Skip to content

Commit 3729508

Browse files
matentznhrshdhgd
andauthored
What to do when having a uri-prefix clash? (#473)
Note: If you remove either one of the two prefixes, it works --------- Co-authored-by: Harshad Hegde <[email protected]> Co-authored-by: Harshad <[email protected]>
1 parent c1b0ef8 commit 3729508

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

tests/test_utils.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pandas as pd
77
import yaml
8-
from curies import Converter, Record
8+
from curies import Converter, Record, chain
99
from sssom_schema import Mapping as SSSOM_Mapping
1010

1111
from sssom.constants import (
@@ -430,3 +430,40 @@ def test_get_dict_from_mapping(self):
430430
else:
431431
self.assertEqual(value, result_with_mapping_object[key])
432432
self.assertEqual(value, result_with_dict[key])
433+
434+
def test_curiechain_with_conflicts(self):
435+
"""Test curie map with CURIE/URI clashes."""
436+
PREFIXMAP_BOTH = {
437+
"SCTID": "http://identifiers.org/snomedct/",
438+
"SCTID__2": "http://snomed.info/id/",
439+
}
440+
PREFIXMAP_FIRST = {
441+
"SCTID": "http://identifiers.org/snomedct/",
442+
}
443+
PREFIXMAP_SECOND = {
444+
"SCTID__2": "http://snomed.info/id/",
445+
}
446+
447+
EPM = [
448+
{
449+
"prefix": "SCTID",
450+
"prefix_synonyms": ["snomed"],
451+
"uri_prefix": "http://snomed.info/id/",
452+
},
453+
]
454+
455+
converter = chain(
456+
[Converter.from_prefix_map(PREFIXMAP_FIRST), Converter.from_extended_prefix_map(EPM)]
457+
)
458+
self.assertIn("SCTID", converter.prefix_map)
459+
converter = chain(
460+
[Converter.from_prefix_map(PREFIXMAP_SECOND), Converter.from_extended_prefix_map(EPM)]
461+
)
462+
self.assertIn("SCTID", converter.prefix_map)
463+
# Fails here:
464+
with self.assertRaises(ValueError):
465+
chain(
466+
[Converter.from_prefix_map(PREFIXMAP_BOTH), Converter.from_extended_prefix_map(EPM)]
467+
)
468+
469+
# self.assertIn("SCTID", converter.prefix_map)

0 commit comments

Comments
 (0)