libtest.py 2.06 KB
Newer Older
1
2
3
4
5
6
#!/usr/bin/python

'''
    Unit test for the library
'''

7
8
import unittest
import test
jvoisin's avatar
jvoisin committed
9
10
11
import sys
sys.path.append('..')
from lib import mat
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

class Test_Remove_lib(test.MATTest):
    def test_remove(self):
        '''make sure that the lib remove all compromizing meta'''
        for clean, dirty in self.file_list:
            current_file = mat.create_class_file(dirty)
            current_file.remove_all()
            self.assertTrue(current_file.is_clean())

    def test_remove_empty(self):
        '''Test removal with clean files'''
        for clean, dirty in self.file_list:
            current_file = mat.create_class_file(clean)
            current_file.remove_all()
            self.assertTrue(current_file.is_clean())


class Test_List_lib(test.MATTest):
    def test_list(self):
        '''check if get_meta returns all the expected meta'''
        for clean, dirty in self.file_list:
            current_file = mat.create_class_file(dirty)
jvoisin's avatar
jvoisin committed
34
            meta_list = ('exif', 'photoshop', 'adobe')
35
            self.assertEqual(current_file.get_meta(), meta_list)
36
37
38
39
40

    def testlist_list_empty(self):
        '''check that a listing of a clean file return an empty dict'''
        for clean, dirty in self.file_list:
            current_file = mat.create_class_file(clean)
jvoisin's avatar
jvoisin committed
41
            self.assertEqual(current_file.get_meta(), list())
42
43
44


class Test_isClean_lib(test.MATTest):
45
    def test_dirty(self):
46
47
48
        '''test is_clean on clean files'''
        for clean, dirty in self.file_list:
            current_file = mat.create_class_file(dirty)
jvoisin's avatar
jvoisin committed
49
            self.assertFalse(current_file.is_clean())
50
51
52
53
54

    def test_clean(self):
        '''test is_clean on dirty files'''
        for clean, dirty in self.file_list:
            current_file = mat.create_class_file(clean)
jvoisin's avatar
jvoisin committed
55
            self.assertTrue(current_file.is_clean())
56
57
58
59
60
61
62
63
64


if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(Test_Remove_lib))
    suite.addTest(unittest.makeSuite(Test_List_lib))
    suite.addTest(unittest.makeSuite(Test_isClean_lib))
    unittest.TextTestRunner(verbosity=2).run(suite)