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
def test_from_json_no_update(): data = { "query": "example query", "destination": 17839, "latest_update": None } sub = Subscription.from_json(data) assert sub.query == "example query" assert sub.destination == 17839 assert sub.latest_update is None
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
def test_from_json(): data = { "query": "example query", "destination": 17839, "latest_update": "2019-09-17T21:14:07Z" } sub = Subscription.from_json(data) assert sub.query == "example query" assert sub.destination == 17839 assert sub.latest_update == datetime.datetime(2019, 9, 17, 21, 14, 7, tzinfo=datetime.timezone.utc)