Skip to content

Commit ee4a574

Browse files
committed
test(search): ✅ update tests for search pages
1 parent 90841b6 commit ee4a574

2 files changed

Lines changed: 17 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":"108824017345866","name":"Facebook","link":"https://www.facebook.com/108824017345866"},{"id":"20531316728","name":"Facebook App","link":"https://www.facebook.com/20531316728"},{"id":"185150934832623","name":"Facebook","link":"https://www.facebook.com/185150934832623"},{"id":"126320487382225","name":"T.Rextasy (Marc Bolan Tribute) Official Facebook Page","link":"https://www.facebook.com/126320487382225"},{"id":"196822497403119","name":"Facebook Direct Support","link":"https://www.facebook.com/196822497403119"}],"paging":{"cursors":{"before":"before","after":"after"},"next":"https://graph.facebook.com/v12.0/pages/search?access_token=access_token&pretty=0&fields=id%2Cname%2Clocation%2Clink&q=facebook&limit=5&after=after","previous":"https://graph.facebook.com/v12.0/pages/search?access_token=access_token&pretty=0&fields=id%2Cname%2Clocation%2Clink&q=facebook&limit=5&before=before"}}

tests/facebook/test_page.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,19 @@ def test_get_videos(helpers, fb_api):
250250
object_id=pid, count=2, limit=3, return_json=True
251251
)
252252
assert len(videos_json["data"]) == 2
253+
254+
255+
def test_search_pages(helpers, fb_api):
256+
with responses.RequestsMock() as m:
257+
m.add(
258+
method=responses.GET,
259+
url=f"https://graph.facebook.com/{fb_api.version}/pages/search",
260+
json=helpers.load_json("testdata/facebook/apidata/pages/search_pages.json"),
261+
)
262+
263+
pages = fb_api.page.search(q="facebook", count=5, limit=5)
264+
assert len(pages.data) == 5
265+
assert pages.data[0].id == "108824017345866"
266+
267+
pages_json = fb_api.page.search(q="facebook", count=4, return_json=True)
268+
assert len(pages_json["data"]) == 4

0 commit comments

Comments
 (0)