コード例 #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)
コード例 #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"
    }
コード例 #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))
コード例 #4
0
ファイル: test_str.py プロジェクト: jonsource/elastic_connect
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))
コード例 #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('>')
コード例 #6
0
ファイル: test_str.py プロジェクト: jonsource/elastic_connect
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'}"
コード例 #7
0
def test_with_join_serialize_empty():
    wj = WithJoin(value="13")
    assert wj.serialize() == {"id": None, "value": "13", "join": None}