diff options
Diffstat (limited to 'test/libtest.py')
| -rwxr-xr-x | test/libtest.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/libtest.py b/test/libtest.py new file mode 100755 index 0000000..2bd1fa7 --- /dev/null +++ b/test/libtest.py | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | #!/usr/bin/python | ||
| 2 | |||
| 3 | ''' | ||
| 4 | Unit test for the library | ||
| 5 | ''' | ||
| 6 | |||
| 7 | import unittest | ||
| 8 | import test | ||
| 9 | import sys | ||
| 10 | sys.path.append('..') | ||
| 11 | from lib import mat | ||
| 12 | |||
| 13 | class Test_Remove_lib(test.MATTest): | ||
| 14 | def test_remove(self): | ||
| 15 | '''make sure that the lib remove all compromizing meta''' | ||
| 16 | for clean, dirty in self.file_list: | ||
| 17 | current_file = mat.create_class_file(dirty) | ||
| 18 | current_file.remove_all() | ||
| 19 | self.assertTrue(current_file.is_clean()) | ||
| 20 | |||
| 21 | def test_remove_empty(self): | ||
| 22 | '''Test removal with clean files''' | ||
| 23 | for clean, dirty in self.file_list: | ||
| 24 | current_file = mat.create_class_file(clean) | ||
| 25 | current_file.remove_all() | ||
| 26 | self.assertTrue(current_file.is_clean()) | ||
| 27 | |||
| 28 | |||
| 29 | class Test_List_lib(test.MATTest): | ||
| 30 | def test_list(self): | ||
| 31 | '''check if get_meta returns all the expected meta''' | ||
| 32 | for clean, dirty in self.file_list: | ||
| 33 | current_file = mat.create_class_file(dirty) | ||
| 34 | meta_list = dict({"fixme":"please"},) | ||
| 35 | self.assertEqual(current_file.get_meta(), meta_list) | ||
| 36 | |||
| 37 | def testlist_list_empty(self): | ||
| 38 | '''check that a listing of a clean file return an empty dict''' | ||
| 39 | for clean, dirty in self.file_list: | ||
| 40 | current_file = mat.create_class_file(clean) | ||
| 41 | self.assertEqual(current_file.get_meta(), dict()) #dirty, isn't it ? | ||
| 42 | |||
| 43 | |||
| 44 | class Test_isClean_lib(test.MATTest): | ||
| 45 | def test_dirty(self): | ||
| 46 | '''test is_clean on clean files''' | ||
| 47 | for clean, dirty in self.file_list: | ||
| 48 | current_file = mat.create_class_file(dirty) | ||
| 49 | self.assertTrue(current_file.is_clean()) | ||
| 50 | |||
| 51 | def test_clean(self): | ||
| 52 | '''test is_clean on dirty files''' | ||
| 53 | for clean, dirty in self.file_list: | ||
| 54 | current_file = mat.create_class_file(clean) | ||
| 55 | self.assertFalse(current_file.is_clean()) | ||
| 56 | |||
| 57 | |||
| 58 | if __name__ == '__main__': | ||
| 59 | suite = unittest.TestSuite() | ||
| 60 | suite.addTest(unittest.makeSuite(Test_Remove_lib)) | ||
| 61 | suite.addTest(unittest.makeSuite(Test_List_lib)) | ||
| 62 | suite.addTest(unittest.makeSuite(Test_isClean_lib)) | ||
| 63 | unittest.TextTestRunner(verbosity=2).run(suite) | ||
| 64 | |||
