Skip to content

Commit

Permalink
chore: validate attribut no exist after deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
djs0109 committed Feb 25, 2025
1 parent 74d0438 commit 9574828
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/clients/test_ngsi_ld_cb_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def test_post_entity(self):
self.client.post_entity(entity=self.entity_identical)
response = contextmanager.exception.response
self.assertEqual(response.status_code, 409)

entity_list = self.client.get_entity_list(
entity_type=self.entity_identical.type, options="keyValues"
)
Expand Down Expand Up @@ -154,7 +153,7 @@ def test_post_entity(self):
entity_list = self.client.get_entity_list(options="keyValues")
self.assertNotIn("room2", entity_list)

"""delete"""
# delete entity
self.client.entity_batch_operation(
entities=entity_list, action_type=ActionTypeLD.DELETE
)
Expand Down Expand Up @@ -384,19 +383,16 @@ def test_delete_entity_attribute(self):
self.client.delete_attribute(
entity_id=self.entity.id, attribute_id="does_not_exist"
)

entity_list = self.client.get_entity_list(options="keyValues")

for entity in entity_list:
self.client.delete_entity_by_id(entity_id=entity.id)
self.client.delete_entity_by_id(entity_id=self.entity.id)

"""Test 2"""
self.entity.test_value = 20
self.client.post_entity(entity=self.entity)
self.client.delete_attribute(
entity_id=self.entity.id, attribute_id="test_value"
)

entity_response = self.client.get_entity(entity_id=self.entity.id)
self.assertNotIn("test_value", entity_response.model_dump())
with self.assertRaises(requests.exceptions.HTTPError) as contextmanager:
self.client.delete_attribute(
entity_id=self.entity.id, attribute_id="test_value"
Expand Down Expand Up @@ -520,7 +516,9 @@ def test_entity_batch_operations_create(self) -> None:
"""Test 1"""
entities_a = [
ContextLDEntityKeyValues(
id=f"urn:ngsi-ld:test:{str(i)}", type=f"filip:object:test"
id=f"urn:ngsi-ld:test:{str(i)}",
type=f"filip:object:test",
temperature=i,
)
for i in range(0, 10)
]
Expand Down

0 comments on commit 9574828

Please sign in to comment.