diff options
author | Didier Raboud <odyx@debian.org> | 2012-05-22 10:28:08 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2012-05-22 10:28:24 +0200 |
commit | fd37a778bc1cfc8771e09d3c24fc4a869f4d3a33 (patch) | |
tree | 209c66d84fc57448774f0d83a2d6f43c4aa0b379 /test | |
parent | 2c2abf9329f28922a50612d2c12d243e89e68aea (diff) |
PyUT: Implement test for lsb_release.compare_release.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_lsb_release.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/test/test_lsb_release.py b/test/test_lsb_release.py index f174b6c..0292f4a 100644 --- a/test/test_lsb_release.py +++ b/test/test_lsb_release.py @@ -75,9 +75,33 @@ class TestLSBRelease(unittest.TestCase): release_line = string.strip(release_line,',') self.assertEqual(sorted(lr.parse_policy_line(release_line)),sorted(longnames),'parse_policy_line(' + release_line + ')') - @unittest.skip('Test not implemented.') def test_compare_release(self): - raise NotImplementedError() + # Test that equal suite strings lead to 0 + fake_release_equal = rnd_string(1,25) + x = [rnd_string(1,12), {'suite': fake_release_equal}] + y = [rnd_string(1,12), {'suite': fake_release_equal}] + self.assertEqual(lr.compare_release(x,y),0) + + # Test that sequences in RELEASES_ORDER lead to reliable output + RO_min = 0 + RO_max = len(lr.RELEASES_ORDER) - 1 + x_suite_i = random.randint(RO_min,RO_max) + y_suite_i = random.randint(RO_min,RO_max) + x[1]['suite'] = lr.RELEASES_ORDER[x_suite_i] + y[1]['suite'] = lr.RELEASES_ORDER[y_suite_i] + supposed_output = y_suite_i - x_suite_i + self.assertEqual(lr.compare_release(x,y), + supposed_output, + 'compare_release(' + x[1]['suite'] + ',' + y[1]['suite'] + ') =? ' + str(supposed_output)) + + # Test that sequences not in RELEASES_ORDER lead to reliable output + x[1]['suite'] = rnd_string(1,12) + y[1]['suite'] = rnd_string(1,12) + supposed_output = cmp(x[1]['suite'],y[1]['suite']) + self.assertEqual(lr.compare_release(x,y), + supposed_output, + 'compare_release(' + x[1]['suite'] + ',' + y[1]['suite'] + ') =? ' + str(supposed_output)) + @unittest.skip('Test not implemented.') def test_parse_apt_policy(self): raise NotImplementedError() |