diff options
| author | jvoisin | 2011-06-18 04:42:52 +0200 |
|---|---|---|
| committer | jvoisin | 2011-06-18 04:42:52 +0200 |
| commit | de5917e5f01374bb1a647f49ae85283241a2bea9 (patch) | |
| tree | fbe5483af79965d1445bd4aaa528f0ad3e48a8aa /test/clitest.py | |
| parent | 0523e034870ed80cc3916ebb78552d661de4d3b0 (diff) | |
Creation of the arborescence
Diffstat (limited to 'test/clitest.py')
| -rwxr-xr-x | test/clitest.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/clitest.py b/test/clitest.py new file mode 100755 index 0000000..da0563f --- /dev/null +++ b/test/clitest.py | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | #!/usr/bin/python | ||
| 2 | ''' | ||
| 3 | Unit test for the CLI interface | ||
| 4 | ''' | ||
| 5 | |||
| 6 | import unittest | ||
| 7 | import subprocess | ||
| 8 | import sys | ||
| 9 | sys.path.append('..') | ||
| 10 | import cli | ||
| 11 | from lib import mat | ||
| 12 | import test | ||
| 13 | |||
| 14 | class Test_Remove_cli(test.MATTest): | ||
| 15 | def test_remove(self): | ||
| 16 | '''make sure that the cli remove all compromizing meta''' | ||
| 17 | for clean, dirty in self.file_list: | ||
| 18 | subprocess.call(['../cli.py', dirty]) | ||
| 19 | current_file = mat.create_class_file(dirty) | ||
| 20 | self.assertTrue(current_file.is_clean()) | ||
| 21 | |||
| 22 | def test_remove_empty(self): | ||
| 23 | '''Test removal with clean files''' | ||
| 24 | for clean, dirty in self.file_list: | ||
| 25 | subprocess.call(['../cli.py', clean]) | ||
| 26 | current_file = mat.create_class_file(clean) | ||
| 27 | self.assertTrue(current_file.is_clean()) | ||
| 28 | |||
| 29 | |||
| 30 | class Test_List_cli(test.MATTest): | ||
| 31 | def test_list_clean(self): | ||
| 32 | '''check if get_meta returns meta''' | ||
| 33 | for clean, dirty in self.file_list: | ||
| 34 | #fixme : a (clean|dirty).(jpg|pdf|...).out ? | ||
| 35 | proc = subprocess.Popen(['../cli.py', '-d', clean], | ||
| 36 | stdout=subprocess.PIPE) | ||
| 37 | stdout, stderr = proc.communicate() | ||
| 38 | self.assertEqual(stdout, "[+] File %s" % clean) | ||
| 39 | |||
| 40 | def test_list_dirty(self): | ||
| 41 | '''check if get_meta returns all the expected meta''' | ||
| 42 | for clean, dirty in self.file_list: | ||
| 43 | proc = subprocess.Popen(['../cli.py', '-d', dirty], | ||
| 44 | stdout=subprocess.PIPE) | ||
| 45 | stdout, stderr = proc.communicate() | ||
| 46 | self.assertNotEqual(stdout, "[+] File %s" % dirty) | ||
| 47 | |||
| 48 | |||
| 49 | class Test_isClean_cli(test.MATTest): | ||
| 50 | #FIXME : use an external file with string as const ? | ||
| 51 | def test_clean(self): | ||
| 52 | '''test is_clean on clean files''' | ||
| 53 | for clean, dirty in self.file_list: | ||
| 54 | proc = subprocess.Popen(['../cli.py', '-c', clean], | ||
| 55 | stdout=subprocess.PIPE) | ||
| 56 | stdout, stderr = proc.communicate() | ||
| 57 | self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean) | ||
| 58 | |||
| 59 | def test_dirty(self): | ||
| 60 | '''test is_clean on dirty files''' | ||
| 61 | for clean, dirty in self.file_list: | ||
| 62 | proc = subprocess.Popen(['../cli.py', '-c', dirty], | ||
| 63 | stdout=subprocess.PIPE) | ||
| 64 | stdout, stderr = proc.communicate() | ||
| 65 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) | ||
| 66 | |||
| 67 | |||
| 68 | if __name__ == '__main__': | ||
| 69 | suite = unittest.TestSuite() | ||
| 70 | suite.addTest(unittest.makeSuite(Test_Remove_cli)) | ||
| 71 | suite.addTest(unittest.makeSuite(Test_List_cli)) | ||
| 72 | suite.addTest(unittest.makeSuite(Test_isClean_cli)) | ||
| 73 | unittest.TextTestRunner(verbosity=2).run(suite) | ||
