예제 #1
0
def test_live_location_from_graphql_expired():
    data = {
        "description": {
            "text": "Last update 4 Jan"
        },
        "media": None,
        "source": None,
        "style_list": ["message_live_location", "fallback"],
        "title_with_entities": {
            "text": "Location-sharing ended"
        },
        "properties": [],
        "url": "https://www.facebook.com/",
        "deduplication_key": "2254535444791641",
        "action_links": [],
        "messaging_attribution": None,
        "messenger_call_to_actions": [],
        "target": {
            "__typename": "MessageLiveLocation",
            "live_location_id": "2254535444791641",
            "is_expired": True,
            "expiration_time": 1546626345,
            "sender": {
                "id": "100007056224713"
            },
            "coordinate": None,
            "location_title": None,
            "sender_destination": None,
            "stop_reason": "CANCELED",
        },
        "subattachments": [],
    }
    expected = LiveLocationAttachment(
        uid=2254535444791641,
        name="Location-sharing ended",
        expires_at=datetime.datetime(2019,
                                     1,
                                     4,
                                     18,
                                     25,
                                     45,
                                     tzinfo=datetime.timezone.utc),
        is_expired=True,
    )
    expected.url = "https://www.facebook.com/"
    assert expected == LiveLocationAttachment._from_graphql(data)
예제 #2
0
def test_live_location_from_pull():
    data = ...
    assert LiveLocationAttachment(
        ...) == LiveLocationAttachment._from_pull(data)