diff options
| author | jvoisin | 2011-06-10 01:29:29 +0200 |
|---|---|---|
| committer | jvoisin | 2011-06-10 01:29:29 +0200 |
| commit | c308cf7daaa4fa46377e2df0f2e9a397981e19b2 (patch) | |
| tree | f016ce17cd6747acc068a7d2fc5093d1bd96fa9e /clitest.py | |
| parent | f7082a21d6511c5069fbb9ff186ce22f3e22fed7 (diff) | |
The current version is (mostly) working
Diffstat (limited to '')
| -rw-r--r-- | clitest.py (renamed from lib/test.py) | 40 |
1 files changed, 12 insertions, 28 deletions
| @@ -1,45 +1,29 @@ | |||
| 1 | import mat | 1 | import cli |
| 2 | import unittest | 2 | import unittest |
| 3 | import shutil | 3 | import test |
| 4 | import glob | ||
| 5 | import tempfile | ||
| 6 | 4 | ||
| 7 | FILE_LIST = zip(glob.glob('clean*'), glob.glob('dirty*')) | 5 | import shlex |
| 6 | import subprocess | ||
| 8 | 7 | ||
| 9 | class MATTest(unittest.TestCase): | 8 | class Test_Remove_cli(test.MATTest): |
| 10 | def setUp(self): | ||
| 11 | '''create working copy of the clean and the dirty file in the TMP dir''' | ||
| 12 | self.file_list = [] | ||
| 13 | self.tmpdir = tempfile.mkdtemp() | ||
| 14 | |||
| 15 | for clean, dirty in FILE_LIST: | ||
| 16 | shutil.copy2(clean, self.tmpdir + clean) | ||
| 17 | shutil.copy2(dirty, self.tmpdir + dirty) | ||
| 18 | self.file_list.append((self.tmpdir + clean, self.tmpdir + dirty)) | ||
| 19 | |||
| 20 | def tearDown(self): | ||
| 21 | '''Remove the tmp folder''' | ||
| 22 | shutil.rmtree(self.tmpdir) | ||
| 23 | |||
| 24 | class Test_Remove(MATTest): | ||
| 25 | def test_remove(self): | 9 | def test_remove(self): |
| 26 | '''make sure that the lib remove all compromizing meta''' | 10 | '''make sure that the cli remove all compromizing meta''' |
| 27 | for clean, dirty in self.file_list: | 11 | for clean, dirty in self.file_list: |
| 28 | mat.file(dirty).remove_all() | 12 | subprocess.call("cli.py %s" dirty) |
| 29 | self.assertTrue(mat.file(dirty).is_clean()) | 13 | self.assertTrue(mat.file(dirty).is_clean()) |
| 30 | 14 | ||
| 31 | def test_remove_empty(self): | 15 | def test_remove_empty(self): |
| 32 | '''Test removal with clean files''' | 16 | '''Test removal with clean files''' |
| 33 | for clean, dirty in self.file_list: | 17 | for clean, dirty in self.file_list: |
| 34 | mat.file(clean).remove_all() | 18 | subprocess.call("cli.py %s" clean) |
| 35 | self.assertTrue(mat.file(clean).is_clean()) | 19 | self.assertTrue(mat.file(dirty).is_clean()) |
| 36 | 20 | ||
| 37 | 21 | ||
| 38 | class Test_List(MATTest): | 22 | class Test_List_cli(test.MATTest): |
| 39 | def test_list(self): | 23 | def test_list(self): |
| 40 | '''check if get_meta returns all the expected meta''' | 24 | '''check if get_meta returns all the expected meta''' |
| 41 | for clean, dirty in self.file_list: | 25 | for clean, dirty in self.file_list: |
| 42 | meta_list = dict() #FIXME | 26 | meta_list = dict("fixme":"please",) #FIXME |
| 43 | self.assertDictEqual(mat.file(dirty).get_meta(), meta_list) | 27 | self.assertDictEqual(mat.file(dirty).get_meta(), meta_list) |
| 44 | 28 | ||
| 45 | def testlist_list_empty(self): | 29 | def testlist_list_empty(self): |
| @@ -48,7 +32,7 @@ class Test_List(MATTest): | |||
| 48 | self.assertEqual(mat.file(clean).get_meta(), None) | 32 | self.assertEqual(mat.file(clean).get_meta(), None) |
| 49 | 33 | ||
| 50 | 34 | ||
| 51 | class Test_isClean(MATTest): | 35 | class Test_isClean_cli(test.MATTest): |
| 52 | def test_clean(self): | 36 | def test_clean(self): |
| 53 | '''test is_clean on clean files''' | 37 | '''test is_clean on clean files''' |
| 54 | for clean, dirty in self.file_list: | 38 | for clean, dirty in self.file_list: |
