Skip to content

Commit 56012bb

Browse files
Update test_collections.py to latest/v5
1 parent 5c0f962 commit 56012bb

1 file changed

Lines changed: 48 additions & 33 deletions

File tree

pipeline/tests/test_collections.py

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ def test_round_trip_single_file():
3636
collection.save(test_file_path, individual_files=False, include_empty_properties=False)
3737

3838
new_collection = Collection()
39-
new_collection.load(test_file_path)
40-
39+
new_collection.load(test_file_path, version='latest')
4140
assert len(collection) == len(new_collection)
4241

4342
for node in new_collection:
@@ -63,7 +62,7 @@ def test_round_trip_multi_file():
6362
collection = Collection(person)
6463
collection.save(test_output_dir, individual_files=True, include_empty_properties=False)
6564
new_collection = Collection()
66-
new_collection.load(test_output_dir)
65+
new_collection.load(test_output_dir, version='latest')
6766

6867
assert len(collection) == len(new_collection)
6968

@@ -83,7 +82,7 @@ def test_round_trip_multi_file_group_by_schema():
8382
collection = Collection(person)
8483
collection.save(test_output_dir, individual_files=True, include_empty_properties=False, group_by_schema=True)
8584
new_collection = Collection()
86-
new_collection.load(test_output_dir)
85+
new_collection.load(test_output_dir, version='latest')
8786

8887
assert len(collection) == len(new_collection)
8988

@@ -98,12 +97,14 @@ def test_round_trip_multi_file_group_by_schema():
9897

9998

10099
def test_collection_sort_by_id():
101-
person = omcore.Person(given_name="A", family_name="Professor", id="_:004")
102-
uni1 = omcore.Organization(full_name="University of This Place", id="_:002")
103-
uni2 = omcore.Organization(full_name="University of That Place", id="_:001")
104-
person.affiliations = [
105-
omcore.Affiliation(member_of=uni1),
106-
omcore.Affiliation(member_of=uni2),
100+
person = omcore.Person(preferred_name="A", family_name="Professor", id="_:004")
101+
uni1 = omcore.Organization(name="University of This Place", id="_:002")
102+
uni2 = omcore.Organization(name="University of That Place", id="_:001")
103+
uni1.membershipss = [
104+
omcore.Membership(member=person),
105+
]
106+
uni2.membershipss = [
107+
omcore.Membership(member=person),
107108
]
108109

109110
c = Collection(person, uni1, uni2)
@@ -116,29 +117,43 @@ def test_collection_sort_by_id():
116117
os.remove("test_collection_sort_by_id.jsonld")
117118

118119
expected_saved_data = {
119-
"@context": {"@vocab": "https://openminds.om-i.org/props/"},
120-
"@graph": [
121-
{
122-
"@id": "_:001",
123-
"@type": "https://openminds.om-i.org/types/Organization",
124-
"fullName": "University of That Place",
125-
},
126-
{
127-
"@id": "_:002",
128-
"@type": "https://openminds.om-i.org/types/Organization",
129-
"fullName": "University of This Place",
130-
},
131-
{
132-
"@id": "_:004",
133-
"@type": "https://openminds.om-i.org/types/Person",
134-
"affiliation": [
135-
{"@type": "https://openminds.om-i.org/types/Affiliation", "memberOf": {"@id": "_:002"}},
136-
{"@type": "https://openminds.om-i.org/types/Affiliation", "memberOf": {"@id": "_:001"}},
137-
],
138-
"familyName": "Professor",
139-
"givenName": "A",
140-
},
141-
],
120+
"@context":{
121+
"@vocab":"https://openminds.om-i.org/props/"
122+
},
123+
"@graph":[
124+
{
125+
"@id":"_:001",
126+
"@type":"https://openminds.om-i.org/types/Organization",
127+
"memberships":[
128+
{
129+
"@type":"https://openminds.om-i.org/types/Membership",
130+
"member":{
131+
"@id":"_:004"
132+
}
133+
}
134+
],
135+
"name":"University of That Place"
136+
},
137+
{
138+
"@id":"_:002",
139+
"@type":"https://openminds.om-i.org/types/Organization",
140+
"memberships":[
141+
{
142+
"@type":"https://openminds.om-i.org/types/Membership",
143+
"member":{
144+
"@id":"_:004"
145+
}
146+
}
147+
],
148+
"name":"University of This Place"
149+
},
150+
{
151+
"@id":"_:004",
152+
"@type":"https://openminds.om-i.org/types/Person",
153+
"familyName":"Professor",
154+
"preferredName":"A"
155+
}
156+
]
142157
}
143158

144159
assert saved_data == expected_saved_data

0 commit comments

Comments
 (0)