diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/clitest.py | 25 | ||||
| -rw-r--r-- | test/libtest.py | 16 |
2 files changed, 39 insertions, 2 deletions
diff --git a/test/clitest.py b/test/clitest.py index cb615ce..4155d45 100644 --- a/test/clitest.py +++ b/test/clitest.py | |||
| @@ -72,10 +72,33 @@ class TestisCleancli(test.MATTest): | |||
| 72 | stdout, _ = proc.communicate() | 72 | stdout, _ = proc.communicate() |
| 73 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) | 73 | self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty) |
| 74 | 74 | ||
| 75 | class TestFileAttributes(unittest.TestCase): | ||
| 76 | ''' | ||
| 77 | test various stuffs about files (readable, writable, exist, ...) | ||
| 78 | ''' | ||
| 79 | def test_not_readable(self): | ||
| 80 | proc = subprocess.Popen(['../mat-cli', 'not_readable'], | ||
| 81 | stdout=subprocess.PIPE) | ||
| 82 | stdout, _ = proc.communicate() | ||
| 83 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_readable') | ||
| 84 | |||
| 85 | def test_not_writtable(self): | ||
| 86 | proc = subprocess.Popen(['../mat-cli', 'not_writtable'], | ||
| 87 | stdout=subprocess.PIPE) | ||
| 88 | stdout, _ = proc.communicate() | ||
| 89 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'not_writtable') | ||
| 90 | |||
| 91 | def test_not_exist(self): | ||
| 92 | proc = subprocess.Popen(['../mat-cli', 'ilikecookies'], | ||
| 93 | stdout=subprocess.PIPE) | ||
| 94 | stdout, _ = proc.communicate() | ||
| 95 | self.assertEqual(stdout.strip('\n'), 'Unable to pocess %s' % 'ilikecookies') | ||
| 75 | 96 | ||
| 76 | if __name__ == '__main__': | 97 | if __name__ == '__main__': |
| 77 | suite = unittest.TestSuite() | 98 | suite = unittest.TestSuite() |
| 78 | suite.addTest(unittest.makeSuite(TestRemovecli)) | 99 | suite.addTest(unittest.makeSuite(TestRemovecli)) |
| 79 | suite.addTest(unittest.makeSuite(TestListcli)) | 100 | suite.addTest(unittest.makeSuite(TestListcli)) |
| 80 | suite.addTest(unittest.makeSuite(TestisCleancli)) | 101 | suite.addTest(unittest.makeSuite(TestisCleancli)) |
| 81 | unittest.TextTestRunner(verbosity=test.VERBOSITY).run(suite) | 102 | test_result = unittest.TextTestRunner(verbosity=test.VERBOSITY).run(suite) |
| 103 | sys.exit(len(test_result.failures)) | ||
| 104 | |||
diff --git a/test/libtest.py b/test/libtest.py index ecbc03e..bfeb548 100644 --- a/test/libtest.py +++ b/test/libtest.py | |||
| @@ -64,11 +64,25 @@ class TestisCleanlib(test.MATTest): | |||
| 64 | current_file = mat.create_class_file(clean, False, True) | 64 | current_file = mat.create_class_file(clean, False, True) |
| 65 | self.assertTrue(current_file.is_clean()) | 65 | self.assertTrue(current_file.is_clean()) |
| 66 | 66 | ||
| 67 | class TestFileAttributes(unittest.TestCase): | ||
| 68 | ''' | ||
| 69 | test various stuffs about files (readable, writable, exist, ...) | ||
| 70 | ''' | ||
| 71 | def test_not_readable(self): | ||
| 72 | self.assertFalse(mat.create_class_file('not_readable', False, True)) | ||
| 73 | |||
| 74 | def test_not_writtable(self): | ||
| 75 | self.assertFalse(mat.create_class_file('not_writtable', False, True)) | ||
| 76 | |||
| 77 | def test_not_exist(self): | ||
| 78 | self.assertFalse(mat.create_class_file('ilikecookies', False, True)) | ||
| 67 | 79 | ||
| 68 | if __name__ == '__main__': | 80 | if __name__ == '__main__': |
| 69 | Suite = unittest.TestSuite() | 81 | Suite = unittest.TestSuite() |
| 70 | Suite.addTest(unittest.makeSuite(TestRemovelib)) | 82 | Suite.addTest(unittest.makeSuite(TestRemovelib)) |
| 71 | Suite.addTest(unittest.makeSuite(TestListlib)) | 83 | Suite.addTest(unittest.makeSuite(TestListlib)) |
| 72 | Suite.addTest(unittest.makeSuite(TestisCleanlib)) | 84 | Suite.addTest(unittest.makeSuite(TestisCleanlib)) |
| 73 | unittest.TextTestRunner(verbosity=test.VERBOSITY).run(Suite) | 85 | Suite.addTest(unittest.makeSuite(TestFileAttributes)) |
| 86 | test_result = unittest.TextTestRunner(verbosity=test.VERBOSITY).run(Suite) | ||
| 87 | sys.exit(len(test_result.failures)) | ||
| 74 | 88 | ||
