def test_nested_with_set_collection_type(self, class_entity_repo): session = class_entity_repo.session_factory() ent = MyEntity() child = MyEntityChild() ent.children = set([child]) session.add(MyEntity, ent) session.commit() fetched_ent = session.query(MyEntity).one() assert isinstance(fetched_ent.children, set)
def test_nested_with_invalid_collection_type(self, class_entity_repo): session = class_entity_repo.session_factory() ent = MyEntity() child = MyEntityChild() ent.children = (child,) with pytest.raises(ValueError): session.add(MyEntity, ent) ent.id = 0 child.id = 0 with pytest.raises(ValueError) as cm: session.load(MyEntity, ent) assert cm.value.args[0].startswith('Do not know')
def test_nested_with_invalid_collection_data(self, class_entity_repo): session = class_entity_repo.session_factory() ent = MyEntity() ent.children = [None] with pytest.raises(ValueError): session.add(MyEntity, ent)