Skip to content
Snippets Groups Projects
Commit 05f017d8 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by Jesse Mapel
Browse files

ISIS ideal now fails if inst id is not ISIS Ideal (#284)

* ISIS ideal now fails if inst id is not ISIS Ideal

* redo super

* updated ideal test
parent 7d0aac3f
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ class AleJsonEncoder(json.JSONEncoder):
return obj.isoformat()
return json.JSONEncoder.default(self, obj)
def load(label, props={}, formatter='usgscsm', verbose=True):
def load(label, props={}, formatter='usgscsm', verbose=False):
"""
Attempt to load a given label from all possible drivers
......@@ -68,13 +68,17 @@ def load(label, props={}, formatter='usgscsm', verbose=True):
res.instrument_id
with res as driver:
return formatter(driver)
isd = formatter(driver)
if verbose:
print("Success with: ", driver)
print("ISD:\n", isd)
return isd
except Exception as e:
if verbose:
print(f'Failed: {e}\n')
traceback.print_exc()
raise Exception('No Such Driver for Label')
def loads(label, props='', formatter='usgscsm', verbose=True):
def loads(label, props='', formatter='usgscsm', verbose=False):
res = load(label, props, formatter, verbose=verbose)
return json.dumps(res, cls=AleJsonEncoder)
......@@ -18,6 +18,14 @@ class IdealLsIsisLabelIsisSpiceDriver(LineScanner, IsisSpice, IsisLabel, NoDisto
"""
return self.instrument_id
@property
def instrument_id(self):
instrument_id = super().instrument_id
if instrument_id != "IdealCamera":
raise Exception(f"Instrument ID is {instrument_id} when it should be \"IdealCamera\"")
return instrument_id
@property
def ephemeris_start_time(self):
......
......@@ -8,9 +8,9 @@ def IdealDriver():
return IdealLsIsisLabelIsisSpiceDriver("")
@patch('ale.base.label_isis.IsisLabel.instrument_id', 1)
@patch('ale.base.label_isis.IsisLabel.instrument_id', "IdealCamera")
def test_sensor_name(IdealDriver):
assert IdealDriver.sensor_name == 1
assert IdealDriver.sensor_name == "IdealCamera"
@patch('ale.drivers.isis_ideal_drivers.IdealLsIsisLabelIsisSpiceDriver.ephemeris_start_time', 451262458.99571)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment