summaryrefslogtreecommitdiff
path: root/test/libtest.py
diff options
context:
space:
mode:
authorjvoisin2013-07-20 18:01:16 +0200
committerjvoisin2013-07-20 18:01:16 +0200
commit2b5a56407cda78e9eeff126debf074dbe02579f8 (patch)
treed55fe5c5471e308652e563202482a4cfb4d766bf /test/libtest.py
parent1b409d411c4aaace0572ecc3e77a5e8df16ecec8 (diff)
Simplification and refactoring of the testsuite
Diffstat (limited to 'test/libtest.py')
-rw-r--r--test/libtest.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/test/libtest.py b/test/libtest.py
index 9ab23d8..acf8659 100644
--- a/test/libtest.py
+++ b/test/libtest.py
@@ -20,16 +20,17 @@ class TestRemovelib(test.MATTest):
20 def test_remove(self): 20 def test_remove(self):
21 '''make sure that the lib remove all compromizing meta''' 21 '''make sure that the lib remove all compromizing meta'''
22 for _, dirty in self.file_list: 22 for _, dirty in self.file_list:
23 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) 23 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True)
24 current_file.remove_all() 24 current_file.remove_all()
25 current_file2 = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) 25 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True)
26 self.assertTrue(current_file2.is_clean()) 26 self.assertTrue(current_file.is_clean())
27 27
28 def test_remove_empty(self): 28 def test_remove_empty(self):
29 '''Test removal with clean files''' 29 '''Test removal with clean files'''
30 for clean, _ in self.file_list: 30 for clean, _ in self.file_list:
31 current_file = MAT.mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) 31 current_file = MAT.mat.create_class_file(clean, False, add2archive=True)
32 current_file.remove_all() 32 current_file.remove_all()
33 current_file = MAT.mat.create_class_file(clean, False, add2archive=True)
33 self.assertTrue(current_file.is_clean()) 34 self.assertTrue(current_file.is_clean())
34 35
35 36
@@ -38,15 +39,15 @@ class TestListlib(test.MATTest):
38 test the get_meta() method 39 test the get_meta() method
39 ''' 40 '''
40 def test_list(self): 41 def test_list(self):
41 '''check if get_meta returns all the expected meta''' 42 '''check if get_meta returns metadata'''
42 for _, dirty in self.file_list: 43 for _, dirty in self.file_list:
43 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) 44 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True)
44 self.assertIsNotNone(current_file.get_meta()) 45 self.assertIsNotNone(current_file.get_meta())
45 46
46 def testlist_list_empty(self): 47 def testlist_list_empty(self):
47 '''check that a listing of a clean file return an empty dict''' 48 '''check that a listing of a clean file returns an empty dict'''
48 for clean, _ in self.file_list: 49 for clean, _ in self.file_list:
49 current_file = MAT.mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) 50 current_file = MAT.mat.create_class_file(clean, False, add2archive=True)
50 self.assertEqual(current_file.get_meta(), dict()) 51 self.assertEqual(current_file.get_meta(), dict())
51 52
52 53
@@ -55,15 +56,15 @@ class TestisCleanlib(test.MATTest):
55 test the is_clean() method 56 test the is_clean() method
56 ''' 57 '''
57 def test_dirty(self): 58 def test_dirty(self):
58 '''test is_clean on clean files''' 59 '''test is_clean on dirty files'''
59 for _, dirty in self.file_list: 60 for _, dirty in self.file_list:
60 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) 61 current_file = MAT.mat.create_class_file(dirty, False, add2archive=True)
61 self.assertFalse(current_file.is_clean()) 62 self.assertFalse(current_file.is_clean())
62 63
63 def test_clean(self): 64 def test_clean(self):
64 '''test is_clean on dirty files''' 65 '''test is_clean on clean files'''
65 for clean, _ in self.file_list: 66 for clean, _ in self.file_list:
66 current_file = MAT.mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) 67 current_file = MAT.mat.create_class_file(clean, False, add2archive=True)
67 self.assertTrue(current_file.is_clean()) 68 self.assertTrue(current_file.is_clean())
68 69
69 70
@@ -73,15 +74,15 @@ class TestFileAttributes(unittest.TestCase):
73 ''' 74 '''
74 def test_not_writtable(self): 75 def test_not_writtable(self):
75 ''' test MAT's behaviour on non-writable file''' 76 ''' test MAT's behaviour on non-writable file'''
76 self.assertFalse(MAT.mat.create_class_file('not_writtable', False, add2archive=True, low_pdf_quality=True)) 77 self.assertFalse(MAT.mat.create_class_file('not_writtable', False, add2archive=True))
77 78
78 def test_not_exist(self): 79 def test_not_exist(self):
79 ''' test MAT's behaviour on non-existent file''' 80 ''' test MAT's behaviour on non-existent file'''
80 self.assertFalse(MAT.mat.create_class_file('ilikecookies', False, add2archive=True, low_pdf_quality=True)) 81 self.assertFalse(MAT.mat.create_class_file('ilikecookies', False, add2archive=True))
81 82
82 def test_empty(self): 83 def test_empty(self):
83 ''' test MAT's behaviour on empty file''' 84 ''' test MAT's behaviour on empty file'''
84 self.assertFalse(MAT.mat.create_class_file('empty_file', False, add2archive=True, low_pdf_quality=True)) 85 self.assertFalse(MAT.mat.create_class_file('empty_file', False, add2archive=True))
85 86
86class TestSecureRemove(unittest.TestCase): 87class TestSecureRemove(unittest.TestCase):
87 ''' Test the secure_remove function 88 ''' Test the secure_remove function
@@ -95,11 +96,11 @@ class TestSecureRemove(unittest.TestCase):
95 def test_remove_fail(self): 96 def test_remove_fail(self):
96 ''' test the secure removal of an non-removable file 97 ''' test the secure removal of an non-removable file
97 ''' 98 '''
98 self.assertRaises(MAT.exceptions.UnableToRemoveFile, MAT.mat.secure_remove, '/OMAGAD') 99 self.assertRaises(MAT.exceptions.UnableToRemoveFile, MAT.mat.secure_remove, '/NOTREMOVABLE')
99 100
100 101
101def get_tests(): 102def get_tests():
102 ''' Return every libtests''' 103 ''' Returns every libtests'''
103 suite = unittest.TestSuite() 104 suite = unittest.TestSuite()
104 suite.addTest(unittest.makeSuite(TestRemovelib)) 105 suite.addTest(unittest.makeSuite(TestRemovelib))
105 suite.addTest(unittest.makeSuite(TestListlib)) 106 suite.addTest(unittest.makeSuite(TestListlib))