Esempio n. 1
0
def test_graphql_view_at_path_prefix():
    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')])
    with create_app_from_workspace(workspace, DagsterInstance.ephemeral(),
                                   '/dagster-path').test_client() as client:
        res = client.get('/dagster-path/graphql')
        assert b'Must provide query string' in res.data
Esempio n. 2
0
def test_create_app_with_multiple_workspace_files():
    with load_workspace_from_yaml_paths([
            file_relative_path(__file__, "./workspace.yaml"),
            file_relative_path(__file__, "./override.yaml"),
    ], ) as workspace:
        assert create_app_from_workspace(workspace,
                                         DagsterInstance.ephemeral())
Esempio n. 3
0
def test_create_app_with_workspace(python_user_process_api):
    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")],
            python_user_process_api,
    ) as workspace:
        assert create_app_from_workspace(workspace,
                                         DagsterInstance.ephemeral())
Esempio n. 4
0
def test_graphql_view_at_path_prefix():
    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")]) as workspace:
        with create_app_from_workspace(
                workspace, DagsterInstance.ephemeral(),
                "/dagster-path").test_client() as client:
            res = client.get("/dagster-path/graphql")
            assert b"Must provide query string" in res.data
Esempio n. 5
0
def test_create_app_with_multiple_workspace_files(python_user_process_api):
    workspace = load_workspace_from_yaml_paths(
        [
            file_relative_path(__file__, './workspace.yaml'),
            file_relative_path(__file__, './override.yaml'),
        ],
        python_user_process_api,
    )
    assert create_app_from_workspace(workspace, DagsterInstance.ephemeral())
Esempio n. 6
0
def test_graphql_view():
    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')], UserProcessApi.CLI)
    with create_app_from_workspace(
            workspace,
            DagsterInstance.ephemeral(),
    ).test_client() as client:
        res = client.get('/graphql')
    assert b'Must provide query string' in res.data
Esempio n. 7
0
def test_smoke_app():
    flask_app = app.create_app_from_workspace(
        get_workspace_from_kwargs(
            dict(
                module_name='dagster_examples.intro_tutorial.repos',
                definition='hello_cereal_repository',
            )),
        DagsterInstance.ephemeral(),
    )
    client = flask_app.test_client()

    result = client.post(
        '/graphql',
        data={'query': SMOKE_TEST_QUERY},
    )
    data = json.loads(result.data.decode('utf-8'))
    assert len(data['data']['repositoryLocationsOrError']['nodes']) == 1
    assert len(data['data']['repositoryLocationsOrError']['nodes'][0]
               ['repositories']) == 1
    assert (len(data['data']['repositoryLocationsOrError']['nodes'][0]
                ['repositories'][0]['pipelines']) == 2)
    assert {
        node_data['name']
        for node_data in data['data']['repositoryLocationsOrError']['nodes'][0]
        ['repositories'][0]['pipelines']
    } == set(['hello_cereal_pipeline', 'complex_pipeline'])

    result = client.get('/graphql')
    assert result.status_code == 400
    data = json.loads(result.data.decode('utf-8'))
    assert len(data['errors']) == 1
    assert data['errors'][0]['message'] == 'Must provide query string.'

    result = client.get('/dagit/notebook?path=foo.bar')
    assert result.status_code == 400
    assert result.data.decode('utf-8') == 'Invalid Path'

    result = client.post('/graphql',
                         data={'query': 'query { version { slkjd } }'})
    data = json.loads(result.data.decode('utf-8'))
    assert 'errors' in data
    assert len(data['errors']) == 1
    assert 'must not have a sub selection' in data['errors'][0]['message']

    # Missing routes return the index.html file of the Dagit react app, so the user
    # gets our UI when they navigate to "synthetic" react router URLs.
    result = client.get('static/foo/bar')
    assert result.status_code == 200
    assert "You need to enable JavaScript to run this app." in result.data.decode(
        'utf-8')

    result = client.get('pipelines/foo')
    assert result.status_code == 200
    assert "You need to enable JavaScript to run this app." in result.data.decode(
        'utf-8')
