示例#1
0
def test_get_cloud_url_different_regex(patch_post, cloud_api):
    response = {
        "data": {
            "user": [{
                "default_membership": {
                    "tenant": {
                        "slug": "tslug"
                    }
                }
            }]
        }
    }

    patch_post(response)

    with set_temporary_config({
            "cloud.api": "http://api-hello.prefect.io",
            "cloud.auth_token": "secret_token",
            "backend": "cloud",
    }):
        client = Client()

        url = client.get_cloud_url(subdirectory="flow", id="id")
        assert url == "http://hello.prefect.io/tslug/flow/id"

        url = client.get_cloud_url(subdirectory="flow-run", id="id2")
        assert url == "http://hello.prefect.io/tslug/flow-run/id2"
示例#2
0
def test_get_cloud_url_not_as_user(patch_post, cloud_api):
    response = {"data": {"tenant": [{"slug": "tslug"}]}}

    patch_post(response)

    with set_temporary_config({
            "cloud.api": "http://api.prefect.io",
            "cloud.auth_token": "secret_token"
    }):
        client = Client()

        url = client.get_cloud_url(subdirectory="flow", id="id", as_user=False)
        assert url == "http://cloud.prefect.io/tslug/flow/id"

        url = client.get_cloud_url(subdirectory="flow-run",
                                   id="id2",
                                   as_user=False)
        assert url == "http://cloud.prefect.io/tslug/flow-run/id2"