Skip to content

Commit

Permalink
remove bad tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnyr committed Jul 31, 2024
1 parent 4f0ae8a commit ebf26e9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 132 deletions.
131 changes: 0 additions & 131 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,137 +146,6 @@ def test_groups(runner):
base_invoke = runner.invoke(root, ["utils", "refer"])
assert base_invoke.exit_code == 0


@patch("subprocess.Popen")
@patch("os.listdir")
@patch("gzip.open")
@patch("microSALT.utils.job_creator.glob.glob")
@patch("microSALT.cli.os.path.isdir")
def test_analyse_dry(
isdir, jc_glob, gzip, listdir, subproc, runner, config, path_testdata, caplog, dbm
):
caplog.clear()
caplog.set_level(logging.DEBUG, logger="main_logger")

# Sets up subprocess mocking
process_mock = mock.Mock()
attrs = {"communicate.return_value": ("output 123456789", "error")}
process_mock.configure_mock(**attrs)
subproc.return_value = process_mock
isdir.return_value = True

jc_glob.return_value = ["AAA1234A1", "AAA1234A2"]

# isdir.return_value = True
listdir.return_value = [
"ACC6438A3_HVMHWDSXX_L1_1.fastq.gz",
"ACC6438A3_HVMHWDSXX_L1_2.fastq.gz",
"ACC6438A3_HVMHWDSXX_L2_2.fastq.gz",
"ACC6438A3_HVMHWDSXX_L2_2.fastq.gz",
]

# All subcommands
base_invoke = runner.invoke(root, ["analyse"])
assert base_invoke.exit_code == 2
# Exhaustive parameter test
dry_run = runner.invoke(
root, ["analyse", path_testdata, "--input", "/tmp/AAA1234", "--dry"]
)
assert dry_run.exit_code == 0
assert "INFO - Execution finished!" in caplog.text
caplog.clear()


@patch("subprocess.Popen")
@patch("os.listdir")
@patch("gzip.open")
@patch("microSALT.utils.job_creator.glob.glob")
@patch("microSALT.cli.os.path.isdir")
def test_analyse_typical(
isdir, jc_glob, gzip, listdir, subproc, runner, config, path_testdata, caplog, dbm
):
caplog.clear()
caplog.set_level(logging.DEBUG, logger="main_logger")

# Sets up subprocess mocking
process_mock = mock.Mock()
attrs = {"communicate.return_value": ("output 123456789", "error")}
process_mock.configure_mock(**attrs)
subproc.return_value = process_mock
isdir.return_value = True

jc_glob.return_value = ["AAA1234A1", "AAA1234A2"]

# isdir.return_value = True
listdir.return_value = [
"ACC6438A3_HVMHWDSXX_L1_1.fastq.gz",
"ACC6438A3_HVMHWDSXX_L1_2.fastq.gz",
"ACC6438A3_HVMHWDSXX_L2_2.fastq.gz",
"ACC6438A3_HVMHWDSXX_L2_2.fastq.gz",
]

typical_run = runner.invoke(
root,
[
"analyse",
path_testdata,
"--input",
"/tmp/AAA1234",
"--config",
config,
"--email",
"2@2.com",
],
)
assert typical_run.exit_code == 0
assert "INFO - Execution finished!" in caplog.text
caplog.clear()


@patch("subprocess.Popen")
@patch("os.listdir")
@patch("gzip.open")
@patch("microSALT.utils.job_creator.glob.glob")
@patch("microSALT.cli.os.path.isdir")
def test_analyse_exhaustive(
isdir, jc_glob, gzip, listdir, subproc, runner, config, path_testdata, caplog, dbm
):
caplog.clear()
caplog.set_level(logging.DEBUG, logger="main_logger")

# Sets up subprocess mocking
process_mock = mock.Mock()
attrs = {"communicate.return_value": ("output 123456789", "error")}
process_mock.configure_mock(**attrs)
subproc.return_value = process_mock
isdir.return_value = True

jc_glob.return_value = ["AAA1234A1", "AAA1234A2"]

# isdir.return_value = True
listdir.return_value = [
"ACC6438A3_HVMHWDSXX_L1_1.fastq.gz",
"ACC6438A3_HVMHWDSXX_L1_2.fastq.gz",
"ACC6438A3_HVMHWDSXX_L2_2.fastq.gz",
"ACC6438A3_HVMHWDSXX_L2_2.fastq.gz",
]

special_run = runner.invoke(
root,
[
"analyse",
path_testdata,
"--skip_update",
"--assembly-mode isolate",
"--untrimmed",
"--input",
"/tmp/AAA1234",
],
)
assert special_run.exit_code == 0
assert "INFO - Execution finished!" in caplog.text


@patch("microSALT.utils.job_creator.Job_Creator.create_project")
@patch("microSALT.utils.reporter.Reporter.start_web")
@patch("multiprocessing.Process.terminate")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jobcreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_project_job(subproc,testdata):
process_mock.configure_mock(**attrs)
subproc.return_value = process_mock

jc = Job_Creator( config=preset_config, log=logger, sampleinfo=testdata, run_settings={'pool':["AAA1234A1","AAA1234A2"], 'input':'/tmp/AAA1234'})
jc = Job_Creator(config=preset_config, log=logger, sampleinfo=testdata, run_settings={'pool':["AAA1234A1","AAA1234A2"], 'input':'/tmp/AAA1234'})
jc.project_job()

def test_create_collection():
Expand Down

0 comments on commit ebf26e9

Please sign in to comment.