Esempio n. 8
0
def test_index_view():
    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')], UserProcessApi.CLI)
    with create_app_from_workspace(
            workspace,
            DagsterInstance.ephemeral(),
    ).test_client() as client:
        res = client.get('/')

    assert res.status_code == 200, res.data
    assert b'You need to enable JavaScript to run this app' in res.data
Esempio n. 9
0
def test_index_view():
    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")]) as workspace:
        with create_app_from_workspace(
                workspace,
                DagsterInstance.ephemeral(),
        ).test_client() as client:
            res = client.get("/")

        assert res.status_code == 200, res.data
        assert b"You need to enable JavaScript to run this app" in res.data
Esempio n. 10
0
def test_smoke_app(gen_instance):
    with get_workspace_from_kwargs(
            dict(module_name="dagit_tests.toy.bar_repo",
                 definition="bar")) as workspace:

        with gen_instance() as instance:
            flask_app = app.create_app_from_workspace(workspace, instance)
            client = flask_app.test_client()

            result = client.post(
                "/graphql",
                data={"query": SMOKE_TEST_QUERY},
            )
            data = json.loads(result.data.decode("utf-8"))
            assert len(data["data"]["repositoriesOrError"]["nodes"]) == 1
            assert len(data["data"]["repositoriesOrError"]["nodes"][0]
                       ["pipelines"]) == 2
            assert {
                node_data["name"]
                for node_data in data["data"]["repositoriesOrError"]["nodes"]
                [0]["pipelines"]
            } == set(["foo", "baz"])

            result = client.get("/graphql")
            assert result.status_code == 400
            data = json.loads(result.data.decode("utf-8"))
            assert len(data["errors"]) == 1
            assert data["errors"][0]["message"] == "Must provide query string."

            result = client.get("/dagit/notebook?path=foo.bar")
            assert result.status_code == 400
            assert result.data.decode("utf-8") == "Invalid Path"

            result = client.post("/graphql",
                                 data={"query": "query { version { slkjd } }"})
            data = json.loads(result.data.decode("utf-8"))
            assert "errors" in data
            assert len(data["errors"]) == 1
            assert "must not have a sub selection" in data["errors"][0][
                "message"]

            # Missing routes return the index.html file of the Dagit react app, so the user
            # gets our UI when they navigate to "synthetic" react router URLs.
            result = client.get("static/foo/bar")
            assert result.status_code == 200
            assert "You need to enable JavaScript to run this app." in result.data.decode(
                "utf-8")

            result = client.get("pipelines/foo")
            assert result.status_code == 200
            assert "You need to enable JavaScript to run this app." in result.data.decode(
                "utf-8")
Esempio n. 11
0
def test_index_view_at_path_prefix():
    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')])
    with create_app_from_workspace(workspace, DagsterInstance.ephemeral(),
                                   '/dagster-path').test_client() as client:
        # / redirects to prefixed path
        res = client.get('/')
        assert res.status_code == 301

        # index contains the path meta tag
        res = client.get('/dagster-path')
        assert res.status_code == 200
        assert b'You need to enable JavaScript to run this app' in res.data
        assert b'<meta name="dagit-path-prefix" content="/dagster-path"' in res.data
Esempio n. 12
0
def test_notebook_view():
    notebook_path = file_relative_path(__file__, "render_uuid_notebook.ipynb")

    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")]) as workspace:
        with create_app_from_workspace(
                workspace,
                DagsterInstance.ephemeral(),
        ).test_client() as client:
            res = client.get("/dagit/notebook?path={}".format(notebook_path))

        assert res.status_code == 200
        # This magic guid is hardcoded in the notebook
        assert b"6cac0c38-2c97-49ca-887c-4ac43f141213" in res.data
Esempio n. 13
0
def test_notebook_view():
    notebook_path = file_relative_path(__file__, 'render_uuid_notebook.ipynb')

    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')], UserProcessApi.CLI)
    with create_app_from_workspace(
            workspace,
            DagsterInstance.ephemeral(),
    ).test_client() as client:
        res = client.get('/dagit/notebook?path={}'.format(notebook_path))

    assert res.status_code == 200
    # This magic guid is hardcoded in the notebook
    assert b'6cac0c38-2c97-49ca-887c-4ac43f141213' in res.data
