예제 #1
0
def create_random_item(user: User, collection: Collection) -> Item:
    geometry = Point(random.random(), random.random())
    properties = {"name": random_lower_string()}
    item_in = ItemCreate(geometry=geometry, properties=properties)
    item = services.item.create_collection_item(InternalUserDTO(**user.dict()),
                                                collection.uuid,
                                                item_in.to_dto())
    return Item.from_dto(item)
예제 #2
0
def test_create_item(db: Session) -> None:
    geometry = Point(0.0, 0.0)
    properties = {"name": "test-name1"}
    item_in = ItemCreate(geometry=geometry, properties=properties)
    user = create_random_user(db)
    collection = create_random_collection(user)
    item = services.item.create_collection_item(InternalUserDTO(**user.dict()),
                                                collection.uuid,
                                                item_in.to_dto())
    assert to_shape(item.geometry) == geometry
    assert item.properties == properties
    assert item.collection_uuid == collection.uuid