Skip to content
Snippets Groups Projects
Commit 5c5c5a96 authored by Kevin Kuns's avatar Kevin Kuns
Browse files

check that file types are supported by Struct in load_budget

parent 6953cd7f
No related branches found
No related tags found
No related merge requests found
Pipeline #320974 passed
......@@ -140,10 +140,15 @@ def load_budget(name_or_path, freq=None, bname=None):
modname = 'gwinc.ifo.aLIGO'
bname = bname or 'aLIGO'
else:
elif ext == '':
bname = bname or base
modname = path
else:
raise RuntimeError(
"Unknown file type: {} (supported types: {}).".format(
ext, Struct.STRUCT_EXT))
else:
if name_or_path not in IFOS:
raise RuntimeError("Unknown IFO '{}' (available IFOs: {}).".format(
......
ifos can't be specified by a txt file, so load_budget should fail when trying to load this.
......@@ -3,4 +3,4 @@
Squeezer:
AmplitudedB: 14
FilterCavity:
Lrt: 40e-6
\ No newline at end of file
Lrt: 40e-6
......@@ -92,3 +92,24 @@ def test_inherit_fail(pprint, tpath_join, fpath_join):
with pytest.raises(RuntimeError):
B_inherit2 = load_budget(fpath2)
@pytest.mark.fast
@pytest.mark.logic
def test_load_fail_unknown_filetype(fpath_join):
"""
Test that load_budget fails when given a file type not supported by Struct
"""
with pytest.raises(RuntimeError):
budget = load_budget(fpath_join('new_ifo.txt'))
@pytest.mark.fast
@pytest.mark.logic
def test_load_fail_unknown_ifo():
"""
Test that load_budget fails when given an unknown ifo that doesn't exist
"""
with pytest.raises(RuntimeError):
budget = load_budget('not_a_real_ifo')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment