Example #1
0
def test_interfaceBuilder():
    @jsii.implements(IInterfaceWithProperties)
    class TInterfaceWithProperties:

        x = "READ_WRITE"

        @property
        def read_only_string(self):
            return "READ_ONLY"

        @property
        def read_write_string(self):
            return self.x

        @read_write_string.setter
        def read_write_string(self, value):
            self.x = value

    obj = TInterfaceWithProperties()
    interact = UsesInterfaceWithProperties(obj)
    assert interact.just_read() == "READ_ONLY"
    assert interact.write_and_read("Hello") == "Hello"
Example #2
0
def test_propertyOverrides_interfaces():
    @jsii.implements(IInterfaceWithProperties)
    class TInterfaceWithProperties:

        x = None

        @property
        def read_only_string(self):
            return "READ_ONLY_STRING"

        @property
        def read_write_string(self):
            return self.x + "?"

        @read_write_string.setter
        def read_write_string(self, value):
            self.x = value + "!"

    obj = TInterfaceWithProperties()
    interact = UsesInterfaceWithProperties(obj)

    assert interact.just_read() == "READ_ONLY_STRING"
    assert interact.write_and_read("Hello") == "Hello!?"