Skip to content

Commit 534f2b8

Browse files
committed
test(dm): ✅ update tests for send events
1 parent 08841b2 commit 534f2b8

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"data": {
3+
"dm_conversation_id": "1346889436626259968",
4+
"dm_event_id": "128341038123"
5+
}
6+
}

tests/apis/test_dm_events.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,55 @@ def test_get_dm_events(api_with_user, helpers):
5858
dm_event_fields="id,text,event_type,dm_conversation_id,created_at,sender_id,attachments,participant_ids,referenced_tweets",
5959
)
6060
assert resp.data[0].dm_conversation_id == "1585094756761149440"
61+
62+
63+
@responses.activate
64+
def test_create_message_to_participant(api_with_user, helpers):
65+
data = helpers.load_json_data("testdata/apis/dm_events/events_create.json")
66+
participant_id = "1234567"
67+
68+
responses.add(
69+
responses.POST,
70+
url=f"https://api.twitter.com/2/dm_conversations/with/{participant_id}/messages",
71+
json=data,
72+
)
73+
resp = api_with_user.create_message_to_participant(
74+
participant_id=participant_id,
75+
text="hello",
76+
attachments=[{"media_id": "1455952740635586573"}],
77+
)
78+
assert resp.dm_conversation_id == "1346889436626259968"
79+
80+
81+
@responses.activate
82+
def test_create_message_to_conversation(api_with_user, helpers):
83+
data = helpers.load_json_data("testdata/apis/dm_events/events_create.json")
84+
dm_conversation_id = "7654321"
85+
86+
responses.add(
87+
responses.POST,
88+
url=f"https://api.twitter.com/2/dm_conversations/{dm_conversation_id}/messages",
89+
json=data,
90+
)
91+
resp = api_with_user.create_message_to_conversation(
92+
dm_conversation_id=dm_conversation_id,
93+
text="hello",
94+
attachments=[{"media_id": "1455952740635586573"}],
95+
)
96+
assert resp.dm_conversation_id == "1346889436626259968"
97+
98+
99+
@responses.activate
100+
def test_create_conversation(api_with_user, helpers):
101+
data = helpers.load_json_data("testdata/apis/dm_events/events_create.json")
102+
responses.add(
103+
responses.POST,
104+
url=f"https://api.twitter.com/2/dm_conversations",
105+
json=data,
106+
)
107+
resp = api_with_user.create_conversation(
108+
conversation_type="group",
109+
message={"text": "hello"},
110+
participant_ids=["1234567", "7654321"],
111+
)
112+
assert resp.dm_conversation_id == "1346889436626259968"

0 commit comments

Comments
 (0)