Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_deploy_cname(builded_doc, travis_env):
runner = CliRunner()
result = runner.invoke(
main, ['-o', builded_doc, 'deploy', '-c', 'test.org'], env=travis_env)
assert result.exit_code == 0, result.output
assert result.output == 'ghp-import -p -f -n -r ' \
'https://token@github.com/org/travis-sphinx.git ' \
'-c test.org '\
'-m Update\ documentation %s\n' % builded_doc
def test_execute_mode_command():
runner = CliRunner()
add_result = runner_pipeline_execute(
runner,
[
'-y',
script_relative_path('../repository.yaml'),
'--env',
script_relative_path('../environments/multi_mode_with_resources/add_mode.yaml'),
'-d',
'add_mode',
'multi_mode_with_resources', # pipeline name
],
)
assert add_result
def test_uninstall_cli_pypi(libraries_api_mock):
test_pypi_package = 'databricks-cli'
test_pypi_repo = 'https://pypi.databricks.com'
# Coordinates
runner = CliRunner()
runner.invoke(cli.uninstall_cli, [
'--cluster-id', TEST_CLUSTER_ID,
'--pypi-package', test_pypi_package,
'--pypi-repo', test_pypi_repo])
libraries_api_mock.uninstall_libraries.assert_called_with(TEST_CLUSTER_ID, [{
'pypi': {
'package': test_pypi_package,
'repo': test_pypi_repo
}
def test_query(self, api_client):
"""Run query."""
runner = CliRunner()
query = ""
api_client.query.return_value = []
expected = json.dumps([[]], indent=4, sort_keys=True)
result = runner.invoke(subcommand.query, ["-f", "json", query])
assert result.exit_code == 0
assert result.output.strip("\n") == expected
api_client.query.assert_called_with(query=query)
monkeypatch.setattr('boto3.client', MagicMock())
monkeypatch.setattr('boto3.resource', my_resource)
data = {'SenzaInfo': {'StackName': 'test',
'Parameters': [{'ApplicationId': {'Description': 'Application ID from kio'}}]},
'SenzaComponents': [{'Configuration': {'ServerSubnets': {'myregion': ['subnet-123']},
'Type': 'Senza::Configuration'}},
{'AppServer': {'Image': 'AppImage',
'InstanceType': 't2.micro',
'SecurityGroups': ['app-{{Arguments.ApplicationId}}'],
'IamRoles': ['app-{{Arguments.ApplicationId}}'],
'TaupageConfig': {'runtime': 'Docker',
'source': 'foo/bar'},
'Type': 'Senza::TaupageAutoScalingGroup'}}]
}
runner = CliRunner()
with runner.isolated_filesystem():
with open('myapp.yaml', 'w') as fd:
yaml.dump(data, fd)
result = runner.invoke(cli, ['print', 'myapp.yaml', '--region=aa-fakeregion-1', '123', 'master-mind'],
catch_exceptions=False)
assert 'AWSTemplateFormatVersion' in result.output
assert 'subnet-123' in result.output
assert 'app-master-mind' in result.output
assert 'sg-007' in result.output
def test_command_line_interface():
"""Test the CLI."""
runner = CliRunner()
result = runner.invoke(cli.main)
assert result.exit_code == 0
assert 'dep_check.cli.main' in result.output
help_result = runner.invoke(cli.main, ['--help'])
assert help_result.exit_code == 0
assert '--help Show this message and exit.' in help_result.output
def test_should_send_proper_data_and_print_message_when_create_wrong_project_id_was_given(self, post_patched):
post_patched.return_value = MockResponse(self.RESPONSE_JSON_404_PROJECT_NOT_FOUND, 404,
self.RESPONSE_CONTENT_404_PROJECT_NOT_FOUND)
runner = CliRunner()
result = runner.invoke(cli.cli, self.BASIC_OPTIONS_COMMAND)
post_patched.assert_called_once_with(self.URL,
headers=self.EXPECTED_HEADERS,
json=self.BASIC_OPTIONS_REQUEST,
params=None,
files=None,
data=None)
assert result.output == self.EXPECTED_STDOUT_PROJECT_NOT_FOUND
assert result.exit_code == 0
def test_cmd_get_astral_output():
r = CliRunner().invoke(javaproperties, ['get', '-', 'astral'], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'\xF0\x9F\x90\x90\n'
def test_cli_validate_with_valid_check_relations():
"""Tests that validate --check-relations follows foreign keys."""
result = CliRunner().invoke(
cli.cli,
[
"validate",
"tests/data/valid-relations/datapackage.json",
"--check-relations",
],
)
assert result.exit_code == 0
assert '"valid": true' in result.output