Exemplo n.º 1
0
 def test_update_member_with_link(self):
     my_entity = create_entity()
     new_parent = MyEntityParent()
     new_parent.text = self.UPDATED_TEXT
     new_parent.id = 2
     my_entity.parent = new_parent
     coll = create_staging_collection(IMyEntity)
     member = coll.create_member(my_entity)
     mp = self._make_mapping()
     attribute_options = {
         ('parent', ): {
             WRITE_AS_LINK_OPTION: True
         },
         ('nested_parent', ): {
             IGNORE_OPTION: True
         }
     }
     mp_cloned = mp.clone(attribute_options=attribute_options)
     data_el = mp_cloned.map_to_data_element(member)
     # The linked-to parent needs to be in the root collection.
     my_entity.parent = None
     del member
     del my_entity
     parent_coll = get_root_collection(IMyEntityParent)
     parent_coll.create_member(new_parent)
     my_entity = create_entity()
     coll = get_root_collection(IMyEntity)
     context = coll.create_member(my_entity)
     self.assert_equal(context.parent.text, MyEntity.DEFAULT_TEXT)
     context.update_from_data(data_el)
     self.assert_equal(context.parent.text, self.UPDATED_TEXT)
Exemplo n.º 2
0
 def test_update_member_with_link(self):
     my_entity = create_entity()
     new_parent = MyEntityParent()
     new_parent.text = self.UPDATED_TEXT
     new_parent.id = 2
     my_entity.parent = new_parent
     coll = create_staging_collection(IMyEntity)
     member = coll.create_member(my_entity)
     mp = self._make_mapping()
     attribute_options = {('parent',):{WRITE_AS_LINK_OPTION:True},
                        ('nested_parent',):{IGNORE_OPTION:True}}
     mp_cloned = mp.clone(attribute_options=attribute_options)
     data_el = mp_cloned.map_to_data_element(member)
     # The linked-to parent needs to be in the root collection.
     my_entity.parent = None
     del member
     del my_entity
     parent_coll = get_root_collection(IMyEntityParent)
     parent_coll.create_member(new_parent)
     my_entity = create_entity()
     coll = get_root_collection(IMyEntity)
     context = coll.create_member(my_entity)
     self.assert_equal(context.parent.text, MyEntity.DEFAULT_TEXT)
     context.update_from_data(data_el)
     self.assert_equal(context.parent.text, self.UPDATED_TEXT)
Exemplo n.º 3
0
 def test_update_member(self):
     my_entity = create_entity()
     new_parent = MyEntityParent()
     new_parent.text = self.UPDATED_TEXT
     new_parent.id = 2
     my_entity.parent = new_parent
     coll = create_staging_collection(IMyEntity)
     member = coll.create_member(my_entity)
     mp = self._make_mapping()
     data_el = mp.map_to_data_element(member)
     del member
     del my_entity
     my_entity = create_entity()
     coll = get_root_collection(IMyEntity)
     context = coll.create_member(my_entity)
     self.assert_equal(context.parent.text, MyEntity.DEFAULT_TEXT)
     context.update_from_data(data_el)
     self.assert_equal(context.parent.text, self.UPDATED_TEXT)
Exemplo n.º 4
0
 def test_update_member(self):
     my_entity = create_entity()
     new_parent = MyEntityParent()
     new_parent.text = self.UPDATED_TEXT
     new_parent.id = 2
     my_entity.parent = new_parent
     coll = create_staging_collection(IMyEntity)
     member = coll.create_member(my_entity)
     mp = self._make_mapping()
     data_el = mp.map_to_data_element(member)
     del member
     del my_entity
     my_entity = create_entity()
     coll = get_root_collection(IMyEntity)
     context = coll.create_member(my_entity)
     self.assert_equal(context.parent.text, MyEntity.DEFAULT_TEXT)
     context.update_from_data(data_el)
     self.assert_equal(context.parent.text, self.UPDATED_TEXT)