Skip to content
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

improve AssetInformation and Entity constraint validation + add tests #1

Merged
merged 12 commits into from
Nov 7, 2023

Conversation

jkhsjdhjs
Copy link

This PR improves the validation of AASd-014 for Entity and AASd-131 for AssetInformation. Furthermore, tests are added. Please refer to the individual commit messages as for why something was changed.

This PR also includes the commits from eclipse-basyx#153 for the tests to succeed and thus depends on it.

The default inherited `clear()` implementation repeatedly deletes the
last item of the list until the list is empty. If the last item can be
deleted successfully, but an item in front of it that will be deleted
later cannot, this makes `clear()` non-atomic.

Thus, the `clear()` method is now overriden in an atomic way.
Furthermore, the ConstrainedList atomicity test is fixed to correctly
test for this as well.
This decorator silently overrides the `global_asset_id` property,
resulting in the constraints not being checked properly.
… to setter

This only needs to be checked if the `global_asset_id` changes.
`_validate_asset_ids_for_entity_type()` only needs to know whether there
are `specific_asset_ids` or not. This can be represented by a boolean,
allowing the delete hook of the `ConstrainedList` to make use of this
function as well.
Similar to `submodel.Entity`, this is done to reduce duplicate code.
…ecific_asset_id`

Since `__setitem__` can be used to clear the list as well (e.g.
`list[:] = ()`), the constraints need to be verified in this case as
well.
The attributes need to be assigned bypassing the setters because the
setters try to access attributes that haven't been set yet for
constraint validation. Only `global_asset_id` is set via the setter
as a final constraint validation, and because `global_asset_id` is
also constrained via a string constraint.
…ty}.specific_asset_id`

This prevents setting the attributes without verification of the constraints.
…to `Entity`

This adds an `item_add_hook` to the `specific_asset_id`
`ConstrainedList`, which is called whenever a new item is added to the
list. This is necessary because a co-managed `Entity` is not allowed to
have specific asset ids, so it shouldn't be possible to add any in this
case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants