Skip to content

Commit

Permalink
Fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Aug 1, 2024
1 parent 466b846 commit ee3506d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
10 changes: 2 additions & 8 deletions tests/test_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ async def test_resource_upsert(
assert results_all.count > 0

# define content of resource
content = {
content: dict = {
"has_object": {"type": "added-resource-object", "id": "98u44-f4jo4"},
"field1": "something",
"category": "test object",
}

# define a resource to be upserted
resource = models.Resource(
id_=resource_id,
content=content, # type: ignore
)
resource = models.Resource(id_=resource_id, content=content)

# put together event payload
payload = event_schemas.SearchableResource(
Expand Down Expand Up @@ -82,11 +79,8 @@ async def test_resource_upsert(
assert updated_resources.count == results_all.count

# remove unselected fields
content = resource.content
assert isinstance(content, dict)
del content["field1"]
del content["category"]
assert isinstance(content["has_object"], dict)
del content["has_object"]["id"]

assert resource in updated_resources.hits
Expand Down
18 changes: 7 additions & 11 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,14 @@ async def test_resource_load(joint_fixture: JointFixture):
class_name="DatasetEmbedded", query="", filters=[]
)

content: dict = {
"has_object": {"type": "added-resource-object", "id": "98u44-f4jo4"},
"field1": "something",
"category": "test object",
}

# define and load a new resource
resource = models.Resource(
id_="added-resource",
content={
"has_object": {"type": "added-resource-object", "id": "98u44-f4jo4"},
"field1": "something",
"category": "test object",
},
)
resource = models.Resource(id_="added-resource", content=content)

await joint_fixture.query_handler.load_resource(
resource=resource, class_name="DatasetEmbedded"
Expand All @@ -179,11 +178,8 @@ async def test_resource_load(joint_fixture: JointFixture):
assert validated_resource.id_ == resource.id_

# remove unselected fields
content = resource.content
assert isinstance(content, dict)
del content["field1"]
del content["category"]
assert isinstance(content["has_object"], dict)
del content["has_object"]["id"]

assert validated_resource.content == content
Expand Down

0 comments on commit ee3506d

Please sign in to comment.