コード例 #1
0
def test_to_json_and_back_no_update():
    sub = Subscription("an example", -63939)

    data = sub.to_json()
    new_sub = Subscription.from_json(data)

    assert new_sub.query == sub.query
    assert new_sub.destination == sub.destination
    assert new_sub.latest_update == sub.latest_update
コード例 #2
0
def test_to_json_no_updates():
    sub = Subscription("test query", -12322)

    data = sub.to_json()
    assert "query" in data
    assert data["query"] == "test query"
    assert "destination" in data
    assert data["destination"] == -12322
    assert "latest_update" in data
    assert data["latest_update"] is None
コード例 #3
0
def test_to_json():
    sub = Subscription("test query", -12322)
    sub.latest_update = datetime.datetime(2019, 9, 17, 21, 8, 35)

    data = sub.to_json()
    assert "query" in data
    assert data["query"] == "test query"
    assert "destination" in data
    assert data["destination"] == -12322
    assert "latest_update" in data
    assert data["latest_update"] == "2019-09-17T21:08:35"
コード例 #4
0
def test_to_json_and_back():
    sub = Subscription("something", 3223)
    sub.latest_update = datetime.datetime(2019,
                                          9,
                                          17,
                                          21,
                                          16,
                                          14,
                                          tzinfo=datetime.timezone.utc)

    data = sub.to_json()
    new_sub = Subscription.from_json(data)

    assert new_sub.query == sub.query
    assert new_sub.destination == sub.destination
    assert new_sub.latest_update == sub.latest_update