def test_getExternalIdsOfCls(self): supervision_sentence = schema.StateSupervisionSentence( external_id=_EXTERNAL_ID) supervision_sentence_2 = schema.StateSupervisionSentence( external_id=_EXTERNAL_ID_2) supervision_sentence_3 = schema.StateSupervisionSentence( external_id=_EXTERNAL_ID_3) sentence_group = schema.StateSentenceGroup(external_id=_EXTERNAL_ID, supervision_sentences=[ supervision_sentence, supervision_sentence_2 ]) sentence_group_2 = schema.StateSentenceGroup( external_id=_EXTERNAL_ID_2, supervision_sentences=[ supervision_sentence_2, supervision_sentence_3 ]) external_id = schema.StatePersonExternalId(external_id=_EXTERNAL_ID) person = schema.StatePerson( external_ids=[external_id], sentence_groups=[sentence_group, sentence_group_2]) self.assertCountEqual([_EXTERNAL_ID, _EXTERNAL_ID_2, _EXTERNAL_ID_3], get_external_ids_of_cls( [person], schema.StateSupervisionSentence)) self.assertCountEqual([_EXTERNAL_ID, _EXTERNAL_ID_2], get_external_ids_of_cls( [person], schema.StateSentenceGroup)) self.assertCountEqual([_EXTERNAL_ID], get_external_ids_of_cls([person], schema.StatePerson))
def test_getExternalIdsOfCls(self): supervision_sentence = StateSupervisionSentence.new_with_defaults( external_id=_EXTERNAL_ID) supervision_sentence_2 = attr.evolve(supervision_sentence, external_id=_EXTERNAL_ID_2) supervision_sentence_3 = attr.evolve(supervision_sentence, external_id=_EXTERNAL_ID_3) sentence_group = StateSentenceGroup.new_with_defaults( external_id=_EXTERNAL_ID, supervision_sentences=[ supervision_sentence, supervision_sentence_2 ]) sentence_group_2 = StateSentenceGroup.new_with_defaults( external_id=_EXTERNAL_ID_2, supervision_sentences=[ supervision_sentence_2, supervision_sentence_3 ]) external_id = StatePersonExternalId.new_with_defaults( external_id=_EXTERNAL_ID) person = StatePerson.new_with_defaults( external_ids=[external_id], sentence_groups=[sentence_group, sentence_group_2]) self.assertCountEqual([_EXTERNAL_ID, _EXTERNAL_ID_2, _EXTERNAL_ID_3], get_external_ids_of_cls( [person], StateSupervisionSentence)) self.assertCountEqual([_EXTERNAL_ID, _EXTERNAL_ID_2], get_external_ids_of_cls([person], StateSentenceGroup)) self.assertCountEqual([_EXTERNAL_ID], get_external_ids_of_cls([person], StatePerson))
def test_getExternalIdsOfCls_emptyExternalId_raises(self): sentence_group = schema.StateSentenceGroup(external_id=_EXTERNAL_ID) sentence_group_2 = schema.StateSentenceGroup() external_id = schema.StatePersonExternalId(external_id=_EXTERNAL_ID) person = schema.StatePerson( external_ids=[external_id], sentence_groups=[sentence_group, sentence_group_2]) with pytest.raises(EntityMatchingError): get_external_ids_of_cls([person], schema.StateSentenceGroup)
def test_getExternalIdsOfCls_emptyExternalId_raises(self): sentence_group = StateSentenceGroup.new_with_defaults( external_id=_EXTERNAL_ID) sentence_group_2 = StateSentenceGroup.new_with_defaults() external_id = StatePersonExternalId.new_with_defaults( external_id=_EXTERNAL_ID) person = StatePerson.new_with_defaults( external_ids=[external_id], sentence_groups=[sentence_group, sentence_group_2]) with pytest.raises(EntityMatchingError): get_external_ids_of_cls([person], StateSentenceGroup)
def test_getExternalIdsOfCls_emptyPersonExternalId_raises(self): person = schema.StatePerson() with pytest.raises(EntityMatchingError): get_external_ids_of_cls([person], schema.StatePerson)
def test_getExternalIdsOfCls_emptyPersonExternalId_raises(self): person = StatePerson.new_with_defaults() with pytest.raises(EntityMatchingError): get_external_ids_of_cls([person], StatePerson)