From 94c578817edd68d5baa956c568770eafe46e6f73 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 23 Dec 2021 21:09:47 +0100 Subject: Fix printing values of list fields --- tests/test_commands.py | 52 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'tests/test_commands.py') diff --git a/tests/test_commands.py b/tests/test_commands.py index 99cc649..bd7098c 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -22,18 +22,7 @@ class Args: raise AttributeError(e) -class testCommands(unittest.TestCase): - def setUp(self): - self.tmpdir = tempfile.TemporaryDirectory() - utils.copytree( - 'tests/data/simple', - self.tmpdir.name, - dirs_exist_ok=True, - ) - - def tearDown(self): - pass - +class CommandsMixin: def _edit_file(self, filepath): return True @@ -49,6 +38,19 @@ class testCommands(unittest.TestCase): cmd.main() return stream + +class testCommandsSimple(unittest.TestCase, CommandsMixin): + def setUp(self): + self.tmpdir = tempfile.TemporaryDirectory() + utils.copytree( + 'tests/data/simple', + self.tmpdir.name, + dirs_exist_ok=True, + ) + + def tearDown(self): + pass + def test_init(self): args = { 'collection': self.tmpdir.name, @@ -180,5 +182,31 @@ class testCommands(unittest.TestCase): self.assertEqual(streams['stderr'].getvalue(), '') +class testCommandsComplex(unittest.TestCase, CommandsMixin): + def setUp(self): + self.tmpdir = tempfile.TemporaryDirectory() + utils.copytree( + 'tests/data/complex', + self.tmpdir.name, + dirs_exist_ok=True, + ) + + def tearDown(self): + pass + + def test_get_values_from_list(self): + args = { + 'collection': self.tmpdir.name, + 'git': True, + 'template': False, + 'query': '*', + 'field': 'tags', + } + streams = self._run_command(command.GetValues(), args) + print(streams['stdout'].getvalue()) + self.assertIn('this: 1', streams['stdout'].getvalue()) + self.assertEqual(streams['stderr'].getvalue(), '') + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3