summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/clitest.py48
-rw-r--r--test/libtest.py37
-rw-r--r--test/test.py1
3 files changed, 53 insertions, 33 deletions
diff --git a/test/clitest.py b/test/clitest.py
index f603f97..0667d6d 100644
--- a/test/clitest.py
+++ b/test/clitest.py
@@ -8,66 +8,76 @@ import subprocess
8import sys 8import sys
9 9
10sys.path.append('..') 10sys.path.append('..')
11import cli 11#import cli
12from lib import mat 12from lib import mat
13import test 13import test
14 14
15class Test_Remove_cli(test.MATTest): 15class TestRemovecli(test.MATTest):
16 '''
17 test if cli.py correctly remove metadatas
18 '''
16 def test_remove(self): 19 def test_remove(self):
17 '''make sure that the cli remove all compromizing meta''' 20 '''make sure that the cli remove all compromizing meta'''
18 for clean, dirty in self.file_list: 21 for _, dirty in self.file_list:
19 subprocess.call(['../cli.py', dirty]) 22 subprocess.call(['../cli.py', dirty])
20 current_file = mat.create_class_file(dirty, False, True) 23 current_file = mat.create_class_file(dirty, False, True)
21 self.assertTrue(current_file.is_clean()) 24 self.assertTrue(current_file.is_clean())
22 25
23 def test_remove_empty(self): 26 def test_remove_empty(self):
24 '''Test removal with clean files''' 27 '''Test removal with clean files'''
25 for clean, dirty in self.file_list: 28 for clean, _ in self.file_list:
26 subprocess.call(['../cli.py', clean]) 29 subprocess.call(['../cli.py', clean])
27 current_file = mat.create_class_file(clean, False, True) 30 current_file = mat.create_class_file(clean, False, True)
28 self.assertTrue(current_file.is_clean()) 31 self.assertTrue(current_file.is_clean())
29 32
30 33
31class Test_List_cli(test.MATTest): 34class TestListcli(test.MATTest):
35 '''
36 test if cli.py correctly display metadatas
37 '''
32 def test_list_clean(self): 38 def test_list_clean(self):
33 '''check if get_meta returns meta''' 39 '''check if get_meta returns meta'''
34 for clean, dirty in self.file_list: 40 for clean, _ in self.file_list:
35 proc = subprocess.Popen(['../cli.py', '-d', clean], 41 proc = subprocess.Popen(['../cli.py', '-d', clean],
36 stdout=subprocess.PIPE) 42 stdout=subprocess.PIPE)
37 stdout, stderr = proc.communicate() 43 stdout, _ = proc.communicate()
38 self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful meta found" % clean) 44 self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful \
45meta found" % clean)
39 46
40 def test_list_dirty(self): 47 def test_list_dirty(self):
41 '''check if get_meta returns all the expected meta''' 48 '''check if get_meta returns all the expected meta'''
42 for clean, dirty in self.file_list: 49 for _, dirty in self.file_list:
43 proc = subprocess.Popen(['../cli.py', '-d', dirty], 50 proc = subprocess.Popen(['../cli.py', '-d', dirty],
44 stdout=subprocess.PIPE) 51 stdout=subprocess.PIPE)
45 stdout, stderr = proc.communicate() 52 stdout, _ = proc.communicate()
46 self.assertNotEqual(stdout, "[+] File %s" % dirty) 53 self.assertNotEqual(stdout, "[+] File %s" % dirty)
47 54
48 55
49class Test_isClean_cli(test.MATTest): 56class TestisCleancli(test.MATTest):
57 '''
58 check if cli.py correctly check if a file is clean or not
59 '''
50 #FIXME : use an external file with string as const ? 60 #FIXME : use an external file with string as const ?
51 def test_clean(self): 61 def test_clean(self):
52 '''test is_clean on clean files''' 62 '''test is_clean on clean files'''
53 for clean, dirty in self.file_list: 63 for clean, _ in self.file_list:
54 proc = subprocess.Popen(['../cli.py', '-c', clean], 64 proc = subprocess.Popen(['../cli.py', '-c', clean],
55 stdout=subprocess.PIPE) 65 stdout=subprocess.PIPE)
56 stdout, stderr = proc.communicate() 66 stdout, _ = proc.communicate()
57 self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean) 67 self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean)
58 68
59 def test_dirty(self): 69 def test_dirty(self):
60 '''test is_clean on dirty files''' 70 '''test is_clean on dirty files'''
61 for clean, dirty in self.file_list: 71 for _, dirty in self.file_list:
62 proc = subprocess.Popen(['../cli.py', '-c', dirty], 72 proc = subprocess.Popen(['../cli.py', '-c', dirty],
63 stdout=subprocess.PIPE) 73 stdout=subprocess.PIPE)
64 stdout, stderr = proc.communicate() 74 stdout, _ = proc.communicate()
65 self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) 75 self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty)
66 76
67 77
68if __name__ == '__main__': 78if __name__ == '__main__':
69 suite = unittest.TestSuite() 79 suite = unittest.TestSuite()
70 suite.addTest(unittest.makeSuite(Test_Remove_cli)) 80 suite.addTest(unittest.makeSuite(TestRemovecli))
71 suite.addTest(unittest.makeSuite(Test_List_cli)) 81 suite.addTest(unittest.makeSuite(TestListcli))
72 suite.addTest(unittest.makeSuite(Test_isClean_cli)) 82 suite.addTest(unittest.makeSuite(TestisCleancli))
73 unittest.TextTestRunner(verbosity=2).run(suite) 83 unittest.TextTestRunner(test.VERBOSITY).run(suite)
diff --git a/test/libtest.py b/test/libtest.py
index eea8117..7b7611a 100644
--- a/test/libtest.py
+++ b/test/libtest.py
@@ -10,55 +10,64 @@ import sys
10sys.path.append('..') 10sys.path.append('..')
11from lib import mat 11from lib import mat
12 12
13class Test_Remove_lib(test.MATTest): 13class TestRemovelib(test.MATTest):
14 '''
15 test the remove_all() method
16 '''
14 def test_remove(self): 17 def test_remove(self):
15 '''make sure that the lib remove all compromizing meta''' 18 '''make sure that the lib remove all compromizing meta'''
16 for clean, dirty in self.file_list: 19 for _, dirty in self.file_list:
17 current_file = mat.create_class_file(dirty, False, True) 20 current_file = mat.create_class_file(dirty, False, True)
18 current_file.remove_all() 21 current_file.remove_all()
19 self.assertTrue(current_file.is_clean()) 22 self.assertTrue(current_file.is_clean())
20 23
21 def test_remove_empty(self): 24 def test_remove_empty(self):
22 '''Test removal with clean files''' 25 '''Test removal with clean files'''
23 for clean, dirty in self.file_list: 26 for clean, _ in self.file_list:
24 current_file = mat.create_class_file(clean, False, True) 27 current_file = mat.create_class_file(clean, False, True)
25 current_file.remove_all() 28 current_file.remove_all()
26 self.assertTrue(current_file.is_clean()) 29 self.assertTrue(current_file.is_clean())
27 30
28 31
29class Test_List_lib(test.MATTest): 32class TestListlib(test.MATTest):
33 '''
34 test the get_meta() method
35 '''
30 def test_list(self): 36 def test_list(self):
31 '''check if get_meta returns all the expected meta''' 37 '''check if get_meta returns all the expected meta'''
32 for clean, dirty in self.file_list: 38 for _, dirty in self.file_list:
33 current_file = mat.create_class_file(dirty, False, True) 39 current_file = mat.create_class_file(dirty, False, True)
34 #FIXME assertisNotNone() : python 2.7 40 #FIXME assertisNotNone() : python 2.7
35 self.assertTrue(current_file.get_meta()) 41 self.assertTrue(current_file.get_meta())
36 42
37 def testlist_list_empty(self): 43 def testlist_list_empty(self):
38 '''check that a listing of a clean file return an empty dict''' 44 '''check that a listing of a clean file return an empty dict'''
39 for clean, dirty in self.file_list: 45 for clean, _ in self.file_list:
40 current_file = mat.create_class_file(clean, False, True) 46 current_file = mat.create_class_file(clean, False, True)
41 self.assertEqual(current_file.get_meta(), dict()) 47 self.assertEqual(current_file.get_meta(), dict())
42 48
43 49
44class Test_isClean_lib(test.MATTest): 50class TestisCleanlib(test.MATTest):
51 '''
52 test the is_clean() method
53 '''
45 def test_dirty(self): 54 def test_dirty(self):
46 '''test is_clean on clean files''' 55 '''test is_clean on clean files'''
47 for clean, dirty in self.file_list: 56 for _, dirty in self.file_list:
48 current_file = mat.create_class_file(dirty, False, True) 57 current_file = mat.create_class_file(dirty, False, True)
49 self.assertFalse(current_file.is_clean()) 58 self.assertFalse(current_file.is_clean())
50 59
51 def test_clean(self): 60 def test_clean(self):
52 '''test is_clean on dirty files''' 61 '''test is_clean on dirty files'''
53 for clean, dirty in self.file_list: 62 for clean, _ in self.file_list:
54 current_file = mat.create_class_file(clean, False, True) 63 current_file = mat.create_class_file(clean, False, True)
55 self.assertTrue(current_file.is_clean()) 64 self.assertTrue(current_file.is_clean())
56 65
57 66
58if __name__ == '__main__': 67if __name__ == '__main__':
59 suite = unittest.TestSuite() 68 Suite = unittest.TestSuite()
60 suite.addTest(unittest.makeSuite(Test_Remove_lib)) 69 Suite.addTest(unittest.makeSuite(TestRemovelib))
61 suite.addTest(unittest.makeSuite(Test_List_lib)) 70 Suite.addTest(unittest.makeSuite(TestListlib))
62 suite.addTest(unittest.makeSuite(Test_isClean_lib)) 71 Suite.addTest(unittest.makeSuite(TestisCleanlib))
63 unittest.TextTestRunner(verbosity=2).run(suite) 72 unittest.TextTestRunner(test.VERBOSITY).run(Suite)
64 73
diff --git a/test/test.py b/test/test.py
index e9e8f82..ac63f60 100644
--- a/test/test.py
+++ b/test/test.py
@@ -15,6 +15,7 @@ import unittest
15sys.path.append('..') 15sys.path.append('..')
16from lib import mat 16from lib import mat
17 17
18VERBOSITY = 3
18FILE_LIST = zip(glob.glob('clean*'), glob.glob('dirty*')) 19FILE_LIST = zip(glob.glob('clean*'), glob.glob('dirty*'))
19 20
20class MATTest(unittest.TestCase): 21class MATTest(unittest.TestCase):