|
5 | 5 | import numpy as np |
6 | 6 | import pandas as pd |
7 | 7 | import yaml |
8 | | -from curies import Converter, Record |
| 8 | +from curies import Converter, Record, chain |
9 | 9 | from sssom_schema import Mapping as SSSOM_Mapping |
10 | 10 |
|
11 | 11 | from sssom.constants import ( |
@@ -430,3 +430,40 @@ def test_get_dict_from_mapping(self): |
430 | 430 | else: |
431 | 431 | self.assertEqual(value, result_with_mapping_object[key]) |
432 | 432 | 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