Skip to content

Commit aa2dd3b

Browse files
committed
feat(test): ✅ update tests for event
1 parent 1a1794d commit aa2dd3b

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id":"5971414199599456","name":"Python Go Go Go","description":"Talk the descprition for python","start_time":"2021-07-23T21:00:00+0800","end_time":"2021-07-27T00:00:00+0800","place":{"name":"Washington Place Dasmarinas - CVRI","location":{"city":"Dasmariñas","country":"Philippines","latitude":14.274640893666,"longitude":120.96776474724,"street":"Brgy Malinta","zip":"4114"},"id":"534105339994132"},"event_times":[{"id":"5971414202932789","start_time":"2021-07-26T21:00:00+0800","end_time":"2021-07-27T00:00:00+0800","ticket_uri":"https://www.baidu.com/"},{"id":"5971414216266121","start_time":"2021-07-25T21:00:00+0800","end_time":"2021-07-26T00:00:00+0800","ticket_uri":"https://www.baidu.com/"},{"id":"5971414206266122","start_time":"2021-07-24T21:00:00+0800","end_time":"2021-07-25T00:00:00+0800","ticket_uri":"https://www.baidu.com/"},{"id":"5971414212932788","start_time":"2021-07-23T21:00:00+0800","end_time":"2021-07-24T00:00:00+0800","ticket_uri":"https://www.baidu.com/"}]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"5971414199599456":{"id":"5971414199599456","name":"Python Go Go Go","description":"Talk the descprition for python","start_time":"2021-07-23T21:00:00+0800","end_time":"2021-07-27T00:00:00+0800","place":{"name":"Washington Place Dasmarinas - CVRI","location":{"city":"Dasmariñas","country":"Philippines","latitude":14.274640893666,"longitude":120.96776474724,"street":"Brgy Malinta","zip":"4114"},"id":"534105339994132"},"event_times":[{"id":"5971414202932789","start_time":"2021-07-26T21:00:00+0800","end_time":"2021-07-27T00:00:00+0800","ticket_uri":"https://www.baidu.com/"},{"id":"5971414216266121","start_time":"2021-07-25T21:00:00+0800","end_time":"2021-07-26T00:00:00+0800","ticket_uri":"https://www.baidu.com/"},{"id":"5971414206266122","start_time":"2021-07-24T21:00:00+0800","end_time":"2021-07-25T00:00:00+0800","ticket_uri":"https://www.baidu.com/"},{"id":"5971414212932788","start_time":"2021-07-23T21:00:00+0800","end_time":"2021-07-24T00:00:00+0800","ticket_uri":"https://www.baidu.com/"}]},"512411373205445":{"id":"512411373205445","name":"AAAAAA","description":"A desciption to new","start_time":"2021-07-23T20:00:00-0500","end_time":"2021-07-23T23:00:00-0500","place":{"name":"H. Matamoros, Tamaulipas"}}}

tests/facebook/test_event.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
Tests for event.
3+
"""
4+
5+
import responses
6+
7+
8+
def test_get_info(helpers, fb_api):
9+
evt_id = "5971414199599456"
10+
11+
with responses.RequestsMock() as m:
12+
m.add(
13+
method=responses.GET,
14+
url=f"https://graph.facebook.com/{fb_api.version}/{evt_id}",
15+
json=helpers.load_json("testdata/facebook/apidata/events/event_info.json"),
16+
)
17+
18+
event = fb_api.event.get_info(event_id=evt_id)
19+
assert event.id == evt_id
20+
assert event.start_time == "2021-07-23T21:00:00+0800"
21+
22+
event_json = fb_api.event.get_info(
23+
event_id=evt_id,
24+
fields="id,name,description,start_time,end_time,place,event_times",
25+
return_json=True,
26+
)
27+
assert event_json["id"] == evt_id
28+
29+
30+
def test_get_batch(helpers, fb_api):
31+
et_ids = ["5971414199599456", "512411373205445"]
32+
33+
with responses.RequestsMock() as m:
34+
m.add(
35+
method=responses.GET,
36+
url=f"https://graph.facebook.com/{fb_api.version}",
37+
json=helpers.load_json("testdata/facebook/apidata/events/events_info.json"),
38+
)
39+
40+
events = fb_api.event.get_batch(ids=et_ids)
41+
assert events[et_ids[0]].id == et_ids[0]
42+
43+
events_json = fb_api.event.get_batch(
44+
ids=et_ids,
45+
fields="id,name,description,start_time,end_time,place,event_times",
46+
return_json=True,
47+
)
48+
assert events_json[et_ids[1]]["id"] == et_ids[1]

0 commit comments

Comments
 (0)