Skip to content

Commit

Permalink
feat(dm): ✅ update tests for block user dm
Browse files Browse the repository at this point in the history
  • Loading branch information
MerleLiuKun committed Oct 29, 2024
1 parent 402bd8c commit 4eb0311
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 0 additions & 2 deletions pytwitter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,6 @@ def block_user_dm(self, target_user_id: str):
data = self._parse_response(resp)
return data


def unblock_user_dm(self, target_user_id: str):
"""
Allows the authenticated user to unblock direct messages (DMs) from the target user.
Expand All @@ -2062,7 +2061,6 @@ def unblock_user_dm(self, target_user_id: str):
data = self._parse_response(resp)
return data


def get_user_muting(
self,
user_id: str,
Expand Down
21 changes: 21 additions & 0 deletions tests/apis/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ def test_block_and_unblock_user(api_with_user):
assert not resp["data"]["blocking"]


@responses.activate
def test_block_and_unblock_user_dm(api_with_user):
target_user_id = "123456"

responses.add(
method=responses.POST,
url=f"https://api.twitter.com/2/users/{target_user_id}/dm/block",
json={"data": {"blocked": True}},
)
resp = api_with_user.block_user_dm(target_user_id=target_user_id)
assert resp["data"]["blocked"]

responses.add(
method=responses.POST,
url=f"https://api.twitter.com/2/users/{target_user_id}/dm/unblock",
json={"data": {"blocked": False}},
)
resp = api_with_user.unblock_user_dm(target_user_id=target_user_id)
assert not resp["data"]["blocked"]


@responses.activate
def test_get_blocking_users(api_with_user, helpers):
users_data = helpers.load_json_data(
Expand Down

0 comments on commit 4eb0311

Please sign in to comment.