def test_smoke_app(): repository_container = RepositoryContainer(repository=define_repo()) pipeline_run_storage = PipelineRunStorage() flask_app = app.create_app(repository_container, pipeline_run_storage) 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']) == 1 assert {node_data['name'] for node_data in data['data']['pipelines']['nodes']} == set( ['repo_demo_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'] result = client.get('static/foo/bar') assert result.status_code == 404
def test_create_app(): handle = ExecutionTargetHandle.for_repo_yaml( script_relative_path('./repository.yaml')) pipeline_run_storage = InMemoryRunStorage() assert create_app(handle, pipeline_run_storage, use_synchronous_execution_manager=True)
def test_index_view(): with create_app( ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml')), PipelineRunStorage(), ).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_index_view(): with create_app( 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 = script_relative_path('render_uuid_notebook.ipynb') with create_app( ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml')), PipelineRunStorage(), ).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 test_notebook_view(): notebook_path = file_relative_path(__file__, 'render_uuid_notebook.ipynb') with create_app( 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 test_smoke_app(): repository_container = app.RepositoryContainer(repository=define_repo()) pipeline_run_storage = PipelineRunStorage() flask_app = app.create_app(repository_container, pipeline_run_storage) 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']) == 1 assert set([node_data['name'] for node_data in data['data']['pipelines']['nodes']]) == set( ['repo_demo_pipeline'] )
def load_dagit_for_repo_cli_args(n_pipelines=1, **kwargs): handle = handle_for_repo_cli_args(kwargs) app = create_app(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( 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_smoke_app(): repository_container = app.RepositoryContainer( DynamicObject( object=define_example_repository(), module=None, fn_name=None, fn=None, module_name=None, )) flask_app = app.create_app(repository_container) client = flask_app.test_client() result = client.post('/graphql', data={'query': 'query { pipelines { name }}'}) data = json.loads(result.data.decode('utf-8')) assert data == {"data": {"pipelines": [{"name": "pandas_hello_world"}]}}
def test_smoke_app(): pipeline_run_storage = PipelineRunStorage() flask_app = app.create_app( ExecutionTargetHandle.for_repo_module( module_name='dagster_examples.intro_tutorial.repos', fn_name='define_repo'), pipeline_run_storage, ) 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']) == 1 assert { node_data['name'] for node_data in data['data']['pipelines']['nodes'] } == set(['repo_demo_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'] result = client.get('static/foo/bar') assert result.status_code == 404 result = client.get('vendor/foo/bar') assert result.status_code == 404
def test_create_app(): handle = ExecutionTargetHandle.for_repo_yaml( script_relative_path('./repository.yaml')) assert create_app(handle, DagsterInstance.ephemeral())