def test_create_app_with_workspace(): with load_workspace_process_context_from_yaml_paths( DagsterInstance.ephemeral(), [file_relative_path(__file__, "./workspace.yaml")], ) as workspace_process_context: assert create_app_from_workspace_process_context( workspace_process_context)
def test_graphql_view_at_path_prefix(): with load_workspace_process_context_from_yaml_paths( DagsterInstance.ephemeral(), [file_relative_path(__file__, "./workspace.yaml")] ) as workspace_process_context: with create_app_from_workspace_process_context( workspace_process_context, "/dagster-path" ).test_client() as client: res = client.get("/dagster-path/graphql") assert b"Must provide query string" in res.data
def test_graphql_view(): with load_workspace_process_context_from_yaml_paths( DagsterInstance.ephemeral(), [file_relative_path(__file__, "./workspace.yaml") ]) as workspace_process_context: client = TestClient( create_app_from_workspace_process_context( workspace_process_context, )) res = client.get("/graphql") assert b"No GraphQL query found in the request" in res.content
def test_index_view(): with load_workspace_process_context_from_yaml_paths( DagsterInstance.ephemeral(), [file_relative_path(__file__, "./workspace.yaml")] ) as workspace_process_context: with create_app_from_workspace_process_context( workspace_process_context ).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
def test_smoke_app(gen_instance): with gen_instance() as instance: with get_workspace_process_context_from_kwargs( instance, version="", read_only=False, kwargs=dict(module_name="dagit_tests.toy.bar_repo", definition="bar"), ) as workspace_process_context: asgi_app = app.create_app_from_workspace_process_context( workspace_process_context) client = TestClient(asgi_app) result = client.post( "/graphql", json={"query": SMOKE_TEST_QUERY}, ) assert result.status_code == 200, result.content data = result.json() 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 assert result.content == b"No GraphQL query found in the request" result = client.get( "/dagit/notebook?path=foo.bar&repoLocName=foo_repo") assert result.status_code == 400 assert result.content.decode("utf-8") == "Invalid Path" result = client.post("/graphql", json={"query": "query { version { slkjd } }"}) data = result.json() assert "errors" in data assert len(data["errors"]) == 1 assert "must not have a sub selection" in data["errors"][0][ "message"] # Missing routes redirect to 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("foo/bar") assert result.status_code == 200, result.content result = client.get("pipelines/foo") assert result.status_code == 200, result.content
def test_notebook_view(): notebook_path = file_relative_path(__file__, "render_uuid_notebook.ipynb") with load_workspace_process_context_from_yaml_paths( DagsterInstance.ephemeral(), [file_relative_path(__file__, "./workspace.yaml")] ) as workspace_process_context: with create_app_from_workspace_process_context( workspace_process_context, ).test_client() as client: res = client.get(f"/dagit/notebook?path={notebook_path}&repoLocName=load_from_file") assert res.status_code == 200 # This magic guid is hardcoded in the notebook assert b"6cac0c38-2c97-49ca-887c-4ac43f141213" in res.data
def test_create_app_with_workspace_and_scheduler(): with tempfile.TemporaryDirectory() as temp_dir: with instance_for_test( temp_dir=temp_dir, overrides={ "scheduler": { "module": "dagster.utils.test", "class": "FilesystemTestScheduler", "config": {"base_dir": temp_dir}, } }, ) as instance: with load_workspace_process_context_from_yaml_paths( instance, [file_relative_path(__file__, "./workspace.yaml")] ) as workspace_process_context: assert create_app_from_workspace_process_context(workspace_process_context)
def test_index_view_at_path_prefix(): with load_workspace_process_context_from_yaml_paths( DagsterInstance.ephemeral(), [file_relative_path(__file__, "./workspace.yaml")] ) as workspace_process_context: with create_app_from_workspace_process_context( workspace_process_context, "/dagster-path" ).test_client() as client: # / redirects to prefixed path res = client.get("/") assert res.status_code == 200 # 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
def load_dagit_for_workspace_cli_args(n_pipelines=1, **kwargs): instance = DagsterInstance.ephemeral() with get_workspace_process_context_from_kwargs( instance, version="", read_only=False, kwargs=kwargs ) as workspace_process_context: client = TestClient(create_app_from_workspace_process_context(workspace_process_context)) res = client.get( "/graphql?query={query_string}".format(query_string=PIPELINES_OR_ERROR_QUERY) ) json_res = res.json() 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