def test_index_view(): with create_app_with_execution_handle( ExecutionTargetHandle.for_repo_yaml( file_relative_path(__file__, './repository.yaml')), 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
def test_notebook_view(): notebook_path = file_relative_path(__file__, 'render_uuid_notebook.ipynb') with create_app_with_execution_handle( ExecutionTargetHandle.for_repo_yaml( file_relative_path(__file__, './repository.yaml')), 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
def load_dagit_for_repo_cli_args(n_pipelines=1, **kwargs): handle = handle_for_repo_cli_args(kwargs) app = create_app_with_execution_handle(handle, DagsterInstance.ephemeral()) 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 'pipelinesOrError' in json_res['data'] assert 'nodes' in json_res['data']['pipelinesOrError'] assert len(json_res['data']['pipelinesOrError']['nodes']) == n_pipelines return res
def test_smoke_app(): flask_app = app.create_app_with_execution_handle( ExecutionTargetHandle.for_repo_module( module_name='dagster_examples.intro_tutorial.repos', fn_name='define_repo'), DagsterInstance.ephemeral(), ) client = flask_app.test_client() result = client.post( '/graphql', data={'query': 'query { pipelines { nodes { name }}}'}) data = json.loads(result.data.decode('utf-8')) assert len(data['data']['pipelines']['nodes']) == 2 assert { node_data['name'] for node_data in data['data']['pipelines']['nodes'] } == 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')
def test_create_app_with_execution_handle(): handle = ExecutionTargetHandle.for_repo_yaml( file_relative_path(__file__, './repository.yaml')) assert create_app_with_execution_handle(handle, DagsterInstance.ephemeral())