From 4034cf9a1af52cb26ec551cea6af90683677e132 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 13 Oct 2019 11:54:47 +0200 Subject: Copy file permissions Mat2 (the cli) will now copy the input file permissions to the output file. --- tests/test_climat2.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') 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 @@ import random import os import shutil +import stat import subprocess import unittest import glob @@ -132,6 +133,33 @@ class TestCleanMeta(unittest.TestCase): self.assertNotIn(b'Comment: Created with GIMP', stdout) os.remove('./tests/data/clean.jpg') + os.remove('./tests/data/clean.cleaned.jpg') + + +class TestCopyPermissions(unittest.TestCase): + def test_jpg_777(self): + shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') + os.chmod('./tests/data/clean.jpg', 0o777) + + proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.jpg'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertIn(b'Comment: Created with GIMP', stdout) + + proc = subprocess.Popen(mat2_binary + ['./tests/data/clean.jpg'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + + proc = subprocess.Popen(mat2_binary + ['--show', './tests/data/clean.cleaned.jpg'], + stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + self.assertNotIn(b'Comment: Created with GIMP', stdout) + + permissions = os.stat('./tests/data/clean.cleaned.jpg')[stat.ST_MODE] + self.assertEqual(permissions, 0o100777) + + os.remove('./tests/data/clean.jpg') + os.remove('./tests/data/clean.cleaned.jpg') class TestIsSupported(unittest.TestCase): -- cgit v1.3