-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_xmlupload.py
51 lines (42 loc) · 1.66 KB
/
test_xmlupload.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
48
49
50
51
# pylint: disable=missing-class-docstring,missing-function-docstring
import unittest
import pytest
from dsp_tools.models.exceptions import UserError
from dsp_tools.utils.xml_upload import xml_upload
class TestXMLUpload(unittest.TestCase):
server = "http://0.0.0.0:3333"
user = "root@example.com"
password = "test"
imgdir = "."
sipi = "http://0.0.0.0:1024"
def test_xml_upload(self) -> None:
with self.assertRaisesRegex(UserError, r"A project with shortcode 9999 could not be found on the DSP server"):
xml_upload(
input_file="testdata/invalid-testdata/xml-data/inexistent-shortcode.xml",
server=self.server,
user=self.user,
password=self.password,
imgdir=self.imgdir,
sipi=self.sipi,
verbose=False,
save_metrics=False,
preprocessing_done=False,
)
with self.assertRaisesRegex(
UserError,
r"The <knora> tag of your XML file references the default-ontology 'notexistingfantasyonto', "
r"but the project 4124 on the DSP server contains only the ontologies {'testonto'}",
):
xml_upload(
input_file="testdata/invalid-testdata/xml-data/inexistent-ontoname.xml",
server=self.server,
user=self.user,
password=self.password,
imgdir=self.imgdir,
sipi=self.sipi,
verbose=False,
save_metrics=False,
preprocessing_done=False,
)
if __name__ == "__main__":
pytest.main([__file__])