Expand general CLI tests.
@@ -37,7 +37,7 @@ class TestCliEagerFlags(TestCase):
assert result.exit_code == 0, result.stderr
-class TestCliDeployRuns(PatchSSHTestCase):
+class TestDeployCli(PatchSSHTestCase):
def setUp(self):
pseudo_state.reset()
@@ -49,22 +49,31 @@ class TestCliDeployRuns(PatchSSHTestCase):
assert result.exit_code == 1, result.stderr
assert 'No deploy file: not-a-file.py' in result.stderr
- def test_deploy_inventory(self):
+
+class TestOperationCli(PatchSSHTestCase):
+ def test_invalid_operation_module(self):
result = run_cli(
path.join('tests', 'deploy', 'inventories', 'inventory.py'),
- 'server.shell',
- '--debug-data',
+ 'not_a_module.shell',
)
- assert result.exit_code == 0, result.stderr
+ assert result.exit_code == 1, result.stderr
+ assert 'No such module: not_a_module'
- def test_get_facts(self):
+ def test_invalid_operation_function(self):
result = run_cli(
path.join('tests', 'deploy', 'inventories', 'inventory.py'),
- 'fact',
- 'os',
+ 'server.not_an_operation',
+ )
+ assert result.exit_code == 1, result.stderr
+ assert 'No such operation: server.not_an_operation'
+
+ def test_deploy_inventory(self):
+ result = run_cli(
+ path.join('tests', 'deploy', 'inventories', 'inventory.py'),
+ 'server.shell',
+ '--debug-data',
)
assert result.exit_code == 0, result.stderr
- assert '"somehost": null' in result.stderr
def test_deploy_operation(self):
result = run_cli(
@@ -82,6 +91,15 @@ class TestCliDeployRuns(PatchSSHTestCase):
)
assert result.exit_code == 0, result.stderr
+ def test_deploy_operation_json_args(self):
+ result = run_cli(
+ path.join('tests', 'deploy', 'inventory_all.py'),
+ 'server.shell',
+ '[["echo hi"], {}]',
+ )
+ assert result.exit_code == 0, result.stderr
+
+
class TestFactCli(PatchSSHTestCase):
def test_get_fact(self):
result = run_cli(
@@ -130,6 +148,7 @@ class TestFactCli(PatchSSHTestCase):
assert '"somehost": null' in result.stderr
+class TestExecCli(PatchSSHTestCase):
def test_exec_command(self):
result = run_cli(
path.join('tests', 'deploy', 'inventories', 'inventory.py'),
