Commit 2b5a5640 authored by jvoisin's avatar jvoisin
Browse files

Simplification and refactoring of the testsuite

parent 1b409d41
......@@ -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):
......
......@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment