def test_extend_and_merge(self) -> None: extends_and_merges = Struct(age=32, label='green', items=[5], extends=Struct(age=42, other=True, knobs={'a': True}, items=[1, 2]), merges=[ Struct(age=52, other=False, items=[1, 3, 4], knobs={ 'a': False, 'b': True }), Struct(items=[2]) ]) self.assertEqual( Struct(age=32, label='green', other=True, items=[5, 1, 3, 4, 2], knobs={ 'a': False, 'b': True }), extends_and_merges.create())
def test_merge(self) -> None: merges = Struct(age=32, items=[3], knobs={'b': False}, merges=[ Struct(age=42, other=True, items=[1, 2], knobs={ 'a': True, 'b': True }) ]) # Merging is lazy, so we don't pick up the other field yet. self.assertNotEqual( Struct(age=32, items=[3, 1, 2], knobs={ 'a': True, 'b': True }, other=True), merges) # But we do pick it up now. self.assertEqual( Struct(age=32, items=[3, 1, 2], knobs={ 'a': True, 'b': True }, other=True), merges.create())
def test_extend_and_merge(self) -> None: extends_and_merges = Struct( age=32, label="green", items=[5], extends=Struct(age=42, other=True, knobs={"a": True}, items=[1, 2]), merges=[ Struct(age=52, other=False, items=[1, 3, 4], knobs={ "a": False, "b": True }), Struct(items=[2]), ], ) self.assertEqual( Struct( age=32, label="green", other=True, items=[5, 1, 3, 4, 2], knobs={ "a": False, "b": True }, ), extends_and_merges.create(), )
def test_extend(self): extends = Struct(age=32, label='green', items=[], extends=Struct(age=42, other=True, items=[1, 2])) # Extension is lazy, so we don't pick up the other field yet. self.assertNotEqual(Struct(age=32, label='green', items=[], other=True), extends) # But we do pick it up now. self.assertEqual(Struct(age=32, label='green', items=[], other=True), extends.create())
def test_extend_and_merge(self): extends_and_merges = Struct(age=32, label='green', items=[5], extends=Struct(age=42, other=True, knobs={'a': True}, items=[1, 2]), merges=[Struct(age=52, other=False, items=[1, 3, 4], knobs={'a': False, 'b': True}), Struct(items=[2])]) self.assertEqual(Struct(age=32, label='green', other=True, items=[5, 1, 3, 4, 2], knobs={'a': False, 'b': True}), extends_and_merges.create())
def test_merge(self): merges = Struct(age=32, items=[3], knobs={'b': False}, merges=[Struct(age=42, other=True, items=[1, 2], knobs={'a': True, 'b': True})]) # Merging is lazy, so we don't pick up the other field yet. self.assertNotEqual(Struct(age=32, items=[3, 1, 2], knobs={'a': True, 'b': True}, other=True), merges) # But we do pick it up now. self.assertEqual(Struct(age=32, items=[3, 1, 2], knobs={'a': True, 'b': True}, other=True), merges.create())