Exemplo n.º 1
0
def test_encoder_with_datamodel_element():
    encoder = BfJsonEncoder()

    iface = Interface(hostname='node', interface="iface")
    assert encoder.default(iface) == iface.dict()

    assert json.loads(
        json.dumps({"name": {"nested": iface}},
                   cls=BfJsonEncoder)) == {"name": {"nested": iface.dict()}}
Exemplo n.º 2
0
def test_json_serialization():
    i = Interface(hostname='host', interface='iface')
    # Load into dict from json to ignore key ordering
    assert json.loads(BfJsonEncoder().encode(i)) == json.loads(
        json.dumps(i.dict()))
def test_json_serialization():
    i = Interface(hostname='host', interface='iface')
    assert BfJsonEncoder().encode(i) == json.dumps(i.dict())