Unverified Commit 710778bc authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Adds fast fail instrument_id lookup on driver (#502)

* Adds fast fail instrument_id lookup on driver

* Removes import gifted by the IDE
parent fe6c55e5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12,6 +12,13 @@ from ale.base.type_sensor import LineScanner
class KaguyaTcIsisLabelIsisSpiceDriver(LineScanner, IsisLabel, IsisSpice, KaguyaSeleneDistortion, Driver):
    """
    """
    VALID_INSTRUMENT_IDS = ['TC1', 'TC2']
    @property
    def instrument_id(self):
      iid = self.label['IsisCube']['Instrument']['InstrumentId']
      if iid not in self.VALID_INSTRUMENT_IDS:
        raise ValueError(f"Instrument ID: '{iid}' not in VALID_INSTRUMENT_IDS list. Failing.")
      return iid

    @property
    def spacecraft_name(self):
+8 −0
Original line number Diff line number Diff line
@@ -199,6 +199,14 @@ class test_isis_isis(unittest.TestCase):
        label = get_image_label("TC1S2B0_01_06691S820E0465", "isis")
        self.driver = KaguyaTcIsisLabelIsisSpiceDriver(label)

    def test_instrument_id(self):
        assert self.driver.instrument_id == 'TC1'

    def test_bad_instrument_id(self):
        self.driver.label['IsisCube']['Instrument']['InstrumentId'] = 'FAIL'
        with self.assertRaises(ValueError):
            self.driver.instrument_id

    def test_spacecraft_name(self):
        assert self.driver.spacecraft_name == 'KAGUYA'