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