Exemplo n.º 1
0
def test_with_join_serialize():
    s = Simple(value="12")
    wj = WithJoin(value="13", join=s)
    wj_ser = wj.serialize()

    assert wj_ser["id"] is None
    assert wj_ser["value"] == "13"
    assert isinstance(wj_ser["join"], Simple)
Exemplo n.º 2
0
def test_with_join_serialize_id_simple_id():
    s = Simple(id="2", value="12")
    wj = WithJoin(id="1", value="13", join=s)

    assert wj.serialize() == {"id": "1", "join": "2", "value": "13"}
    assert wj.serialize(depth=1) == {
        "id": "1",
        "join": {
            "id": "2",
            "value": "12"
        },
        "value": "13"
    }
Exemplo n.º 3
0
def test_with_join_id_simple_id_repr():
    s = Simple(id="2", value="12")
    wj = WithJoin(id="1", value="13", join=s)

    assert re.search(
        r"<conftest\.WithJoin object at 0x.*>{'id': '1', 'value': '13', 'join': '2'",
        repr(wj))
Exemplo n.º 4
0
def test_with_join_id_str():
    s = Simple(value="12")
    wj = WithJoin(id="1", value="13", join=s)

    assert re.search(
        r"{'id': '1', 'value': '13', 'join': '<conftest\.Simple object at 0x.*>'}",
        str(wj))
Exemplo n.º 5
0
def test_with_join_repr():
    s = Simple(value="12")
    wj = WithJoin(value="13", join=s)

    assert repr(wj).startswith('<conftest.WithJoin')
    assert repr(wj).endswith('>')
Exemplo n.º 6
0
def test_with_join_id_simple_id_str():
    s = Simple(id="2", value="12")
    wj = WithJoin(id="1", value="13", join=s)

    assert str(wj) == "{'id': '1', 'value': '13', 'join': '2'}"
Exemplo n.º 7
0
def test_with_join_serialize_empty():
    wj = WithJoin(value="13")
    assert wj.serialize() == {"id": None, "value": "13", "join": None}