当前位置: 首页>>代码示例>>Python>>正文


Python testing.CliRunner方法代码示例

本文整理汇总了Python中click.testing.CliRunner方法的典型用法代码示例。如果您正苦于以下问题:Python testing.CliRunner方法的具体用法?Python testing.CliRunner怎么用?Python testing.CliRunner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在click.testing的用法示例。


在下文中一共展示了testing.CliRunner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_simple_cloud_commands

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_simple_cloud_commands(ControllerClient, format_result):
    commands = [
        ["claim-node", "token"],
        ["create-node", "test"],
        ["delete-node", "test"],
        ["describe-node", "test"],
        ["group-add-node", "group", "node"],
        ["help"],
        ["list-groups"],
        ["list-nodes"],
        ["login"],
        ["logout"],
        ["rename-node", "node", "node"]
    ]

    format_result.return_value = "result"

    runner = CliRunner()
    for command in commands:
        result = runner.invoke(cloud.root, command, obj={})
        print("Command {} exit code {}".format(command[0], result.exit_code))
        assert result.exit_code == 0 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:24,代码来源:test_cloud.py

示例2: test_csv

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_csv():
    expected = '\n'.join([
        'source_context, test_context',
        'smother/tests/demo.py:11,test2',
        'smother/tests/demo.py:4,test4',
        '',
    ])

    runner = CliRunner()

    with NamedTemporaryFile(mode='w+') as tf:
        result = runner.invoke(
            cli,
            ['-r', 'smother/tests/.smother_2',
             'csv',
             tf.name
             ]
        )
        assert result.exit_code == 0
        tf.seek(0)
        assert tf.read() == expected 
开发者ID:ChrisBeaumont,项目名称:smother,代码行数:23,代码来源:test_cli.py

示例3: test_semantic_csv

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_semantic_csv():
    expected = '\n'.join([
        'source_context, test_context',
        'smother.tests.demo,test4',
        'smother.tests.demo:bar,test2',
        '',
    ])

    runner = CliRunner()

    with NamedTemporaryFile(mode='w+') as tf:
        result = runner.invoke(
            cli,
            ['-r', 'smother/tests/.smother_2',
             '--semantic',
             'csv',
             tf.name
             ]
        )
        assert result.exit_code == 0
        tf.seek(0)
        assert tf.read() == expected 
开发者ID:ChrisBeaumont,项目名称:smother,代码行数:24,代码来源:test_cli.py

示例4: test_input_file_invalid_ip_addresses_passsed

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_input_file_invalid_ip_addresses_passsed(self, api_client):
        """Error returned if only invalid IP addresses are passed in input file."""
        runner = CliRunner()

        expected = (
            "Error: at least one valid IP address must be passed either as an "
            "argument (IP_ADDRESS) or through the -i/--input_file option."
        )

        result = runner.invoke(
            subcommand.interesting,
            ["-i", StringIO("not-an-ip")],
            parent=Context(main, info_name="greynoise"),
        )
        assert result.exit_code == -1
        assert "Usage: greynoise interesting" in result.output
        assert expected in result.output
        api_client.interesting.assert_not_called() 
开发者ID:GreyNoise-Intelligence,项目名称:pygreynoise,代码行数:20,代码来源:test_subcommand.py

示例5: test_empty_input_file

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_empty_input_file(self, api_client):
        """Error is returned if empty input fle is passed."""
        runner = CliRunner()

        expected = (
            "Error: at least one query must be passed either as an argument "
            "(QUERY) or through the -i/--input_file option."
        )

        result = runner.invoke(
            subcommand.query,
            ["-i", StringIO()],
            parent=Context(main, info_name="greynoise"),
        )
        assert result.exit_code == -1
        assert "Usage: greynoise query" in result.output
        assert expected in result.output
        api_client.query.assert_not_called() 
开发者ID:GreyNoise-Intelligence,项目名称:pygreynoise,代码行数:20,代码来源:test_subcommand.py

示例6: test_startserver

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_startserver(self):
        runner = CliRunner()
        # Starting server with valid parameters
        result = runner.invoke(startserver,
                               ["--adduser", "--api", "--no-auth", "--dburl",
                                "--hydradoc", "--port", "--no-token", "--serverurl",
                                "serve"])
        result.exit_code != 0

        # Starting server with invalid parameters

        result = runner.invoke(startserver,
                               ["--adduser", "sqlite://not-valid", "http://localhost",
                                "--port", "serve"])
        assert result.exit_code == 2 
