示例#1
0
def test_collection_mid_uplink_zaa():
    """
    Same as for ``aa``, but with different naming
    """

    logger.setLevel(logging.DEBUG)

    class A:
        b = Uplink()

    class B:
        zaa = Collection(A)
        c = Uplink()

    class C:
        bb = Collection(B)

    B.c.linksTo(C, C.bb)
    A.b.linksTo(B, B.zaa)

    builder = Builder(B).withA(HavingIn(B.zaa, 1),
                               HavingIn(C.bb, 1))

    c = builder.build().c

    assert len(c.bb) == 2
    assert len(c.bb[0].zaa) == 2
    assert len(c.bb[1].zaa) == 2
示例#2
0
def test_reused_keys_mod():
    builder = Builder(ReusingKey).withA(InstanceModifier(A).thatSets(b='ololo'))
    rk1 = builder.build()
    rk2 = builder.build()
    rk3 = builder.withA(InstanceModifier(A).thatSets(b='hahaha')).build()

    assert isinstance(rk1.a, A)
    assert isinstance(rk2.a, A)
    assert isinstance(rk3.a, A)
    assert rk1.a == rk2.a
    assert rk1.b == rk2.b
    assert rk1.a != rk3.a
示例#3
0
def test_reused_keys_mod():
    builder = Builder(ReusingKey).withA(
        InstanceModifier(A).thatSets(b='ololo'))
    rk1 = builder.build()
    rk2 = builder.build()
    rk3 = builder.withA(InstanceModifier(A).thatSets(b='hahaha')).build()

    assert isinstance(rk1.a, A)
    assert isinstance(rk2.a, A)
    assert isinstance(rk3.a, A)
    assert rk1.a == rk2.a
    assert rk1.b == rk2.b
    assert rk1.a != rk3.a