aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_postprocessor.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-07-03 00:57:03 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2023-07-03 00:57:03 -0400
commitef30b1fa552fd4ceebdd14bbcc16f30f430883f8 (patch)
treecf680fbc0801f3090b28c190b7dd4a9d0fe1f454 /test/test_postprocessor.py
parent9fb906aeb3816abb42f459d1b67e35024e6f2348 (diff)
New upstream version 1.25.7.upstream/1.25.7
Diffstat (limited to 'test/test_postprocessor.py')
-rw-r--r--test/test_postprocessor.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/test_postprocessor.py b/test/test_postprocessor.py
index ac89b55..554a51e 100644
--- a/test/test_postprocessor.py
+++ b/test/test_postprocessor.py
@@ -164,6 +164,76 @@ class ClassifyTest(BasePostprocessorTest):
mkdirs.assert_called_once_with(path, exist_ok=True)
+class ExecTest(BasePostprocessorTest):
+
+ def test_command_string(self):
+ self._create({
+ "command": "echo {} && rm {};",
+ })
+
+ with patch("subprocess.Popen") as p:
+ i = Mock()
+ i.wait.return_value = 0
+ p.return_value = i
+ self._trigger(("after",))
+
+ p.assert_called_once_with(
+ "echo {0} && rm {0};".format(self.pathfmt.realpath), shell=True)
+ i.wait.assert_called_once_with()
+
+ def test_command_list(self):
+ self._create({
+ "command": ["~/script.sh", "{category}",
+ "\fE _directory.upper()"],
+ })
+
+ with patch("subprocess.Popen") as p:
+ i = Mock()
+ i.wait.return_value = 0
+ p.return_value = i
+ self._trigger(("after",))
+
+ p.assert_called_once_with(
+ [
+ os.path.expanduser("~/script.sh"),
+ self.pathfmt.kwdict["category"],
+ self.pathfmt.realdirectory.upper(),
+ ],
+ shell=False,
+ )
+
+ def test_command_returncode(self):
+ self._create({
+ "command": "echo {}",
+ })
+
+ with patch("subprocess.Popen") as p:
+ i = Mock()
+ i.wait.return_value = 123
+ p.return_value = i
+
+ with self.assertLogs() as log:
+ self._trigger(("after",))
+
+ msg = ("WARNING:postprocessor.exec:'echo {}' returned with "
+ "non-zero exit status (123)".format(self.pathfmt.realpath))
+ self.assertEqual(log.output[0], msg)
+
+ def test_async(self):
+ self._create({
+ "async" : True,
+ "command": "echo {}",
+ })
+
+ with patch("subprocess.Popen") as p:
+ i = Mock()
+ p.return_value = i
+ self._trigger(("after",))
+
+ self.assertTrue(p.called)
+ self.assertFalse(i.wait.called)
+
+
class MetadataTest(BasePostprocessorTest):
def test_metadata_default(self):