import unittest

from codec import upgrade_payload


class HoldoutCodecTests(unittest.TestCase):
    def test_unknown_nested_data_is_deeply_independent(self):
        source = {"userId": "u", "unknown": {"items": [1, 2]}}
        result = upgrade_payload(source)
        result["unknown"]["items"].append(3)
        self.assertEqual(source["unknown"]["items"], [1, 2])

    def test_conflict_is_rejected_even_when_values_match(self):
        with self.assertRaises(ValueError):
            upgrade_payload({"userId": "u", "user_id": "u"})
