Commit 7c9edd65 authored by jvoisin's avatar jvoisin
Browse files

Bugfix, and more pylint conformity

parent 72e73f1f
......@@ -8,66 +8,76 @@ import subprocess
import sys
sys.path.append('..')
import cli
#import cli
from lib import mat
import test
class Test_Remove_cli(test.MATTest):
class TestRemovecli(test.MATTest):
'''
test if cli.py correctly remove metadatas
'''
def test_remove(self):
'''make sure that the cli remove all compromizing meta'''
for clean, dirty in self.file_list:
for _, dirty in self.file_list:
subprocess.call(['../cli.py', dirty])
current_file = mat.create_class_file(dirty, False, True)
self.assertTrue(current_file.is_clean())
def test_remove_empty(self):
'''Test removal with clean files'''
for clean, dirty in self.file_list:
for clean, _ in self.file_list:
subprocess.call(['../cli.py', clean])
current_file = mat.create_class_file(clean, False, True)
self.assertTrue(current_file.is_clean())
class Test_List_cli(test.MATTest):
class TestListcli(test.MATTest):
'''
test if cli.py correctly display metadatas
'''
def test_list_clean(self):
'''check if get_meta returns meta'''
for clean, dirty in self.file_list:
for clean, _ in self.file_list:
proc = subprocess.Popen(['../cli.py', '-d', clean],
stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful meta found" % clean)
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), "[+] File %s :\nNo harmful \
meta found" % clean)
def test_list_dirty(self):
'''check if get_meta returns all the expected meta'''
for clean, dirty in self.file_list:
for _, dirty in self.file_list:
proc = subprocess.Popen(['../cli.py', '-d', dirty],
stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
stdout, _ = proc.communicate()
self.assertNotEqual(stdout, "[+] File %s" % dirty)
class Test_isClean_cli(test.MATTest):
class TestisCleancli(test.MATTest):
'''
check if cli.py correctly check if a file is clean or not
'''
#FIXME : use an external file with string as const ?
def test_clean(self):
'''test is_clean on clean files'''
for clean, dirty in self.file_list:
for clean, _ in self.file_list:
proc = subprocess.Popen(['../cli.py', '-c', clean],
stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), '[+] %s is clean' % clean)
def test_dirty(self):
'''test is_clean on dirty files'''
for clean, dirty in self.file_list:
for _, dirty in self.file_list:
proc = subprocess.Popen(['../cli.py', '-c', dirty],
stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
stdout, _ = proc.communicate()
self.assertEqual(stdout.strip('\n'), '[+] %s is not clean' % dirty)
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Test_Remove_cli))
suite.addTest(unittest.makeSuite(Test_List_cli))
suite.addTest(unittest.makeSuite(Test_isClean_cli))
unittest.TextTestRunner(verbosity=2).run(suite)
suite.addTest(unittest.makeSuite(TestRemovecli))
suite.addTest(unittest.makeSuite(TestListcli))
suite.addTest(unittest.makeSuite(TestisCleancli))
unittest.TextTestRunner(test.VERBOSITY).run(suite)
......@@ -10,55 +10,64 @@ import sys
sys.path.append('..')
from lib import mat
class Test_Remove_lib(test.MATTest):
class TestRemovelib(test.MATTest):
'''
test the remove_all() method
'''
def test_remove(self):
'''make sure that the lib remove all compromizing meta'''
for clean, dirty in self.file_list:
for _, dirty in self.file_list:
current_file = mat.create_class_file(dirty, False, True)
current_file.remove_all()
self.assertTrue(current_file.is_clean())
def test_remove_empty(self):
'''Test removal with clean files'''
for clean, dirty in self.file_list:
for clean, _ in self.file_list:
current_file = mat.create_class_file(clean, False, True)
current_file.remove_all()
self.assertTrue(current_file.is_clean())
class Test_List_lib(test.MATTest):
class TestListlib(test.MATTest):
'''
test the get_meta() method
'''
def test_list(self):
'''check if get_meta returns all the expected meta'''
for clean, dirty in self.file_list:
for _, dirty in self.file_list:
current_file = mat.create_class_file(dirty, False, True)
#FIXME assertisNotNone() : python 2.7
self.assertTrue(current_file.get_meta())
def testlist_list_empty(self):
'''check that a listing of a clean file return an empty dict'''
for clean, dirty in self.file_list:
for clean, _ in self.file_list:
current_file = mat.create_class_file(clean, False, True)
self.assertEqual(current_file.get_meta(), dict())
class Test_isClean_lib(test.MATTest):
class TestisCleanlib(test.MATTest):
'''
test the is_clean() method
'''
def test_dirty(self):
'''test is_clean on clean files'''
for clean, dirty in self.file_list:
for _, dirty in self.file_list:
current_file = mat.create_class_file(dirty, False, True)
self.assertFalse(current_file.is_clean())
def test_clean(self):
'''test is_clean on dirty files'''
for clean, dirty in self.file_list:
for clean, _ in self.file_list:
current_file = mat.create_class_file(clean, False, True)
self.assertTrue(current_file.is_clean())
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Test_Remove_lib))
suite.addTest(unittest.makeSuite(Test_List_lib))
suite.addTest(unittest.makeSuite(Test_isClean_lib))
unittest.TextTestRunner(verbosity=2).run(suite)
Suite = unittest.TestSuite()
Suite.addTest(unittest.makeSuite(TestRemovelib))
Suite.addTest(unittest.makeSuite(TestListlib))
Suite.addTest(unittest.makeSuite(TestisCleanlib))
unittest.TextTestRunner(test.VERBOSITY).run(Suite)
......@@ -15,6 +15,7 @@ import unittest
sys.path.append('..')
from lib import mat
VERBOSITY = 3
FILE_LIST = zip(glob.glob('clean*'), glob.glob('dirty*'))
class MATTest(unittest.TestCase):
......
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