diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-12-23 21:09:47 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-12-23 21:09:47 +0100 |
commit | 94c578817edd68d5baa956c568770eafe46e6f73 (patch) | |
tree | e633186ebf5ad964f49fb10521c3e4b199322ee4 /tests | |
parent | 83a56d5eb68da0d57645bdc287c92c1bad5ab664 (diff) |
Fix printing values of list fields
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_commands.py | 52 |
1 files changed, 40 insertions, 12 deletions
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() |