diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-08 19:55:41 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-08 19:55:41 +0200 |
commit | 69aef18a79a8b23c66ade2aaf0234b46e845cf4c (patch) | |
tree | 057c6f4124f4972f17ec3cb7f61ba227bdf2f285 | |
parent | 8735a5218548be2c04f8aec4e0153dd4e8ac15f4 (diff) | |
download | psutil-69aef18a79a8b23c66ade2aaf0234b46e845cf4c.tar.gz |
update tests
-rwxr-xr-x | psutil/tests/test_misc.py | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index 799dd6b5..545c7af3 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -388,52 +388,55 @@ class TestWrapNumbers(unittest.TestCase): wrap_numbers.cache_clear() def test_first_call(self): - input = {'foo': nt(5, 5, 5)} - self.assertEqual(wrap_numbers(input, 'funname'), input) + input = {'disk1': nt(5, 5, 5)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) def test_input_hasnt_changed(self): - input = {'foo': nt(5, 5, 5)} - self.assertEqual(wrap_numbers(input, 'funname'), input) - self.assertEqual(wrap_numbers(input, 'funname'), input) + input = {'disk1': nt(5, 5, 5)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) + self.assertEqual(wrap_numbers(input, 'disk_io'), input) def test_increase_but_no_wrap(self): - input = {'foo': nt(5, 5, 5)} - self.assertEqual(wrap_numbers(input, 'funname'), input) - input = {'foo': nt(10, 15, 20)} - self.assertEqual(wrap_numbers(input, 'funname'), input) - input = {'foo': nt(20, 25, 30)} - self.assertEqual(wrap_numbers(input, 'funname'), input) - input = {'foo': nt(20, 25, 30)} - self.assertEqual(wrap_numbers(input, 'funname'), input) + input = {'disk1': nt(5, 5, 5)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) + input = {'disk1': nt(10, 15, 20)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) + input = {'disk1': nt(20, 25, 30)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) + input = {'disk1': nt(20, 25, 30)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) def test_wrap(self): # let's say 100 is the threshold - input = {'foo': nt(100, 100, 100)} - self.assertEqual(wrap_numbers(input, 'funname'), input) + input = {'disk1': nt(100, 100, 100)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) # first wrap restarts from 10 - input = {'foo': nt(100, 100, 10)} - self.assertEqual(wrap_numbers(input, 'funname'), - {'foo': nt(100, 100, 110)}) + input = {'disk1': nt(100, 100, 10)} + self.assertEqual(wrap_numbers(input, 'disk_io'), + {'disk1': nt(100, 100, 110)}) # then it remains the same - input = {'foo': nt(100, 100, 10)} - self.assertEqual(wrap_numbers(input, 'funname'), - {'foo': nt(100, 100, 110)}) + input = {'disk1': nt(100, 100, 10)} + self.assertEqual(wrap_numbers(input, 'disk_io'), + {'disk1': nt(100, 100, 110)}) # then it goes up - input = {'foo': nt(100, 100, 90)} - self.assertEqual(wrap_numbers(input, 'funname'), - {'foo': nt(100, 100, 190)}) + input = {'disk1': nt(100, 100, 90)} + self.assertEqual(wrap_numbers(input, 'disk_io'), + {'disk1': nt(100, 100, 190)}) # then it wraps again - input = {'foo': nt(100, 100, 20)} - self.assertEqual(wrap_numbers(input, 'funname'), - {'foo': nt(100, 100, 210)}) + input = {'disk1': nt(100, 100, 20)} + self.assertEqual(wrap_numbers(input, 'disk_io'), + {'disk1': nt(100, 100, 210)}) - def test_dict_keys_mismatch(self): + def test_diff_keys(self): # Emulate a case where the second call to disk_io_counters() # (or whatever) provides a new disk. input = {'disk1': nt(5, 5, 5)} - self.assertEqual(wrap_numbers(input, 'funname'), input) - input = {'disk1': nt(5, 5, 5), 'disk2': nt(7, 7, 7)} - self.assertEqual(wrap_numbers(input, 'funname'), input) + self.assertEqual(wrap_numbers(input, 'disk_io'), input) + input = {'disk1': nt(5, 5, 5), + 'disk2': nt(7, 7, 7)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) + input = {'disk1': nt(8, 8, 8)} + self.assertEqual(wrap_numbers(input, 'disk_io'), input) # =================================================================== |