aboutsummaryrefslogtreecommitdiff
path: root/tests/test_commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_commands.py')
-rw-r--r--tests/test_commands.py52
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()