Esempio n. 14
0
def test_index_view_at_path_prefix():
    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")]) as workspace:
        with create_app_from_workspace(
                workspace, DagsterInstance.ephemeral(),
                "/dagster-path").test_client() as client:
            # / redirects to prefixed path
            res = client.get("/")
            assert res.status_code == 301

            # index contains the path meta tag
            res = client.get("/dagster-path/")
            assert res.status_code == 200
            assert b"You need to enable JavaScript to run this app" in res.data
            assert b'{"pathPrefix": "/dagster-path"}' in res.data
Esempio n. 15
0
def test_create_app_with_workspace_and_scheduler():
    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')])
    with seven.TemporaryDirectory() as temp_dir:
        instance = DagsterInstance.local_temp(
            temp_dir,
            overrides={
                'scheduler': {
                    'module': 'dagster.utils.test',
                    'class': 'FilesystemTestScheduler',
                    'config': {
                        'base_dir': temp_dir
                    },
                }
            },
        )
        assert create_app_from_workspace(workspace, instance)
Esempio n. 16
0
def test_create_app_with_workspace_and_scheduler():
    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")]) as workspace:
        with tempfile.TemporaryDirectory() as temp_dir:
            with instance_for_test_tempdir(
                    temp_dir,
                    overrides={
                        "scheduler": {
                            "module": "dagster.utils.test",
                            "class": "FilesystemTestScheduler",
                            "config": {
                                "base_dir": temp_dir
                            },
                        }
                    },
            ) as instance:
                assert create_app_from_workspace(workspace, instance)
Esempio n. 17
0
def load_dagit_for_workspace_cli_args(n_pipelines=1, **kwargs):
    instance = DagsterInstance.ephemeral()
    workspace = get_workspace_from_kwargs(kwargs, instance)
    app = create_app_from_workspace(workspace, instance)

    client = app.test_client()

    res = client.get('/graphql?query={query_string}'.format(
        query_string=PIPELINES_OR_ERROR_QUERY))
    json_res = json.loads(res.data.decode('utf-8'))
    assert 'data' in json_res
    assert 'repositoriesOrError' in json_res['data']
    assert 'nodes' in json_res['data']['repositoriesOrError']
    assert len(json_res['data']['repositoriesOrError']['nodes'][0]
               ['pipelines']) == n_pipelines

    return res
Esempio n. 18
0
def load_dagit_for_workspace_cli_args(n_pipelines=1, **kwargs):
    instance = DagsterInstance.ephemeral()
    with get_workspace_from_kwargs(kwargs, instance) as workspace:
        app = create_app_from_workspace(workspace, instance)

        client = app.test_client()

        res = client.get("/graphql?query={query_string}".format(
            query_string=PIPELINES_OR_ERROR_QUERY))
        json_res = json.loads(res.data.decode("utf-8"))
        assert "data" in json_res
        assert "repositoriesOrError" in json_res["data"]
        assert "nodes" in json_res["data"]["repositoriesOrError"]
        assert len(json_res["data"]["repositoriesOrError"]["nodes"][0]
                   ["pipelines"]) == n_pipelines

    return res
Esempio n. 19
0
def test_create_app_with_workspace_and_scheduler(python_user_process_api):
    with load_workspace_from_yaml_paths(
        [file_relative_path(__file__, "./workspace.yaml")],
            python_user_process_api) as workspace:
        with seven.TemporaryDirectory() as temp_dir:
            instance = DagsterInstance.local_temp(
                temp_dir,
                overrides={
                    "scheduler": {
                        "module": "dagster.utils.test",
                        "class": "FilesystemTestScheduler",
                        "config": {
                            "base_dir": temp_dir
                        },
                    }
                },
            )
            assert create_app_from_workspace(workspace, instance)
Esempio n. 20
0
def test_create_app_with_workspace():
    workspace = load_workspace_from_yaml_paths(
        [file_relative_path(__file__, './workspace.yaml')])
    assert create_app_from_workspace(workspace, DagsterInstance.ephemeral())