开发者ID:HTTP-APIs,项目名称:hydrus,代码行数:17,代码来源:test_cli.py

示例7: test_taskcli_builddata_command

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_taskcli_builddata_command(mocker):
    """Test the CLI task get build data command."""
    task_id = "aaaa-bbbb-cccc-dddd"
    build_data = [{
        "node_name": "foo",
        "task_id": task_id,
        "collected_data": "1/1/2000",
        "generator": "test",
        "data_format": "text/plain",
        "data_element": "Hello World!",
    }]

    api_client = mocker.MagicMock()
    api_client.get_task_build_data.return_value = build_data

    mocker.patch(
        'drydock_provisioner.cli.commands.DrydockClient', new=api_client)
    mocker.patch('drydock_provisioner.cli.commands.KeystoneClient')

    runner = CliRunner()
    result = runner.invoke(
        cli.drydock, ['-u', 'http://foo', 'task', 'builddata', '-t', task_id])

    print(result.exc_info)
    api_client.get_task_build_data.assert_called_with(task_id)

    assert yaml.safe_dump(
        build_data, allow_unicode=True,
        default_flow_style=False) in result.output 
开发者ID:airshipit,项目名称:drydock,代码行数:31,代码来源:test_cli_task.py

示例8: test

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test():
    result = CliRunner().invoke(main, "foo")
    assert result.exit_code == 0 
开发者ID:bcb,项目名称:jsonrpcclient,代码行数:5,代码来源:test_main.py

示例9: test_notify

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_notify():
    result = CliRunner().invoke(main, ["foo", "--notify"])
    assert result.exit_code == 0 
开发者ID:bcb,项目名称:jsonrpcclient,代码行数:5,代码来源:test_main.py

示例10: test_send

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_send(*_):
    result = CliRunner().invoke(main, ["foo", "--send=http://foo"])
    assert result.exit_code == 0 
开发者ID:bcb,项目名称:jsonrpcclient,代码行数:5,代码来源:test_main.py

示例11: test_send_error

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_send_error(*_):
    result = CliRunner().invoke(main, ["foo", "--send=http://foo"])
    assert result.exit_code == get_click_exception_return_code() 
开发者ID:bcb,项目名称:jsonrpcclient,代码行数:5,代码来源:test_main.py

示例12: test_cli_version

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_cli_version():
    runner = CliRunner()
    result = runner.invoke(cli, ['--version'])
    assert result.exit_code == 0
    assert len(result.output.split('.')) == 3 
开发者ID:frictionlessdata,项目名称:goodtables-py,代码行数:7,代码来源:test_cli.py

示例13: test_cli_infer_schema_enables_infer_fields

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_cli_infer_schema_enables_infer_fields(validate_mock):
    CliRunner().invoke(cli, ['--infer-schema', 'data.csv'])

    last_call_args = validate_mock.call_args
    assert last_call_args is not None
    assert last_call_args[-1].get('infer_schema')
    assert last_call_args[-1].get('infer_fields') 
开发者ID:frictionlessdata,项目名称:goodtables-py,代码行数:9,代码来源:test_cli.py

示例14: test_cli_accepts_multiple_sources

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_cli_accepts_multiple_sources(validate_mock):
    sources = ['data1.csv', 'data2.csv']
    expected_sources = [{'source': source} for source in sources]

    CliRunner().invoke(cli, sources)

    last_call_args = validate_mock.call_args
    assert last_call_args is not None
    assert last_call_args[0][0] == expected_sources 
开发者ID:frictionlessdata,项目名称:goodtables-py,代码行数:11,代码来源:test_cli.py

示例15: test_cli_init

# 需要导入模块: from click import testing [as 别名]
# 或者: from click.testing import CliRunner [as 别名]
def test_cli_init():
    resource_path = 'data/valid.csv'

    result = CliRunner().invoke(init, [resource_path])

    assert result.exit_code == 0

    dp = datapackage.Package(json.loads(result.output), strict=True)
    resource = dp.resources[0]
    assert resource.descriptor['path'] == resource_path
    assert 'schema' in resource.descriptor 
开发者ID:frictionlessdata,项目名称:goodtables-py,代码行数:13,代码来源:test_cli.py


注:本文中的click.testing.CliRunner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。