How to use click - 10 common examples

To help you get started, we’ve selected a few click examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pallets / click / tests / test_bashcomplete.py View on Github external
    @click.option('--bsub-opt', type=click.Choice(['bsubopt1', 'bsubopt2']))
    @click.argument('bsub-arg1', required=False, type=click.Choice(['bsubarg1', 'bsubarg2']))
    @click.argument('bbsub-arg2', required=False, type=click.Choice(['bbsubarg1', 'bbsubarg2']))
    def bsub(bsub_opt):
        pass
github Syntaf / travis-sphinx / tests / test_commands.py View on Github external
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
github dagster-io / dagster / python_modules / dagster / dagster_tests / cli_tests / test_cli_commands.py View on Github external
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
github databricks / databricks-cli / tests / libraries / test_cli.py View on Github external
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
        }
github GreyNoise-Intelligence / pygreynoise / tests / cli / test_subcommand.py View on Github external
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)
github zalando-stups / senza / tests / test_cli.py View on Github external
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
github lumapps / dep-check / tests / test_dep-check.py View on Github external
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
github Paperspace / paperspace-python / tests / functional / test_experiments.py View on Github external
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
github jwodder / javaproperties / test / test_cmd_get.py View on Github external
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'