Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sultaniman committed Mar 25, 2024
1 parent aaeea00 commit 278477d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dlt/common/cli/runner/inquirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def maybe_ask(self) -> t.Tuple[dlt.Pipeline, t.Union[DltResource, DltSource]]:

real_pipeline_name = ""
if pipeline.pipeline_name != pipeline_name:
real_pipeline_name = f"({pipeline.pipeline_name})"
real_pipeline_name = f" ({pipeline.pipeline_name})"

fmt.echo("\nPipeline: " + fmt.style(pipeline_name + real_pipeline_name, fg="blue"))

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/cases/cli_runner/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def null_sink(_items, _table) -> None:
)

numbers_pipeline = dlt.pipeline(
pipeline_name="numbers_pipeline",
pipeline_name="my_numbers_pipeline",
destination="duckdb",
)

Expand Down
16 changes: 9 additions & 7 deletions tests/cli/test_run_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@


def test_run_command_happy_path_works_as_expected():
# pipeline variable name
pipeline_name = "numbers_pipeline"
real_pipeline_name = "my_numbers_pipeline"
p = dlt.pipeline(pipeline_name=pipeline_name)
p._wipe_working_folder()
shutil.copytree(CLI_RUNNER_PIPELINES, TEST_STORAGE_ROOT, dirs_exist_ok=True)
Expand All @@ -33,32 +35,32 @@ def test_run_command_happy_path_works_as_expected():

output = buf.getvalue()
assert "Current working directory is different from the pipeline script" in output
assert "Pipeline: numbers_pipeline" in output
assert "Pipeline: numbers_pipeline (my_numbers_pipeline)" in output
assert "Resource: numbers_resource_instance (numbers_resource)" in output
assert "Pipeline numbers_pipeline load step completed" in output
assert "Pipeline my_numbers_pipeline load step completed" in output
assert "contains no failed jobs" in output

# Check if we can successfully attach to pipeline
dlt.attach(pipeline_name)
dlt.attach(real_pipeline_name)


def test_run_command_fails_with_relevant_error_if_pipeline_resource_or_source_not_found():
with io.StringIO() as buf, contextlib.redirect_stdout(buf):
run_command.run_pipeline_command(
str(TEST_PIPELINE),
"pipeline_404",
"squares_resource_instance",
"numbers_resource_instance",
["write_disposition=merge", "loader_file_format=jsonl"],
)

output = buf.getvalue()
assert "Pipeline pipeline_404 has not been found in pipeline script" in output
assert "You can choose one of: quads_pipeline, squares_pipeline" in output
assert "You can choose one of: quads_pipeline, numbers_pipeline" in output

with io.StringIO() as buf, contextlib.redirect_stdout(buf):
run_command.run_pipeline_command(
str(TEST_PIPELINE),
"squares_pipeline",
"numbers_pipeline",
"resource_404",
["write_disposition=merge", "loader_file_format=jsonl"],
)
Expand All @@ -68,7 +70,7 @@ def test_run_command_fails_with_relevant_error_if_pipeline_resource_or_source_no
"Source or resouce with name: resource_404 has not been found in pipeline script."
in output
)
assert "You can choose one of: quads_resource_instance, squares_resource_instance" in output
assert "You can choose one of: quads_resource_instance, numbers_resource_instance" in output


def test_run_command_allows_selection_of_pipeline_source_or_resource():
Expand Down

0 comments on commit 278477d

Please sign in to comment.