Esempio n. 1
0
def test_videoattachment_from_list():
    data = {
        "__typename": "MessageVideo",
        "id": "bWVzc2...",
        "legacy_attachment_id": "1234",
        "image": {
            "uri":
            "https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/p261x260/1.jpg"
        },
        "image1": {
            "height": 368,
            "width": 640,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/2.jpg",
        },
        "image2": {
            "height": 368,
            "width": 640,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/3.jpg",
        },
        "original_dimensions": {
            "x": 640,
            "y": 368
        },
    }
    assert VideoAttachment(
        id="1234",
        width=640,
        height=368,
        previews={
            fbchat.Image(
                url=
                "https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/p261x260/1.jpg"
            ),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/2.jpg",
                width=640,
                height=368,
            ),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/3.jpg",
                width=640,
                height=368,
            ),
        },
    ) == VideoAttachment._from_list({"node": data})
Esempio n. 2
0
def test_graphql_to_attachment_video():
    data = {
        "__typename": "MessageVideo",
        "attribution_app": None,
        "attribution_metadata": None,
        "filename": "video-4321.mp4",
        "playable_url": "https://video-arn2-1.xx.fbcdn.net/v/video-4321.mp4",
        "chat_image": {
            "height": 96,
            "width": 168,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/s168x128/1.jpg",
        },
        "legacy_attachment_id": "1234",
        "video_type": "FILE_ATTACHMENT",
        "original_dimensions": {
            "x": 640,
            "y": 368
        },
        "playable_duration_in_ms": 6000,
        "large_image": {
            "height": 368,
            "width": 640,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/2.jpg",
        },
        "inbox_image": {
            "height": 260,
            "width": 452,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/p261x260/3.jpg",
        },
    }
    assert VideoAttachment(
        id="1234",
        width=None,
        height=None,
        duration=datetime.timedelta(seconds=6),
        preview_url="https://video-arn2-1.xx.fbcdn.net/v/video-4321.mp4",
        previews={
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/s168x128/1.jpg",
                width=168,
                height=96,
            ),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/p261x260/3.jpg",
                width=452,
                height=260,
            ),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/2.jpg",
                width=640,
                height=368,
            ),
        },
    ) == graphql_to_attachment(data)
Esempio n. 3
0
def test_graphql_to_subattachment_video():
    data = {
        "description": None,
        "media": {
            "animated_image": None,
            "image": {
                "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/t15.5256-10/p180x540/1.jpg",
                "height": 540,
                "width": 960,
            },
            "playable_duration_in_ms": 24469,
            "is_playable": True,
            "playable_url": "https://video-arn2-1.xx.fbcdn.net/v/t42.9040-2/vid.mp4",
        },
        "source": None,
        "style_list": [
            "video_autoplay",
            "video_inline",
            "video",
            "games_app",
            "fallback",
        ],
        "title_with_entities": {"text": ""},
        "properties": [
            {"key": "can_autoplay_result", "value": {"text": "ugc_default_allowed"}}
        ],
        "url": "https://www.facebook.com/some-username/videos/1234/",
        "deduplication_key": "ddb7...",
        "action_links": [],
        "messaging_attribution": None,
        "messenger_call_to_actions": [],
        "xma_layout_info": None,
        "target": {
            "__typename": "Video",
            "video_id": "1234",
            "video_messenger_cta_payload": None,
        },
    }
    assert VideoAttachment(
        uid="1234",
        duration=datetime.timedelta(seconds=24, microseconds=469000),
        preview_url="https://video-arn2-1.xx.fbcdn.net/v/t42.9040-2/vid.mp4",
        previews={
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.5256-10/p180x540/1.jpg",
                width=960,
                height=540,
            )
        },
    ) == graphql_to_subattachment(data)