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)
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" }
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))
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))
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('>')
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'}"
def test_with_join_serialize_empty(): wj = WithJoin(value="13") assert wj.serialize() == {"id": None, "value": "13", "join": None}