Skip to content

Commit

Permalink
swapped order of the assetId when creating an asset to avoid being de…
Browse files Browse the repository at this point in the history
…tected as aim_id
  • Loading branch information
davidvlaminck committed Dec 6, 2024
1 parent 609b011 commit 6a302c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions UnitTests/GeneralTests/RelationCreator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def test_create_valid_relation():
assert relation.typeURI == Bevestiging.typeURI
assert relation.bronAssetId.identificator == another.assetId.identificator
assert relation.doelAssetId.identificator == all_cases.assetId.identificator
assert relation.assetId.identificator == 'Bevestiging_-_another_-_all_cases'


def test_create_relation_input_parameters(subtests):
Expand Down Expand Up @@ -106,6 +107,7 @@ def test_create_relation_input_parameters(subtests):
assert relation.typeURI == Bevestiging.typeURI
assert relation.bronAssetId.identificator == another.assetId.identificator
assert relation.doelAssetId.identificator == all_cases.assetId.identificator
assert relation.assetId.identificator == 'Bevestiging_-_another_-_all_cases'

with subtests.test(msg='real test'):
kast = dynamic_create_instance_from_ns_and_name(namespace='onderdeel', class_name='Wegkantkast')
Expand All @@ -117,6 +119,7 @@ def test_create_relation_input_parameters(subtests):
relation_type=HoortBij)
assert relation is not None
assert relation.doelAssetId.identificator == '847a91b3-569d-4bae-87bf-7e148e8f7de9-bGdjOmluc3RhbGxhdGllI0JlaGVlcnN5cw'
assert relation.assetId.identificator == 'HoortBij_-_0000_-_847a91b3-569d-4bae-87bf-7e148e8f7de9-bGdjOmluc3RhbGxhdGllI0JlaGVlcnN5cw'


def test_create_invalid_relation():
Expand Down
4 changes: 1 addition & 3 deletions otlmow_model/OtlmowModel/Helpers/RelationCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def create_relation(relation_type: Type[RelatieObject], source: Optional[Relatio
raise AttributeError('In order to create a relation_type, the target needs to have a valid assetId '
'(target.assetId.identificator)')

relation_id = ''
relation_id = relation_type.__class__.__name__ + '_-_'
if source_is_legacy:
relation_type.bronAssetId.identificator = source_aim_id
relation_type.bronAssetId.toegekendDoor = 'AWV'
Expand Down Expand Up @@ -152,8 +152,6 @@ def create_relation(relation_type: Type[RelatieObject], source: Optional[Relatio
relation_type.doelAssetId.toegekendDoor = target.assetId.toegekendDoor
relation_id += target.assetId.identificator

relation_id += '_-_' + relation_type.__class__.__name__

relation_type.assetId.identificator = relation_id
relation_type.assetId.toegekendDoor = 'OTLMOW'

Expand Down

0 comments on commit 6a302c5

Please sign in to comment.