def test_remove_id_in_single_relationship():
    relationship_store = RelationshipStore(relationships)
    relationship_store.remove_all_relationships_for_list_item_id("789101")
    remaining_relationship = Relationship(**relationships[1])

    assert len(relationship_store) == 1
    assert (relationship_store.get_relationship(
        remaining_relationship.list_item_id,
        remaining_relationship.to_list_item_id) == remaining_relationship)
    assert relationship_store.is_dirty
def test_add_relationship():
    relationship = Relationship(**relationships[0])

    relationship_store = RelationshipStore()
    relationship_store.add_or_update(relationship)

    assert (relationship_store.get_relationship(
        relationship.list_item_id,
        relationship.to_list_item_id) == relationship)
    assert len(relationship_store) == 1
    assert relationship_store.is_dirty
def test_update_existing_relationship():
    relationship_store = RelationshipStore(relationships)

    relationship = Relationship(**relationships[0])
    relationship.relationship = "test"

    relationship_store.add_or_update(relationship)

    assert len(relationship_store) == 2
    updated_relationship = relationship_store.get_relationship(
        relationship.list_item_id, relationship.to_list_item_id)
    assert updated_relationship.relationship == "test"
    assert relationship_store.is_dirty
コード例 #4
0
 def _get_answers_from_answer_store(self, answer_ids):
     """
     Maps the answers in an answer store to a dictionary of key, value answers.
     """
     answer = self._questionnaire_store.answer_store.get_answer(
         answer_ids[0])
     if answer:
         relationship_store = RelationshipStore(answer.value)
         relationship = relationship_store.get_relationship(
             self._current_location.list_item_id,
             self._current_location.to_list_item_id,
         )
         if relationship:
             return {answer.answer_id: relationship.relationship}
     return {}
def test_get_relationship_that_doesnt_exist():
    relationship_store = RelationshipStore(relationships)
    relationship = relationship_store.get_relationship(
        list_item_id="123456", to_list_item_id="yyyyyy")
    assert not relationship
def test_get_relationship():
    relationship_store = RelationshipStore(relationships)
    relationship = relationship_store.get_relationship(
        list_item_id="123456", to_list_item_id="789101")
    assert relationship