Skip to content

Commit

Permalink
Remove dryrun flag (#3244) (patch)
Browse files Browse the repository at this point in the history
###Changed
- Removes the short flag "-d" in the DRY_RUN option in cg/constants/constants.py
- In test files, "-d" was changed to "--dry-run".
  • Loading branch information
eliottBo authored May 22, 2024
1 parent f07d1e7 commit eb23c88
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 15 deletions.
1 change: 0 additions & 1 deletion cg/constants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ class APIMethods(StrEnum):


DRY_RUN = click.option(
"-d",
"--dry-run",
is_flag=True,
default=False,
Expand Down
6 changes: 4 additions & 2 deletions tests/cli/clean/test_balsamic_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def test_dry_run(
TrailblazerAPI.is_latest_analysis_ongoing.return_value = False

# WHEN dry running with dry run specified
result = cli_runner.invoke(clean_run_dir, [balsamic_case_clean, "-d", "-y"], obj=clean_context)
result = cli_runner.invoke(
clean_run_dir, [balsamic_case_clean, "--dry-run", "-y"], obj=clean_context
)
# THEN command should say it would have deleted
assert result.exit_code == EXIT_SUCCESS
assert "Would have deleted" in caplog.text
Expand Down Expand Up @@ -136,7 +138,7 @@ def test_cleaned_at_invalid(
assert not base_store.get_case_by_internal_id(balsamic_case_not_clean).analyses[0].cleaned_at
# WHEN dry running with dry run specified

result = cli_runner.invoke(past_run_dirs, ["2020-12-01", "-d", "-y"], obj=clean_context)
result = cli_runner.invoke(past_run_dirs, ["2020-12-01", "--dry-run", "-y"], obj=clean_context)

# THEN case directory should not have been cleaned
assert result.exit_code == EXIT_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/clean/test_clean_flow_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_clean_flow_cells_cmd_dry_run(
"cg.meta.clean.clean_flow_cells.CleanFlowCellAPI.is_directory_older_than_21_days",
return_value=True,
):
result = cli_runner.invoke(clean_flow_cells, ["-d"], obj=clean_flow_cells_context)
result = cli_runner.invoke(clean_flow_cells, ["--dry-run"], obj=clean_flow_cells_context)

# THEN assert it exits with success
assert result.exit_code == 0
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/clean/test_microbial_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_dry_run(

# WHEN dry running with dry run specified
result = cli_runner.invoke(
clean_run_dir, [microsalt_case_clean_dry, "-d", "-y"], obj=clean_context_microsalt
clean_run_dir, [microsalt_case_clean_dry, "--dry-run", "-y"], obj=clean_context_microsalt
)

# THEN command should say it would have deleted
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/clean/test_rsync_past_run_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_clean_rsync_past_run_dirs_young_process(
assert rsync_process.exists()
# WHEN attempting to remove said process same day
result = cli_runner.invoke(
rsync_past_run_dirs, ["-d", "-y", str(timestamp_now)], obj=clean_context
rsync_past_run_dirs, ["--dry-run", "-y", str(timestamp_now)], obj=clean_context
)
# THEN the command should not fail and notice that the process is not old
assert result.exit_code == EXIT_SUCCESS
Expand Down
26 changes: 19 additions & 7 deletions tests/cli/workflow/microsalt/test_microsalt_case_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def test_dry_sample(
# GIVEN project, organism and reference genome is specified in lims

# WHEN dry running a sample name
result = cli_runner.invoke(config_case, [microbial_sample_id, "-s", "-d"], obj=base_context)
result = cli_runner.invoke(
config_case, [microbial_sample_id, "-s", "--dry-run"], obj=base_context
)

# THEN command should give us a json dump
assert result.exit_code == EXIT_SUCCESS
Expand All @@ -105,7 +107,7 @@ def test_dry_order(
# WHEN dry running a sample name
result = cli_runner.invoke(
config_case,
[ticket_id, "-t", "-d"],
[ticket_id, "-t", "--dry-run"],
obj=base_context,
)

Expand Down Expand Up @@ -135,7 +137,9 @@ def test_gonorrhoeae(cli_runner: CliRunner, base_context: CGConfig, microbial_sa
sample_obj.organism.internal_id = "gonorrhoeae"

# WHEN getting the case config
result = cli_runner.invoke(config_case, [microbial_sample_id, "-d", "-s"], obj=base_context)
result = cli_runner.invoke(
config_case, [microbial_sample_id, "--dry-run", "-s"], obj=base_context
)

# THEN the organism should now be ...
assert "Neisseria spp." in result.output
Expand All @@ -150,7 +154,9 @@ def test_cutibacterium_acnes(cli_runner: CliRunner, base_context: CGConfig, micr
sample_obj.organism.internal_id = "Cutibacterium acnes"

# WHEN getting the case config
result = cli_runner.invoke(config_case, [microbial_sample_id, "-s", "-d"], obj=base_context)
result = cli_runner.invoke(
config_case, [microbial_sample_id, "-s", "--dry-run"], obj=base_context
)

# THEN the organism should now be ....
assert "Propionibacterium acnes" in result.output
Expand All @@ -166,7 +172,9 @@ def test_vre_nc_017960(cli_runner: CliRunner, base_context: CGConfig, microbial_
sample_obj.organism.reference_genome = "NC_017960.1"

# WHEN getting the case config
result = cli_runner.invoke(config_case, [microbial_sample_id, "-s", "-d"], obj=base_context)
result = cli_runner.invoke(
config_case, [microbial_sample_id, "-s", "--dry-run"], obj=base_context
)

# THEN the organism should now be ....
assert "Enterococcus faecium" in result.output
Expand All @@ -182,7 +190,9 @@ def test_vre_nc_004668(cli_runner: CliRunner, base_context: CGConfig, microbial_
sample_obj.organism.reference_genome = "NC_004668.1"

# WHEN getting the case config
result = cli_runner.invoke(config_case, [microbial_sample_id, "-s", "-d"], obj=base_context)
result = cli_runner.invoke(
config_case, [microbial_sample_id, "-s", "--dry-run"], obj=base_context
)

# THEN the organism should now be ....
assert "Enterococcus faecalis" in result.output
Expand All @@ -201,7 +211,9 @@ def test_vre_comment(
lims_sample.sample_data["comment"] = "ABCD123"

# WHEN getting the case config
result = cli_runner.invoke(config_case, [microbial_sample_id, "-s", "-d"], obj=base_context)
result = cli_runner.invoke(
config_case, [microbial_sample_id, "-s", "--dry-run"], obj=base_context
)

# THEN the organism should now be ....
assert "ABCD123" in result.output
2 changes: 1 addition & 1 deletion tests/cli/workflow/microsalt/test_microsalt_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_dry_arguments(cli_runner: CliRunner, base_context: CGConfig, ticket_id,
caplog.set_level(logging.INFO)

# WHEN dry running without anything specified
result = cli_runner.invoke(run, [ticket_id, "-t", "-d"], obj=base_context)
result = cli_runner.invoke(run, [ticket_id, "-t", "--dry-run"], obj=base_context)

# THEN command should mention missing arguments
assert result.exit_code == EXIT_SUCCESS
Expand Down
4 changes: 3 additions & 1 deletion tests/cli/workflow/nf_analysis/test_cli_config_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ def test_config_case_dry_run(
mocker.patch.object(LimsAPI, "get_source", return_value="blood")

# WHEN invoking the command with dry-run specified
result = cli_runner.invoke(workflow_cli, [workflow, "config-case", case_id, "-d"], obj=context)
result = cli_runner.invoke(
workflow_cli, [workflow, "config-case", case_id, "--dry-run"], obj=context
)

# THEN command should exit successfully
assert result.exit_code == EXIT_SUCCESS
Expand Down

0 comments on commit eb23c88

Please sign in to comment.