-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_propertyclass.py
47 lines (38 loc) · 1.53 KB
/
test_propertyclass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytest
from dsp_tools.commands.project.models.ontology import Ontology
from dsp_tools.commands.project.models.propertyclass import PropertyClass
from dsp_tools.models.langstring import LangString, Languages
from dsp_tools.utils.connection_live import ConnectionLive
def test_PropertyClass_create() -> None:
con = ConnectionLive(server="http://0.0.0.0:3333")
con.login(email="root@example.com", password="test")
# Create a test ontology
onto = Ontology(
con=con,
project="http://rdfh.ch/projects/0001",
name="onto-1",
label="onto-label",
).create()
assert onto.iri is not None
last_modification_date = onto.lastModificationDate
# create new property class
prop_name = "MyPropClassName"
prop_label = LangString({Languages.DE: "MyPropClassLabel"})
prop_comment = LangString({Languages.DE: "This is a property class for testing"})
last_modification_date, property_class = PropertyClass(
con=con,
context=onto.context,
name=prop_name,
ontology_id=onto.iri,
rdf_object="TextValue",
label=prop_label,
comment=prop_comment,
).create(last_modification_date)
assert property_class.iri is not None
assert property_class.name == prop_name
assert property_class.label["de"] == prop_label["de"]
assert property_class.comment["de"] == prop_comment["de"]
# delete the property class to clean up
_ = property_class.delete(last_modification_date)
if __name__ == "__main__":
pytest.main([__file__])