Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(xmlupload): use custom IRIs created from salsah ARKs for XML upl…
…oad (DEV-179) (#147) * add custom IRI and ARK to resource * add creation of custom IRIs from salsah ARKs to XML upload * use https for version 5 uuid * validate salsah ARK before calculating UUID * remove main methods from tests * Update xml_upload.py * add unittest * refactor list from Excel documentation * add documentation for ARK and IRI for XML upload * improve code after review
- Loading branch information
irinaschubert
committed
Jan 27, 2022
1 parent
853068d
commit 873324a
Showing
8 changed files
with
128 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Unit tests for ARK v0 conversion""" | ||
|
||
import unittest | ||
|
||
from knora.dsplib.models.helpers import BaseError | ||
from knora.dsplib.utils.xml_upload import convert_ark_v0_to_resource_iri | ||
|
||
|
||
class TestARKV02IRI(unittest.TestCase): | ||
|
||
def test_convert_ark_v0_to_resource_iri(self): | ||
ark = "ark:/72163/080c-779b9990a0c3f-6e" | ||
iri = convert_ark_v0_to_resource_iri(ark) | ||
self.assertEqual("http://rdfh.ch/080C/Ef9heHjPWDS7dMR_gGax2Q", iri) | ||
|
||
with self.assertRaises(BaseError) as err1: | ||
convert_ark_v0_to_resource_iri("ark:/72163/080c-779b999-0a0c3f-6e") | ||
self.assertEqual(err1.exception.message, "while converting ARK 'ark:/72163/080c-779b999-0a0c3f-6e'. The ARK seems to be invalid") | ||
|
||
with self.assertRaises(BaseError) as err2: | ||
convert_ark_v0_to_resource_iri("ark:/72163/080X-779b9990a0c3f-6e") | ||
self.assertEqual(err2.exception.message, "while converting ARK 'ark:/72163/080X-779b9990a0c3f-6e'. Invalid project shortcode '080X'") | ||
|
||
with self.assertRaises(BaseError) as err3: | ||
convert_ark_v0_to_resource_iri("ark:/72163/080c1-779b9990a0c3f-6e") | ||
self.assertEqual(err3.exception.message, "while converting ARK 'ark:/72163/080c1-779b9990a0c3f-6e'. Invalid project shortcode '080C1'") | ||
|
||
with self.assertRaises(BaseError) as err3: | ||
convert_ark_v0_to_resource_iri("ark:/72163/080c-779b99+90a0c3f-6e") | ||
self.assertEqual(err3.exception.message, "while converting ARK 'ark:/72163/080c-779b99+90a0c3f-6e'. Invalid Salsah ID '779b99+90a0c3f'") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |