def test_load_in_process_location_handle_hello_world_terse():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, 'terse_python_file_workspace.yaml'))
    assert isinstance(workspace, Workspace)
    assert len(workspace.repository_location_handles) == 1
    assert workspace.repository_location_handles[
        0].location_name == 'hello_world_repository'
def test_multi_location_workspace():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, 'multi_location.yaml'))
    assert isinstance(workspace, Workspace)
    assert len(workspace.repository_location_handles) == 2
    assert workspace.has_repository_location_handle('loaded_from_file')
    assert workspace.has_repository_location_handle('loaded_from_module')
Exemple #3
0
def test_successful_host_dagit_ui_from_legacy_repository():
    with mock.patch('gevent.pywsgi.WSGIServer'), seven.TemporaryDirectory(
    ) as temp_dir:
        workspace = load_workspace_from_yaml_path(
            file_relative_path(__file__, './workspace.yaml'))
        host_dagit_ui_with_workspace(storage_fallback=temp_dir,
                                     workspace=workspace,
                                     host=None,
                                     port=2343)
def test_load_legacy_repository_yaml():
    with mock.patch('warnings.warn') as warn_mock:
        workspace = load_workspace_from_yaml_path(
            file_relative_path(__file__, 'legacy_repository.yaml'))
        assert isinstance(workspace, Workspace)
        assert len(workspace.repository_location_handles) == 1

        warn_mock.assert_called_once_with(
            'You are using the legacy repository yaml format. Please update your file '
            'to abide by the new workspace file format.')
Exemple #5
0
def test_index_view():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, './workspace.yaml'))
    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
Exemple #6
0
def test_notebook_view():
    notebook_path = file_relative_path(__file__, 'render_uuid_notebook.ipynb')

    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, './workspace.yaml'))
    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
Exemple #7
0
def test_create_app_with_workspace_and_scheduler():
    workspace = load_workspace_from_yaml_path(
        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)
Exemple #8
0
def test_unknown_error():
    class AnException(Exception):
        pass

    def _raise_custom_error():
        raise AnException('foobar')

    with mock.patch(
            'gevent.pywsgi.WSGIServer',
            new=_define_mock_server(
                _raise_custom_error)), seven.TemporaryDirectory() as temp_dir:
        workspace = load_workspace_from_yaml_path(
            file_relative_path(__file__, './workspace.yaml'))
        with pytest.raises(AnException):
            host_dagit_ui_with_workspace(storage_fallback=temp_dir,
                                         workspace=workspace,
                                         host=None,
                                         port=2343)
Exemple #9
0
def test_port_collision():
    def _raise_os_error():
        raise OSError('Address already in use')

    with mock.patch(
            'gevent.pywsgi.WSGIServer', new=_define_mock_server(
                _raise_os_error)), seven.TemporaryDirectory() as temp_dir:
        workspace = load_workspace_from_yaml_path(
            file_relative_path(__file__, './workspace.yaml'))
        with pytest.raises(Exception) as exc_info:
            host_dagit_ui_with_workspace(
                storage_fallback=temp_dir,
                workspace=workspace,
                host=None,
                port=2343,
                port_lookup=False,
            )

        assert 'another instance of dagit ' in str(exc_info.value)
Exemple #10
0
def test_create_app_with_workspace():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, './workspace.yaml'))
    assert create_app_from_workspace(workspace, DagsterInstance.ephemeral())
Exemple #11
0
def test_load_in_process_location_handle_hello_world_nested_with_def():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, 'nested_with_def_python_module_workspace.yaml')
    )
    assert isinstance(workspace, Workspace)
    assert len(workspace.repository_location_handles) == 1
Exemple #12
0
def test_workspace():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, '../workspace.yaml'))
    assert len(workspace.repository_location_handles) == 2
def test_load_in_process_location_handle_hello_world_through_legacy_codepath():
    workspace = load_workspace_from_yaml_path(
        file_relative_path(__file__, 'terse_python_file_workspace.yaml'))
    assert isinstance(workspace, Workspace)
    assert len(workspace.repository_location_handles) == 1