28 lines
807 B
Python
28 lines
807 B
Python
import unittest
|
|
|
|
from validation import validate_uid_mapping
|
|
|
|
|
|
class UidMappingTest(unittest.TestCase):
|
|
def test_ambiguous_mapping_requires_ids(self) -> None:
|
|
events = [
|
|
{"title": "Event A"},
|
|
{"title": "Event B"},
|
|
]
|
|
|
|
with self.assertRaises(ValueError) as ctx:
|
|
validate_uid_mapping(events, {"Event A"}, {2})
|
|
|
|
message = str(ctx.exception)
|
|
self.assertIn("Ambivalent UID-mapping", message)
|
|
self.assertIn("events[].id", message)
|
|
|
|
def test_ambiguous_mapping_with_ids_returns_false(self) -> None:
|
|
events = [
|
|
{"id": "log_01", "title": "Event A"},
|
|
{"id": "log_02", "title": "Event B"},
|
|
]
|
|
|
|
allow = validate_uid_mapping(events, {"Event A"}, {2})
|
|
self.assertFalse(allow)
|