Example #1
0
def test_generate_supervisor_conf_with_token_and_key():
    # Covers deprecated token based auth colliding with key based auth
    agent = LocalAgent()

    with pytest.raises(ValueError, match="Given both a API token and API key"):
        agent.generate_supervisor_conf(
            token="token",
            key="key",
            labels=["label"],
            import_paths=["path"],
            env_vars={"TESTKEY": "TESTVAL"},
        )
Example #2
0
def test_generate_supervisor_conf(cloud_api):
    agent = LocalAgent()

    conf = agent.generate_supervisor_conf(token="token",
                                          labels=["label"],
                                          import_paths=["path"])

    assert "-t token" in conf
    assert "-l label" in conf
    assert "-p path" in conf
Example #3
0
def install(label, env, import_paths, **kwargs):
    """Generate a supervisord.conf file for a Local agent"""
    from prefect.agent.local import LocalAgent

    conf = LocalAgent.generate_supervisor_conf(
        labels=sorted(set(label)),
        env_vars=dict(e.split("=", 1) for e in env),
        import_paths=list(import_paths),
        **kwargs,
    )
    click.echo(conf)
Example #4
0
def test_generate_supervisor_conf():
    agent = LocalAgent()

    conf = agent.generate_supervisor_conf(
        token="token",
        labels=["label"],
        import_paths=["path"],
        env_vars={"TESTKEY": "TESTVAL"},
    )

    assert "-t token" in conf
    assert "-l label" in conf
    assert "-p path" in conf
    assert "-e TESTKEY=TESTVAL" in conf
Example #5
0
def test_generate_supervisor_conf_with_token():
    # Covers deprecated token based auth
    agent = LocalAgent()

    conf = agent.generate_supervisor_conf(
        token="token",
        labels=["label"],
        import_paths=["path"],
        env_vars={"TESTKEY": "TESTVAL"},
    )

    assert "-t token" in conf
    assert "-l label" in conf
    assert "-p path" in conf
    assert "-e TESTKEY=TESTVAL" in conf
Example #6
0
def test_generate_supervisor_conf_with_key():
    agent = LocalAgent()

    conf = agent.generate_supervisor_conf(
        key="key",
        tenant_id="tenant",
        labels=["label"],
        import_paths=["path"],
        env_vars={"TESTKEY": "TESTVAL"},
    )

    assert "-k key" in conf
    assert "--tenant-id tenant" in conf
    assert "-l label" in conf
    assert "-p path" in conf
    assert "-e TESTKEY=TESTVAL" in conf