Skip to content

Commit 5984ba8

Browse files
committed
test(tests): ✅ update tests for photos
1 parent 76b8dbd commit 5984ba8

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":[{"id":"336596487901950","created_time":"2021-05-07T16:18:42+0000","updated_time":"2021-05-07T17:19:12+0000","link":"https://www.facebook.com/facebook/photos/a.108824087345859/336596487901950/?type=3"},{"id":"200337158194551","created_time":"2020-09-15T16:00:32+0000","updated_time":"2021-05-07T16:18:32+0000","link":"https://www.facebook.com/facebook/photos/a.108824087345859/200337158194551/?type=3"}],"paging":{"cursors":{"before":"before","after":"after"},"next":"https://graph.facebook.com/v11.0/108824017345866/photos?access_token=access_token&pretty=0&fields=id%2Ccreated_time%2Cname%2Cupdated_time%2Clink&limit=2&after=after"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":[{"id":"166370841591183","created_time":"2020-06-01T05:07:38+0000","updated_time":"2020-09-15T16:00:29+0000","link":"https://www.facebook.com/facebook/photos/a.108824087345859/166370841591183/?type=3"},{"id":"124830722411862","created_time":"2020-02-24T20:17:47+0000","updated_time":"2020-06-01T05:07:34+0000","link":"https://www.facebook.com/facebook/photos/a.108824087345859/124830722411862/?type=3"}],"paging":{"cursors":{"before":"before","after":"after"},"previous":"https://graph.facebook.com/v4.0/108824017345866/photos?access_token=access_token&pretty=0&fields=id%2Ccreated_time%2Cname%2Cupdated_time%2Clink&limit=2&before=before"}}

tests/facebook/test_page.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,28 @@ def test_get_albums(helpers, fb_api):
171171
object_id=pid, count=3, limit=3, return_json=True
172172
)
173173
assert len(albums_json) == 3
174+
175+
176+
def test_get_photos(helpers, fb_api):
177+
pid = "108824017345866"
178+
179+
with responses.RequestsMock() as m:
180+
m.add(
181+
method=responses.GET,
182+
url=f"https://graph.facebook.com/{fb_api.version}/{pid}/photos",
183+
json=helpers.load_json("testdata/facebook/apidata/photos/photos_p1.json"),
184+
)
185+
m.add(
186+
method=responses.GET,
187+
url=f"https://graph.facebook.com/{fb_api.version}/{pid}/photos",
188+
json=helpers.load_json("testdata/facebook/apidata/photos/photos_p2.json"),
189+
)
190+
191+
photos, _ = fb_api.page.get_photos(object_id=pid, count=None, limit=2)
192+
assert len(photos) == 4
193+
assert photos[0].id == "336596487901950"
194+
195+
photos_json, _ = fb_api.page.get_photos(
196+
object_id=pid, count=2, limit=2, return_json=True
197+
)
198+
assert len(photos_json) == 2

0 commit comments

Comments
 (0)