def test_check_ce_has_ended(self):
        # Given a valid date
        datetime_obj = parse_date('2007-01-25T12:00:00Z')

        # When check_ce_has_ended is called
        with self.assertRaises(ExerciseClosedError):
            EqPayloadConstructor._check_ce_has_ended(self.dummy_eq,
                                                     datetime_obj)
    def test_check_ce_has_ended_error(self):
        # Given an invalid date
        datetime_obj = 'invalid_date'

        # When check_ce_has_ended is called
        with self.assertRaises(InvalidEqPayLoad) as e:
            EqPayloadConstructor._check_ce_has_ended(self.dummy_eq,
                                                     datetime_obj)

        # Then an InvalidEqPayload is raised
        self.assertEqual(e.exception.message, 'Unable to compare date objects')
    def test_create_eq_constructor_missing_case_id(self):
        case_json = self.case_json.copy()
        del case_json['id']

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(case_json, self.app, self.iac_code)
        self.assertIn('No case id in supplied case JSON', ex.exception.message)
예제 #4
0
    def test_create_eq_constructor_missing_case_id(self):
        uac_json = self.uac_json_e.copy()
        del uac_json['caseId']

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(uac_json, self.attributes_en, self.app, None)
        self.assertIn('No case id in supplied case JSON', ex.exception.message)
    def test_create_eq_constructor_missing_sample_unit_id(self):
        case_json = self.case_json.copy()
        del case_json["sampleUnitId"]

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(case_json, self.app, self.iac_code)
        self.assertIn(f'No sample unit id for case {self.case_id}',
                      ex.exception.message)
    def test_create_eq_constructor_missing_ce_id(self):
        case_json = self.case_json.copy()
        del case_json["caseGroup"]["collectionExerciseId"]

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(case_json, self.app, self.iac_code)
        self.assertIn(f'No collection id for case id {self.case_id}',
                      ex.exception.message)
    def test_check_ce_has_not_ended(self):
        # Given a valid date
        datetime_obj = parse_date('2027-01-25T12:00:00Z')

        # When check_ce_has_ended is called
        self.assertIsNone(
            EqPayloadConstructor._check_ce_has_ended(self.dummy_eq,
                                                     datetime_obj))
예제 #8
0
    def test_create_eq_constructor_missing_uprn(self):
        uac_json = self.uac_json_e.copy()
        del uac_json['address']['uprn']

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(uac_json, self.attributes_en, self.app, None)
            self.assertIn(f'Could not retrieve address uprn from case JSON',
                          ex.exception.message)
    def test_create_eq_constructor_missing_ci_id(self):
        case_json = self.case_json.copy()
        del case_json['collectionInstrumentId']

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(case_json, self.app, self.iac_code)
        self.assertIn(
            f'No collectionInstrumentId value for case id {self.case_id}',
            ex.exception.message)
    def test_create_eq_constructor_missing_sample_unit_ref(self):
        case_json = self.case_json.copy()
        del case_json['caseGroup']['sampleUnitRef']

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(case_json, self.app, self.iac_code)
        self.assertIn(
            f'Could not retrieve sample unit ref for case {self.case_id}',
            ex.exception.message)
 def test_find_event_date_by_tag_unexpected_mandatory(self):
     with self.assertRaises(InvalidEqPayLoad) as e:
         EqPayloadConstructor._find_event_date_by_tag(
             self.dummy_eq, "unexpected", True)
     self.assertIn("unexpected", e.exception.message)
 def test_find_event_date_by_tag_missing_mandatory(self):
     self.dummy_eq._collex_events = []
     with self.assertRaises(InvalidEqPayLoad) as e:
         EqPayloadConstructor._find_event_date_by_tag(
             self.dummy_eq, "ref_period_start", True)
     self.assertIn("ref_period_start", e.exception.message)
 def test_find_event_date_by_tag_missing(self):
     self.dummy_eq._collex_events = []
     result = EqPayloadConstructor._find_event_date_by_tag(
         self.dummy_eq, "ref_period_start", False)
     self.assertIsNone(result)
    def test_create_eq_constructor_missing_iac(self):
        iac_code = ''

        with self.assertRaises(InvalidEqPayLoad) as ex:
            EqPayloadConstructor(self.case_json, self.app, iac_code)
        self.assertIn('IAC is empty', ex.exception.message)
 def test_create_eq_constructor(self):
     self.assertIsInstance(
         EqPayloadConstructor(self.case_json, self.app, self.iac_code),
         EqPayloadConstructor)
예제 #16
0
 def test_create_eq_constructor(self):
     self.assertIsInstance(
         EqPayloadConstructor(self.uac_json_e, self.attributes_en, self.app,
                              None), EqPayloadConstructor)