Revision c08d76f5 test/ganeti.impexpd_unittest.py

b/test/ganeti.impexpd_unittest.py
76 76
                                        cmd_prefix=cmd_prefix,
77 77
                                        cmd_suffix=cmd_suffix)
78 78

  
79
                builder = impexpd.CommandBuilder(mode, opts, 1)
79
                builder = impexpd.CommandBuilder(mode, opts, 1, 2, 3)
80 80

  
81 81
                # Check complete command
82 82
                cmd = builder.GetCommand()
......
108 108
                            ca="/some/path/with,a/,comma")
109 109

  
110 110
    for mode in [constants.IEM_IMPORT, constants.IEM_EXPORT]:
111
      builder = impexpd.CommandBuilder(mode, opts, 1)
111
      builder = impexpd.CommandBuilder(mode, opts, 1, 2, 3)
112 112
      self.assertRaises(errors.GenericError, builder.GetCommand)
113 113

  
114 114
  def testModeError(self):
......
117 117
    assert mode not in [constants.IEM_IMPORT, constants.IEM_EXPORT]
118 118

  
119 119
    opts = CmdBuilderConfig(host="localhost", port=1234)
120
    builder = impexpd.CommandBuilder(mode, opts, 1)
120
    builder = impexpd.CommandBuilder(mode, opts, 1, 2, 3)
121 121
    self.assertRaises(errors.GenericError, builder.GetCommand)
122 122

  
123 123

  
124
class TestCalcThroughput(unittest.TestCase):
125
  def test(self):
126
    self.assertEqual(impexpd._CalcThroughput([]), None)
127
    self.assertEqual(impexpd._CalcThroughput([(0, 0)]), None)
128

  
129
    samples = [
130
      (0.0, 0.0),
131
      (10.0, 100.0),
132
      ]
133
    self.assertAlmostEqual(impexpd._CalcThroughput(samples), 10.0, 3)
134

  
135
    samples = [
136
      (5.0, 7.0),
137
      (10.0, 100.0),
138
      (16.0, 181.0),
139
      ]
140
    self.assertAlmostEqual(impexpd._CalcThroughput(samples), 15.818, 3)
141

  
142

  
124 143
if __name__ == "__main__":
125 144
  testutils.GanetiTestProgram()

Also available in: Unified diff