Move ThreadLocation, ActiveStatus and Image to _models/ folder

This commit is contained in:
Mads Marquart
2020-01-23 15:15:09 +01:00
parent c71c1d37c2
commit 4015bed474
20 changed files with 146 additions and 136 deletions

View File

@@ -1,7 +1,7 @@
import pytest
import datetime
import fbchat
from fbchat import UnsentMessage, ShareAttachment
from fbchat import Image, UnsentMessage, ShareAttachment
from fbchat._models._message import graphql_to_extensible_attachment
@@ -122,7 +122,7 @@ def test_share_from_graphql_link_with_image():
" Share photos and videos, send messages and get updates."
),
source=None,
image=fbchat.Image(
image=Image(
url="https://www.facebook.com/rsrc.php/v3/x.png", width=325, height=325
),
original_image_url="https://www.facebook.com/rsrc.php/v3/x.png",
@@ -184,7 +184,7 @@ def test_share_from_graphql_video():
" Subscribe to the official Rick As..."
),
source="youtube.com",
image=fbchat.Image(
image=Image(
url="https://external-arn2-1.xx.fbcdn.net/safe_image.php?d=xyz123"
"&w=960&h=540&url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FdQw4w9WgXcQ"
"%2Fmaxresdefault.jpg&sx=0&sy=0&sw=1280&sh=720&_nc_hash=abc123",
@@ -307,7 +307,7 @@ def test_share_with_image_subattachment():
title="",
description="Abc",
source="Def",
image=fbchat.Image(
image=Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t1.0-9/1.jpg",
width=720,
height=960,
@@ -435,7 +435,7 @@ def test_share_with_video_subattachment():
title="",
description="Abc",
source="Def",
image=fbchat.Image(
image=Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.5256-10/p180x540/1.jpg",
width=960,
height=540,
@@ -447,7 +447,7 @@ def test_share_with_video_subattachment():
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(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.5256-10/p180x540/1.jpg",
width=960,
height=540,

View File

@@ -1,6 +1,12 @@
import datetime
import fbchat
from fbchat import FileAttachment, AudioAttachment, ImageAttachment, VideoAttachment
from fbchat import (
Image,
FileAttachment,
AudioAttachment,
ImageAttachment,
VideoAttachment,
)
from fbchat._models._file import graphql_to_attachment, graphql_to_subattachment
@@ -28,13 +34,13 @@ def test_imageattachment_from_list():
width=2833,
height=1367,
previews={
fbchat.Image(url="https://scontent-arn2-1.xx.fbcdn.net/v/s261x260/1.jpg"),
fbchat.Image(
Image(url="https://scontent-arn2-1.xx.fbcdn.net/v/s261x260/1.jpg"),
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/2.jpg",
width=960,
height=463,
),
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/s2048x2048/3.jpg",
width=2048,
height=988,
@@ -68,15 +74,15 @@ def test_videoattachment_from_list():
width=640,
height=368,
previews={
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/p261x260/1.jpg"
),
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/2.jpg",
width=640,
height=368,
),
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.3394-10/3.jpg",
width=640,
height=368,
@@ -169,8 +175,8 @@ def test_graphql_to_attachment_image1():
height=None,
is_animated=False,
previews={
fbchat.Image(url="https://scontent-arn2-1.xx.fbcdn.net/v/p50x50/2.png"),
fbchat.Image(
Image(url="https://scontent-arn2-1.xx.fbcdn.net/v/p50x50/2.png"),
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/1.png",
width=128,
height=128,
@@ -204,9 +210,7 @@ def test_graphql_to_attachment_image2():
width=None,
height=None,
is_animated=True,
previews={
fbchat.Image(url="https://cdn.fbsbx.com/v/1.gif", width=128, height=128)
},
previews={Image(url="https://cdn.fbsbx.com/v/1.gif", width=128, height=128)},
) == graphql_to_attachment(data)
@@ -244,17 +248,17 @@ def test_graphql_to_attachment_video():
duration=datetime.timedelta(seconds=6),
preview_url="https://video-arn2-1.xx.fbcdn.net/v/video-4321.mp4",
previews={
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/s168x128/1.jpg",
width=168,
height=96,
),
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/p261x260/3.jpg",
width=452,
height=260,
),
fbchat.Image(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/2.jpg",
width=640,
height=368,
@@ -345,7 +349,7 @@ def test_graphql_to_subattachment_video():
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(
Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/t15.5256-10/p180x540/1.jpg",
width=960,
height=540,

View File

@@ -1,7 +1,7 @@
import pytest
import datetime
import fbchat
from fbchat import LocationAttachment, LiveLocationAttachment
from fbchat import Image, LocationAttachment, LiveLocationAttachment
def test_location_attachment_from_graphql():
@@ -38,7 +38,7 @@ def test_location_attachment_from_graphql():
id=400828513928715,
latitude=55.4,
longitude=12.4322,
image=fbchat.Image(
image=Image(
url="https://external-arn2-1.xx.fbcdn.net/static_map.php?v=1020&osm_provider=2&size=545x280&zoom=15&markers=55.40000000%2C12.43220000&language=en",
width=545,
height=280,

View File

@@ -1,6 +1,6 @@
import pytest
import fbchat
from fbchat import Sticker
from fbchat import Image, Sticker
def test_from_graphql_none():
@@ -20,7 +20,7 @@ def test_from_graphql_normal():
frames_per_col=1,
frame_count=1,
frame_rate=83,
image=fbchat.Image(
image=Image(
url="https://scontent-arn2-1.xx.fbcdn.net/v/redacted.png",
width=274,
height=274,
@@ -57,7 +57,7 @@ def test_from_graphql_animated():
frames_per_col=2,
frame_count=4,
frame_rate=142,
image=fbchat.Image(
image=Image(
url="https://scontent-arn2-1.fbcdn.net/v/redacted1.png",
width=240,
height=293,