예제 #1
0
def test_if_port_env_var_is_set_then_specified_host_is_used(api: API):
    with env("PORT", "4242"):

        def run(app, host, **kwargs):
            assert host == "example.com"

        api.run(_run=run, host="example.com")
def test_at_least_one_group_is_expected(runner, tmpdir):
    boca_dot_py = tmpdir.join("boca.py")
    boca_dot_py.write("import click")

    with env("BOCA_CUSTOM_COMMANDS_FILE", str(boca_dot_py)):
        with pytest.raises(ValueError):
            create_cli()
예제 #3
0
def test_can_provide_custom_commands(runner, tmpdir):
    boca_dot_py = tmpdir.join("boca.py")

    boca_dot_py.write(
        cleandoc(
            """
    import click

    @click.group()
    def cli():
        pass

    @cli.command()
    def hello():
        click.echo("Hello!")
    """
        )
    )

    with env("BOCA_CUSTOM_COMMANDS_FILE", str(boca_dot_py)):
        cli = create_cli()

    result = runner.invoke(cli, ["hello"])

    assert result.exit_code == 0
    assert result.output == "Hello!\n"
예제 #4
0
def test_if_port_env_var_is_set_then_host_is_any_and_port_is_env_var(api: API):
    with env("PORT", "4242"):

        def run(app, host, port, **kwargs):
            assert host == "0.0.0.0"
            assert port == 4242
            assert app == api

        api.run(_run=run)
def test_shell_around_a_simple_functions(mock_starfish):
    with env(STARFISH_API_URL=mock_starfish.url,
             STARFISH_SERVICE_ID='test_1',
             STARFISH_RUN_ID='run_1'):
        starfish = ShellFactory.from_env()
        shelled = starfish.shell_process(
            noop_processing,
            source='some-source-identifier',
            destination='some-destination-identifier')

        # that would be the moment where you store profiles somewhere else.
        list(shelled(gen_profiles(10)))

        # The content has been consumed
        assert shelled.starfish.consumed == 20

        # The server has been requested
        logs = mock_starfish.logs
        assert len(logs) == 20
        assert 'some-source-identifier' in logs.sources
        assert 'some-destination-identifier' in logs.destinations

        for log in logs:
            assert check_server_log(log)
def test_build_factory_config_from_env():
    with env(STARFISH_API_URL='a',
             STARFISH_SERVICE_ID='b',
             STARFISH_RUN_ID='c'):
        config = ShellFactory.from_env().config
        assert config == Config(api_url='a', service_id='b', run_id='c')