From 2b5a56407cda78e9eeff126debf074dbe02579f8 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 20 Jul 2013 18:01:16 +0200 Subject: Simplification and refactoring of the testsuite --- test/clitest.py | 3 ++- test/libtest.py | 35 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'test') diff --git a/test/clitest.py b/test/clitest.py index d877698..31e9015 100644 --- a/test/clitest.py +++ b/test/clitest.py @@ -52,7 +52,8 @@ class TestListcli(test.MATTest): proc = subprocess.Popen(['../mat', '-d', dirty], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertNotEqual(str(stdout), "[+] File %s" % dirty) + self.assertNotEqual(str(stdout), "[+] File %s :\n No\ +harmul metadata found" % dirty) class TestisCleancli(test.MATTest): diff --git a/test/libtest.py b/test/libtest.py index 9ab23d8..acf8659 100644 --- a/test/libtest.py +++ b/test/libtest.py @@ -20,16 +20,17 @@ class TestRemovelib(test.MATTest): def test_remove(self): '''make sure that the lib remove all compromizing meta''' for _, dirty in self.file_list: - current_file = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) + current_file = MAT.mat.create_class_file(dirty, False, add2archive=True) current_file.remove_all() - current_file2 = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) - self.assertTrue(current_file2.is_clean()) + current_file = MAT.mat.create_class_file(dirty, False, add2archive=True) + self.assertTrue(current_file.is_clean()) def test_remove_empty(self): '''Test removal with clean files''' for clean, _ in self.file_list: - current_file = MAT.mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) + current_file = MAT.mat.create_class_file(clean, False, add2archive=True) current_file.remove_all() + current_file = MAT.mat.create_class_file(clean, False, add2archive=True) self.assertTrue(current_file.is_clean()) @@ -38,15 +39,15 @@ class TestListlib(test.MATTest): test the get_meta() method ''' def test_list(self): - '''check if get_meta returns all the expected meta''' + '''check if get_meta returns metadata''' for _, dirty in self.file_list: - current_file = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) + current_file = MAT.mat.create_class_file(dirty, False, add2archive=True) self.assertIsNotNone(current_file.get_meta()) def testlist_list_empty(self): - '''check that a listing of a clean file return an empty dict''' + '''check that a listing of a clean file returns an empty dict''' for clean, _ in self.file_list: - current_file = MAT.mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) + current_file = MAT.mat.create_class_file(clean, False, add2archive=True) self.assertEqual(current_file.get_meta(), dict()) @@ -55,15 +56,15 @@ class TestisCleanlib(test.MATTest): test the is_clean() method ''' def test_dirty(self): - '''test is_clean on clean files''' + '''test is_clean on dirty files''' for _, dirty in self.file_list: - current_file = MAT.mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) + current_file = MAT.mat.create_class_file(dirty, False, add2archive=True) self.assertFalse(current_file.is_clean()) def test_clean(self): - '''test is_clean on dirty files''' + '''test is_clean on clean files''' for clean, _ in self.file_list: - current_file = MAT.mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) + current_file = MAT.mat.create_class_file(clean, False, add2archive=True) self.assertTrue(current_file.is_clean()) @@ -73,15 +74,15 @@ class TestFileAttributes(unittest.TestCase): ''' def test_not_writtable(self): ''' test MAT's behaviour on non-writable file''' - self.assertFalse(MAT.mat.create_class_file('not_writtable', False, add2archive=True, low_pdf_quality=True)) + self.assertFalse(MAT.mat.create_class_file('not_writtable', False, add2archive=True)) def test_not_exist(self): ''' test MAT's behaviour on non-existent file''' - self.assertFalse(MAT.mat.create_class_file('ilikecookies', False, add2archive=True, low_pdf_quality=True)) + self.assertFalse(MAT.mat.create_class_file('ilikecookies', False, add2archive=True)) def test_empty(self): ''' test MAT's behaviour on empty file''' - self.assertFalse(MAT.mat.create_class_file('empty_file', False, add2archive=True, low_pdf_quality=True)) + self.assertFalse(MAT.mat.create_class_file('empty_file', False, add2archive=True)) class TestSecureRemove(unittest.TestCase): ''' Test the secure_remove function @@ -95,11 +96,11 @@ class TestSecureRemove(unittest.TestCase): def test_remove_fail(self): ''' test the secure removal of an non-removable file ''' - self.assertRaises(MAT.exceptions.UnableToRemoveFile, MAT.mat.secure_remove, '/OMAGAD') + self.assertRaises(MAT.exceptions.UnableToRemoveFile, MAT.mat.secure_remove, '/NOTREMOVABLE') def get_tests(): - ''' Return every libtests''' + ''' Returns every libtests''' suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestRemovelib)) suite.addTest(unittest.makeSuite(TestListlib)) -- cgit v1.3