Skip to content

Commit

Permalink
What to do when having a uri-prefix clash? (#473)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
3 people committed Dec 5, 2023
1 parent c1b0ef8 commit 3729508
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pandas as pd
import yaml
from curies import Converter, Record
from curies import Converter, Record, chain
from sssom_schema import Mapping as SSSOM_Mapping

from sssom.constants import (
Expand Down Expand Up @@ -430,3 +430,40 @@ def test_get_dict_from_mapping(self):
else:
self.assertEqual(value, result_with_mapping_object[key])
self.assertEqual(value, result_with_dict[key])

def test_curiechain_with_conflicts(self):
"""Test curie map with CURIE/URI clashes."""
PREFIXMAP_BOTH = {
"SCTID": "http://identifiers.org/snomedct/",
"SCTID__2": "http://snomed.info/id/",
}
PREFIXMAP_FIRST = {
"SCTID": "http://identifiers.org/snomedct/",
}
PREFIXMAP_SECOND = {
"SCTID__2": "http://snomed.info/id/",
}

EPM = [
{
"prefix": "SCTID",
"prefix_synonyms": ["snomed"],
"uri_prefix": "http://snomed.info/id/",
},
]

converter = chain(
[Converter.from_prefix_map(PREFIXMAP_FIRST), Converter.from_extended_prefix_map(EPM)]
)
self.assertIn("SCTID", converter.prefix_map)
converter = chain(
[Converter.from_prefix_map(PREFIXMAP_SECOND), Converter.from_extended_prefix_map(EPM)]
)
self.assertIn("SCTID", converter.prefix_map)
# Fails here:
with self.assertRaises(ValueError):
chain(
[Converter.from_prefix_map(PREFIXMAP_BOTH), Converter.from_extended_prefix_map(EPM)]
)

# self.assertIn("SCTID", converter.prefix_map)

0 comments on commit 3729508

Please sign in to comment.