def test_onObservationError_does_not_call_cancel_trigger_when_its_not_a_trigger(
            self):
        self.momqueryrpc_mock.get_trigger_id.return_value = {
            'trigger_id': None,
            'status': "Error"
        }

        handler = TriggerCancellationHandler(self.momqueryrpc_mock)

        handler.onObservationError(self.obs_sas_id, None)

        self.momqueryrpc_mock.cancel_trigger.assert_not_called()
    def test_onObservationError_uses_correct_triggerid_and_sets_correct_cancellation_reason(
            self):
        handler = TriggerCancellationHandler(self.momqueryrpc_mock)

        handler.onObservationError(self.obs_sas_id, None)

        # correct otdb id is used to obtain trigger
        call_otdb_id = self.momqueryrpc_mock.getMoMIdsForOTDBIds.call_args[0][
            0]
        self.assertEqual(self.obs_sas_id, call_otdb_id)

        # correct trigger id and reason are used to abort
        call_id, call_reason = self.momqueryrpc_mock.cancel_trigger.call_args[
            0]
        self.assertEqual(self.trigger_id, call_id)
        self.assertIn('error', call_reason)
    def test_onObservationError_calls_cancel_trigger_when_its_a_trigger(self):
        handler = TriggerCancellationHandler(self.momqueryrpc_mock)

        handler.onObservationError(self.obs_sas_id, None)

        self.momqueryrpc_mock.cancel_trigger.assert_called()