def test_repository_python_file(): python_file = script_relative_path('bar_repo.py') module = imp.load_source('bar_repo', python_file) handle = handle_for_pipeline_cli_args({ 'pipeline_name': 'foo', 'python_file': python_file, 'fn_name': 'define_bar_repo' }) assert handle.mode == _ExecutionTargetMode.PIPELINE assert handle.entrypoint == LoaderEntrypoint(module, 'bar_repo', 'define_bar_repo', handle) assert handle.data.pipeline_name == 'foo' assert handle.entrypoint.from_handle == handle with pytest.raises(UsageError): handle_for_pipeline_cli_args({ 'module_name': 'kdjfkd', 'pipeline_name': 'foo', 'python_file': script_relative_path('bar_repo.py'), 'fn_name': 'define_bar_repo', 'repository_yaml': None, }) with pytest.raises(UsageError): handle_for_pipeline_cli_args({ 'module_name': None, 'pipeline_name': 'foo', 'python_file': script_relative_path('bar_repo.py'), 'fn_name': 'define_bar_repo', 'repository_yaml': 'kjdfkdjf', })
def test_yaml_file(): module = importlib.import_module('dagster_examples.intro_tutorial.repos') handle = handle_for_pipeline_cli_args({ 'module_name': None, 'pipeline_name': 'foobar', 'python_file': None, 'fn_name': None, 'repository_yaml': script_relative_path('repository.yaml'), }) assert handle.mode == _ExecutionTargetMode.REPOSITORY assert handle.entrypoint == LoaderEntrypoint( module, 'dagster_examples.intro_tutorial.repos', 'define_repo') assert handle.data.pipeline_name == 'foobar' with pytest.raises(CliUsageError): assert handle_for_pipeline_cli_args({ 'module_name': 'kdjfdk', 'pipeline_name': 'foobar' }) with pytest.raises(CliUsageError): assert handle_for_pipeline_cli_args({ 'fn_name': 'kjdfkd', 'pipeline_name': 'foobar' }) with pytest.raises(CliUsageError): assert handle_for_pipeline_cli_args({ 'pipeline_name': 'foobar', 'python_file': 'kjdfkdj' })