コード例 #1
0
def test_graphql_to_attachment_image2():
    data = {
        "__typename": "MessageAnimatedImage",
        "attribution_app": None,
        "attribution_metadata": None,
        "filename": "gif-1234",
        "animated_image": {
            "uri": "https://cdn.fbsbx.com/v/1.gif",
            "height": 128,
            "width": 128,
        },
        "legacy_attachment_id": "1234",
        "preview_image": {
            "uri": "https://cdn.fbsbx.com/v/1.gif",
            "height": 128,
            "width": 128,
        },
        "original_dimensions": {"x": 128, "y": 128},
    }
    assert ImageAttachment(
        uid="1234",
        original_extension="gif",
        width=None,
        height=None,
        is_animated=True,
        previews={
            fbchat.Image(url="https://cdn.fbsbx.com/v/1.gif", width=128, height=128)
        },
    ) == graphql_to_attachment(data)
コード例 #2
0
ファイル: test_file.py プロジェクト: ramshresh/fbchat
def test_imageattachment_from_list():
    data = {
        "__typename": "MessageImage",
        "id": "bWVzc2...",
        "legacy_attachment_id": "1234",
        "image": {
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/s261x260/1.jpg"
        },
        "image1": {
            "height": 463,
            "width": 960,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/2.jpg",
        },
        "image2": {
            "height": 988,
            "width": 2048,
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/s2048x2048/3.jpg",
        },
        "original_dimensions": {
            "x": 2833,
            "y": 1367
        },
        "photo_encodings": [],
    }
    assert ImageAttachment(
        id="1234",
        width=2833,
        height=1367,
        previews={
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/s261x260/1.jpg"),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/2.jpg",
                width=960,
                height=463,
            ),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/s2048x2048/3.jpg",
                width=2048,
                height=988,
            ),
        },
    ) == ImageAttachment._from_list({"node": data})
コード例 #3
0
ファイル: test_file.py プロジェクト: ramshresh/fbchat
def test_graphql_to_attachment_image1():
    data = {
        "__typename": "MessageImage",
        "attribution_app": None,
        "attribution_metadata": None,
        "filename": "image-1234",
        "preview": {
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/1.png",
            "height": 128,
            "width": 128,
        },
        "large_preview": {
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/1.png",
            "height": 128,
            "width": 128,
        },
        "thumbnail": {
            "uri": "https://scontent-arn2-1.xx.fbcdn.net/v/p50x50/2.png"
        },
        "photo_encodings": [],
        "legacy_attachment_id": "1234",
        "original_dimensions": {
            "x": 128,
            "y": 128
        },
        "original_extension": "png",
        "render_as_sticker": False,
        "blurred_image_uri": None,
    }
    assert ImageAttachment(
        id="1234",
        original_extension="png",
        width=None,
        height=None,
        is_animated=False,
        previews={
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/p50x50/2.png"),
            fbchat.Image(
                url="https://scontent-arn2-1.xx.fbcdn.net/v/1.png",
                width=128,
                height=128,
            ),
        },
    ) == graphql_to_attachment(data)