-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
232 post entity will not completely override the existing entity #233
232 post entity will not completely override the existing entity #233
Conversation
@tstorek by checking this issue, I found that the |
@djs0109 The reason for |
@tstorek By "partially update," do you mean like to send only a part of the attributes in the payload, and then Orion will only update the included attributes (and other attributes will not be changed)? If not, it would be great if you can add a simple implementation here FiLiP/tests/clients/test_ngsi_v2_cb.py Line 244 in d606818
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are only some small comments from my side :)
client.post_entity(entity=entity_post, update=True) | ||
self.assertEqual(client.get_entity(entity_id=entity_post.id), | ||
entity_post) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djs0109 After each step (so after post
, update_entity
and override_entity
) I would clear the OCB and reset the variable attr_append
:
clear_all(fiware_header=self.fiware_header, cb_url=settings.CB_URL)
attr_append = NamedContextAttribute(**{
"name": 'pressure',
"type": 'Number',
"value": 1050})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I add the clear_all
, and use attr_append_update
for updating attribute, so that the attr_append
will not be touched during the whole test.
tests/clients/test_ngsi_v2_cb.py
Outdated
# 1) append attribute | ||
entity_update.add_attributes(attrs=[attr_append]) | ||
with self.assertRaises(requests.RequestException): | ||
client.update_entity(entity=entity_update, append_strict=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djs0109 This call still makes an update to the entity. So we could add the follwing assertion:
self.assertEqual(client.get_entity(entity_id=entity_update.id),
entity_update)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I thought that the request will be completely blocked
tests/clients/test_ngsi_v2_cb.py
Outdated
# 3) delete attribute | ||
entity_patch.delete_attributes(attrs=[attr_append]) | ||
client.patch_entity(entity=entity_patch) | ||
# TODO It is expected here not to pass the test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djs0109 The patch function can also delete attributes from an entity with the DELETE request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Currently it is possible. But right now patch_entity
works more like a put_entity
. But I will remove the todos here and maybe open another issue
@tstorek It seems that the |
@djs0109 I have only one small comment on the line FiLiP/tests/clients/test_ngsi_v2_cb.py Line 221 in b6c1d76
because it does not do very much. You can maybe make an assertion out of it like self.assertEqual(res_entity, client.get_entity(entity_id=self.entity.id, attrs=['temperature'])) . I think we can merge after this.
|
@RCX112 Thank you for the suggestion! But I think that will make the test a bit more hard-coded, because if we later add another initial attribute (e.g. "pressure") in |
@djs0109 Maybe you could change the line to something like this pseudo code: |
@RCX112 Fair point :) I added it like that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djs0109 I think the branch is ready to merge :)
closes #232