示例#1
0
def test_typed_attr_as_int():
    class TestCollection(ResourceCollection):
        foo = types.StringType(required=True)
        bar = types.StringType(required=True)

        def create_resources(self):
            pass

    data = Data("data_type", "data_id")

    tc = TestCollection(foo=data.baz[0], bar=data.baz[1])
    assert tc.foo == "${data.data_type.data_id.baz.0}"
    assert tc.bar == "${data.data_type.data_id.baz.1}"
def test_typed_attr_as_strings():
    class TestCollection(ResourceCollection):
        foo = types.StringType(required=True)
        bar = types.StringType(required=True)

        def create_resources(self):
            pass

    data = Data('data_type', 'data_id')

    tc = TestCollection(foo=data.baz, bar=data.baz["bbq"])
    assert tc.foo == '${data.data_type.data_id.baz}'
    assert tc.bar == '${data.data_type.data_id.baz.bbq}'
def test_typed_attr_recursion():
    class TestCollection(ResourceCollection):
        foo = types.StringType(required=True)
        bar = types.StringType(required=True)

        def create_resources(self):
            pass

    data = Data('data_type', 'data_id')

    tc = TestCollection(foo=data.baz[0].resource_collection.resource,
                        bar=data.baz[1].resource_collection.resource)
    assert tc.foo == '${data.data_type.data_id.baz.0.resource_collection.resource}'
    assert tc.bar == '${data.data_type.data_id.baz.1.resource_collection.resource}'
示例#4
0
def test_typed_item_recursion():
    class TestCollection(ResourceCollection):
        foo = types.StringType(required=True)
        bar = types.StringType(required=True)

        def create_resources(self):
            pass

    data = Data("data_type", "data_id")

    tc = TestCollection(
        foo=data.baz[0]["resource_collection"]["resource"],
        bar=data.baz[1]["resource_collection"]["resource"],
    )
    assert tc.foo == "${data.data_type.data_id.baz.0.resource_collection.resource}"
    assert tc.bar == "${data.data_type.data_id.baz.1.resource_collection.resource}"