@@ -148,41 +148,41 @@ def test_create_with_same_id_but_diff_partition_key_attrib_should_succeed(
148148 assert result ["id" ] == sample_item ["id" ], "Should have allowed same id"
149149
150150
151- # def test_create_with_mapper_should_provide_calculated_fields(
152- # cosmos_db_repository: CosmosDBRepository,
153- # event_context: EventContext,
154- # tenant_id: str,
155- # ):
156- # new_item = dict(
157- # id=fake.uuid4(),
158- # name=fake.name(),
159- # email=fake.safe_email(),
160- # age=fake.pyint(min_value=10, max_value=80),
161- # tenant_id=tenant_id,
162- # )
163- #
164- # created_item: Person = cosmos_db_repository.create(
165- # new_item, event_context, mapper=Person
166- # )
167- #
168- # assert created_item is not None
169- # assert all(
170- # item in created_item.__dict__.items() for item in new_item.items()
171- # )
172- # assert (
173- # type(created_item) is Person
174- # ), "The result should be wrapped with a class"
175- # assert created_item.is_adult() is (new_item["age"] >= 18)
176-
177-
178- # def test_find_by_valid_id_should_succeed(
179- # cosmos_db_repository: CosmosDBRepository,
180- # sample_item: dict,
181- # event_context: EventContext,
182- # ):
183- # found_item = cosmos_db_repository.find(sample_item["id"], event_context)
184- #
185- # assert all(item in found_item.items() for item in sample_item.items())
151+ def test_create_with_mapper_should_provide_calculated_fields (
152+ cosmos_db_repository : CosmosDBRepository ,
153+ event_context : EventContext ,
154+ tenant_id : str ,
155+ ):
156+ new_item = dict (
157+ id = fake .uuid4 (),
158+ name = fake .name (),
159+ email = fake .safe_email (),
160+ age = fake .pyint (min_value = 10 , max_value = 80 ),
161+ tenant_id = tenant_id ,
162+ )
163+
164+ created_item : Person = cosmos_db_repository .create (
165+ new_item , event_context , mapper = Person
166+ )
167+
168+ assert created_item is not None
169+ assert all (
170+ item in created_item .__dict__ .items () for item in new_item .items ()
171+ )
172+ assert (
173+ type (created_item ) is Person
174+ ), "The result should be wrapped with a class"
175+ assert created_item .is_adult () is (new_item ["age" ] >= 18 )
176+
177+
178+ def test_find_by_valid_id_should_succeed (
179+ cosmos_db_repository : CosmosDBRepository ,
180+ sample_item : dict ,
181+ event_context : EventContext ,
182+ ):
183+ found_item = cosmos_db_repository .find (sample_item ["id" ], event_context )
184+
185+ assert all (item in found_item .items () for item in sample_item .items ())
186186
187187
188188def test_find_by_invalid_id_should_fail (
0 commit comments