summaryrefslogtreecommitdiff
path: root/test/clitest.py
diff options
context:
space:
mode:
authorjvoisin2014-02-01 04:10:09 +0000
committerjvoisin2014-02-01 04:10:09 +0000
commit36c963ef60babe18c5bbd0feb624f2d5615a23df (patch)
tree7c08971388f54ba2b7f56ba3a783872540c6b53e /test/clitest.py
parent173449009769ce86493a179acb9c66c87125dce3 (diff)
Fix https://labs.riseup.net/code/issues/6416
This commit fix the "Does not inform the user when files where lost while cleaning an archive" (for the CLI) bug, and adds a test for it.
Diffstat (limited to 'test/clitest.py')
-rw-r--r--test/clitest.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/test/clitest.py b/test/clitest.py
index 312822f..ad895f5 100644
--- a/test/clitest.py
+++ b/test/clitest.py
@@ -5,9 +5,11 @@
5 Unit test for the CLI interface 5 Unit test for the CLI interface
6''' 6'''
7 7
8import os
8import unittest 9import unittest
9import subprocess 10import subprocess
10import sys 11import sys
12import tarfile
11 13
12sys.path.append('..') 14sys.path.append('..')
13from MAT import mat 15from MAT import mat
@@ -21,14 +23,14 @@ class TestRemovecli(test.MATTest):
21 def test_remove(self): 23 def test_remove(self):
22 '''make sure that the cli remove all compromizing meta''' 24 '''make sure that the cli remove all compromizing meta'''
23 for _, dirty in self.file_list: 25 for _, dirty in self.file_list:
24 subprocess.call(['../mat', dirty]) 26 subprocess.call(['../mat', '--add2archive', dirty])
25 current_file = mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True) 27 current_file = mat.create_class_file(dirty, False, add2archive=True, low_pdf_quality=True)
26 self.assertTrue(current_file.is_clean()) 28 self.assertTrue(current_file.is_clean())
27 29
28 def test_remove_empty(self): 30 def test_remove_empty(self):
29 '''Test removal with clean files''' 31 '''Test removal with clean files\n'''
30 for clean, _ in self.file_list: 32 for clean, _ in self.file_list:
31 subprocess.call(['../mat', clean]) 33 subprocess.call(['../mat', '--add2archive', clean])
32 current_file = mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True) 34 current_file = mat.create_class_file(clean, False, add2archive=True, low_pdf_quality=True)
33 self.assertTrue(current_file.is_clean()) 35 self.assertTrue(current_file.is_clean())
34 36
@@ -97,11 +99,24 @@ class TestFileAttributes(unittest.TestCase):
97 99
98 def test_empty(self): 100 def test_empty(self):
99 ''' test MAT's behaviour on empty file''' 101 ''' test MAT's behaviour on empty file'''
100 proc = subprocess.Popen(['../mat', 'empty_file'], 102 proc = subprocess.Popen(['../mat', 'empty_file'], stdout=subprocess.PIPE)
101 stdout=subprocess.PIPE)
102 stdout, _ = proc.communicate() 103 stdout, _ = proc.communicate()
103 self.assertEqual(str(stdout).strip('\n'), 'Unable to process %s' % 'ilikecookies') 104 self.assertEqual(str(stdout).strip('\n'), 'Unable to process %s' % 'ilikecookies')
104 105
106class TestUnsupported(test.MATTest):
107 def test_abort_unsupported(self):
108 ''' test if the cli aborts on unsupported files
109 '''
110 tarpath = os.path.join(self.tmpdir, "test.tar.bz2")
111 tar = tarfile.open(tarpath, "w")
112 for f in ('../mat.desktop', '../README.security', '../setup.py'):
113 tar.add(f, f[3:]) # trim '../'
114 tar.close()
115 proc = subprocess.Popen(['../mat', tarpath], stdout=subprocess.PIPE)
116 stdout, _ = proc.communicate()
117 self.assertTrue('It contains unsupported filetypes:'\
118 '\n- mat.desktop\n- README.security\n- setup.py\n'
119 in str(stdout))
105 120
106def get_tests(): 121def get_tests():
107 ''' Return every clitests''' 122 ''' Return every clitests'''
@@ -109,4 +124,5 @@ def get_tests():
109 suite.addTest(unittest.makeSuite(TestRemovecli)) 124 suite.addTest(unittest.makeSuite(TestRemovecli))
110 suite.addTest(unittest.makeSuite(TestListcli)) 125 suite.addTest(unittest.makeSuite(TestListcli))
111 suite.addTest(unittest.makeSuite(TestisCleancli)) 126 suite.addTest(unittest.makeSuite(TestisCleancli))
127 suite.addTest(unittest.makeSuite(TestUnsupported))
112 return suite 128 return suite