aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_postprocessor.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2019-12-25 19:40:28 -0500
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-12-25 19:40:28 -0500
commitf9a1a9dcb7df977eeac9544786df9c0b93795815 (patch)
tree8cb69cf7685da8d7e4deb7dc1d6b209098e1ddfb /test/test_postprocessor.py
parent0c73e982fa596da07f23b377621ab894a9e64884 (diff)
New upstream version 1.12.1upstream/1.12.1
Diffstat (limited to 'test/test_postprocessor.py')
-rw-r--r--test/test_postprocessor.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/test/test_postprocessor.py b/test/test_postprocessor.py
index 0ab89db..17f82c9 100644
--- a/test/test_postprocessor.py
+++ b/test/test_postprocessor.py
@@ -58,7 +58,7 @@ class BasePostprocessorTest(unittest.TestCase):
def setUpClass(cls):
cls.extractor = extractor.find("test:")
cls.dir = tempfile.TemporaryDirectory()
- config.set(("base-directory",), cls.dir.name)
+ config.set((), "base-directory", cls.dir.name)
@classmethod
def tearDownClass(cls):
@@ -151,8 +151,12 @@ class MetadataTest(BasePostprocessorTest):
"ascii" : True,
"indent" : 2,
"extension": "JSON",
+ }, {
+ "public" : "hello",
+ "_private" : "world",
})
+ self.assertEqual(pp.path , pp._path_append)
self.assertEqual(pp.write , pp._write_json)
self.assertEqual(pp.ascii , True)
self.assertEqual(pp.indent , 2)
@@ -167,7 +171,8 @@ class MetadataTest(BasePostprocessorTest):
self.assertEqual(self._output(m), """{
"category": "test",
"extension": "ext",
- "filename": "file"
+ "filename": "file",
+ "public": "hello"
}
""")
@@ -224,13 +229,41 @@ class MetadataTest(BasePostprocessorTest):
)
self.assertEqual(pp.write, pp._write_custom)
self.assertEqual(pp.extension, "txt")
- self.assertTrue(pp.formatter)
+ self.assertTrue(pp.contentfmt)
with patch("builtins.open", mock_open()) as m:
pp.prepare(self.pathfmt)
pp.run(self.pathfmt)
self.assertEqual(self._output(m), "bar\nNone\n")
+ def test_metadata_extfmt(self):
+ pp = self._create({
+ "extension" : "ignored",
+ "extension-format": "json",
+ })
+
+ self.assertEqual(pp.path, pp._path_format)
+
+ with patch("builtins.open", mock_open()) as m:
+ pp.prepare(self.pathfmt)
+ pp.run(self.pathfmt)
+
+ path = self.pathfmt.realdirectory + "file.json"
+ m.assert_called_once_with(path, "w", encoding="utf-8")
+
+ def test_metadata_extfmt_2(self):
+ pp = self._create({
+ "extension-format": "{extension!u}-data:{category:Res/ES/}",
+ })
+
+ self.pathfmt.prefix = "2."
+ with patch("builtins.open", mock_open()) as m:
+ pp.prepare(self.pathfmt)
+ pp.run(self.pathfmt)
+
+ path = self.pathfmt.realdirectory + "file.2.EXT-data:tESt"
+ m.assert_called_once_with(path, "w", encoding="utf-8")
+
@staticmethod
def _output(mock):
return "".join(