def test_correctly_handling_struct_unions(): a0 = StructA(required_string='Present!', optional_string='Bazinga!') a1 = StructA(required_string='Present!', optional_number=1337) b0 = StructB(required_string='Present!', optional_boolean=True) b1 = StructB(required_string='Present!', optional_struct_a=a1) assert StructUnionConsumer.is_struct_a(a0) assert StructUnionConsumer.is_struct_a(a1) assert not StructUnionConsumer.is_struct_a(b0) assert not StructUnionConsumer.is_struct_a(b1) assert not StructUnionConsumer.is_struct_b(a0) assert not StructUnionConsumer.is_struct_b(a1) assert StructUnionConsumer.is_struct_b(b0) assert StructUnionConsumer.is_struct_b(b1)
def test_structs_are_undecorated_on_the_way_to_kernel(): json = JsonFormatter.stringify( StructB(required_string='Bazinga!', optional_boolean=False)) assert loads(json) == { 'requiredString': 'Bazinga!', 'optionalBoolean': False }
def test_structs_are_undecorated_on_the_way_to_kernel(): json = JsonFormatter.stringify( StructB(required_string="Bazinga!", optional_boolean=False)) assert loads(json) == { "requiredString": "Bazinga!", "optionalBoolean": False }
def test_pure_interfaces_can_be_used_transparently_when_added_to_jsii_type(): expected = StructB(required_string="It's Britney b**ch!") @jsii.implements(IStructReturningDelegate) class ImplementsAdditionalInterface(AllTypes): def return_struct(self): return expected delegate = ImplementsAdditionalInterface() consumer = ConsumePureInterface(delegate) assert consumer.work_it_baby() == expected
def test_pure_interfaces_can_be_used_transparently(): expected = StructB(required_string="It's Britney b**ch!") @jsii.implements(IStructReturningDelegate) class StructReturningDelegate: def return_struct(self): return expected delegate = StructReturningDelegate() consumer = ConsumePureInterface(delegate) assert consumer.work_it_baby() == expected