diff options
| author | jvoisin | 2019-10-13 11:54:47 +0200 |
|---|---|---|
| committer | jvoisin | 2019-10-13 11:54:47 +0200 |
| commit | 4034cf9a1af52cb26ec551cea6af90683677e132 (patch) | |
| tree | cccf4b36931977f1378084f33283bd6685280421 /tests/test_climat2.py | |
| parent | 5f0b3beb46d09af26107fe5f80e63ddccb127a59 (diff) | |
Copy file permissions
Mat2 (the cli) will now copy the input file permissions
to the output file.
Diffstat (limited to '')
| -rw-r--r-- | tests/test_climat2.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 9d816b1..17fce82 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | import random | 1 | import random |
| 2 | import os | 2 | import os |
| 3 | import shutil | 3 | import shutil |
| 4 | import stat | ||
| 4 | import subprocess | 5 | import subprocess |
| 5 | import unittest | 6 | import unittest |
| 6 | import glob | 7 | import glob |
| @@ -132,6 +133,33 @@ class TestCleanMeta(unittest.TestCase): | |||
| 132 | self.assertNotIn(b'Comment: Created with GIMP', stdout) | 133 | self.assertNotIn(b'Comment: Created with GIMP', stdout) |
| 133 | 134 | ||
| 134 | os.remove('./tests/data/clean.jpg') | 135 | os.remove('./tests/data/clean.jpg') |
| 136 | os.remove('./tests/data/clean.cleaned.jpg') | ||
| 137 | |||
| 138 | |||
| 139 | class TestCopyPermissions(unittest.TestCase): | ||
| 140 | def test_jpg_777(self): | ||
| 141 | shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') | ||
| 142 | os.chmod('./tests/data/clean.jpg', 0o777) | ||
| 143 | |||
| 144 | proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.jpg'], | ||
| 145 | stdout=subprocess.PIPE) | ||
| 146 | stdout, _ = proc.communicate() | ||
| 147 | self.assertIn(b'Comment: Created with GIMP', stdout) | ||
| 148 | |||
| 149 | proc = subprocess.Popen(mat2_binary + ['./tests/data/clean.jpg'], | ||
| 150 | stdout=subprocess.PIPE) | ||
| 151 | stdout, _ = proc.communicate() | ||
| 152 | |||
| 153 | proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.cleaned.jpg'], | ||
| 154 | stdout=subprocess.PIPE) | ||
| 155 | stdout, _ = proc.communicate() | ||
| 156 | self.assertNotIn(b'Comment: Created with GIMP', stdout) | ||
| 157 | |||
| 158 | permissions = os.stat('./tests/data/clean.cleaned.jpg')[stat.ST_MODE] | ||
| 159 | self.assertEqual(permissions, 0o100777) | ||
| 160 | |||
| 161 | os.remove('./tests/data/clean.jpg') | ||
| 162 | os.remove('./tests/data/clean.cleaned.jpg') | ||
| 135 | 163 | ||
| 136 | 164 | ||
| 137 | class TestIsSupported(unittest.TestCase): | 165 | class TestIsSupported(unittest.TestCase): |
