Skip to content

Commit

Permalink
Add dummy mode test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
agitter committed Nov 23, 2024
1 parent 41aeb36 commit 81eddf3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/OmicsIntegrator1/input/oi1-dummy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
B
30 changes: 30 additions & 0 deletions test/OmicsIntegrator1/test_oi1.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_oi1_all_optional(self):
# Include all optional arguments
OmicsIntegrator1.run(edges=TEST_DIR+'input/oi1-edges.txt',
prizes=TEST_DIR+'input/oi1-prizes.txt',
dummy_nodes=None,
dummy_mode='terminals',
mu_squared=True,
exclude_terms=True,
Expand All @@ -66,6 +67,23 @@ def test_oi1_all_optional(self):
r=0)
assert out_path.exists()

def test_oi1_dummy_file(self):
out_path = Path(OUT_FILE)
out_path.unlink(missing_ok=True)
# Include optional argument
OmicsIntegrator1.run(edges=TEST_DIR+'input/oi1-edges.txt',
prizes=TEST_DIR+'input/oi1-prizes.txt',
dummy_nodes=TEST_DIR + 'input/oi1-dummy.txt',
dummy_mode='file',
output_file=OUT_FILE,
w=5,
b=1,
d=10,
noise=0.333,
g=0.001,
r=0)
assert out_path.exists()

def test_oi1_missing(self):
# Test the expected error is raised when required arguments are missing
with pytest.raises(ValueError):
Expand All @@ -81,6 +99,18 @@ def test_oi1_missing(self):
b=1,
d=10)

def test_oi1_missing_dummy(self):
# Test the expected error is raised when the dummy_nodes file is missing and the dummy_mode is 'file'
with pytest.raises(ValueError):
# No edges
OmicsIntegrator1.run(edges=TEST_DIR+'input/oi1-edges.txt',
prizes=TEST_DIR + 'input/oi1-prizes.txt',
output_file=TEST_DIR+'output/test_optimalForest.sif',
w=5,
b=1,
d=10,
dummy_mode='file')

# Only run Singularity test if the binary is available on the system
# spython is only available on Unix, but do not explicitly skip non-Unix platforms
@pytest.mark.skipif(not shutil.which('singularity'), reason='Singularity not found on system')
Expand Down

0 comments on commit 81eddf3

Please sign in to comment.