Esempio n. 1
0
def test_self_join_repr():
    a = SelfJoin(value="a")
    b = SelfJoin(value="b", join=a)
    a.join = b

    assert repr(a).startswith('<conftest.SelfJoin object at ')
    assert repr(a).endswith('>')
Esempio n. 2
0
def test_self_join_id_id_repr():
    a = SelfJoin(id="2", value="a")
    b = SelfJoin(id="1", value="b", join=a)
    a.join = b

    assert re.search(
        r"<conftest\.SelfJoin object at 0x.*>{'id': '2', 'value': 'a', 'join': '1'}",
        repr(a))
Esempio n. 3
0
def test_self_join_id_str():
    a = SelfJoin(value="a")
    b = SelfJoin(id="1", value="b", join=a)
    a.join = b

    assert re.search(
        r"{'id': '1', 'value': 'b', 'join': '<conftest\.SelfJoin object at 0x.*>'}",
        str(b))
Esempio n. 4
0
def test_self_join_str():
    a = SelfJoin(value="a")
    b = SelfJoin(value="b", join=a)
    a.join = b

    assert re.search(
        r"{'id': None, 'value': 'a', 'join': '<conftest\.SelfJoin object at 0x.*>'}",
        str(a))
def test_self_join_id_id_serialize():
    a = SelfJoin(id="2", value="a")
    b = SelfJoin(id="1", value="b", join=a)
    a.join = b

    b_ser = b.serialize()
    assert b_ser['id'] == '1'
    assert b_ser['value'] == 'b'
    assert b_ser['join'] == '2'

    b_ser = b.serialize(depth=1)
    assert b_ser['id'] == '1'
    assert b_ser['value'] == 'b'
    assert not isinstance(b_ser['join'], SelfJoin)
    assert isinstance(b_ser['join'], dict)
    assert b_ser['join']['id'] == '2'
    assert b_ser['join']['value'] == 'a'
    assert b_ser['join']['join'] == '1'
Esempio n. 6
0
def test_self_join_id_id_str():
    a = SelfJoin(id="2", value="a")
    b = SelfJoin(id="1", value="b", join=a)
    a.join = b

    assert str(a) == "{'id': '2', 'value': 'a', 'join': '1'}"