fix: test

This commit is contained in:
abhi1992002
2024-11-26 13:01:23 +05:30
parent e9e7f28cad
commit 01185c55a1
20 changed files with 213 additions and 298 deletions

View File

@@ -49,6 +49,7 @@ class TwitterUnfollowListBlock(Block):
test_output=[
("success", True),
],
test_mock={"unfollow_list": lambda *args, **kwargs: True},
)
@staticmethod
@@ -107,7 +108,10 @@ class TwitterFollowListBlock(Block):
output_schema=TwitterFollowListBlock.Output,
test_input={"list_id": "123456789", "credentials": TEST_CREDENTIALS_INPUT},
test_credentials=TEST_CREDENTIALS,
test_output=[("success", True), ("error", None)],
test_output=[
("success", True),
],
test_mock={"follow_list": lambda *args, **kwargs: True},
)
@staticmethod

View File

@@ -78,14 +78,14 @@ class TwitterGetListBlock(Block):
("owner_id", "2244994945"),
("owner_username", "TwitterAPI"),
("data", {"id": "84839422", "name": "Official Twitter Accounts"}),
("included", {}),
("meta", {}),
("error", ""),
],
test_mock={
"get_list": lambda *args, **kwargs: (
{"id": "84839422", "name": "Official Twitter Accounts"},
{},
{},
"2244994945",
"TwitterAPI",
)
},
)
@@ -232,26 +232,11 @@ class TwitterGetOwnedListsBlock(Block):
test_output=[
("list_ids", ["84839422"]),
("list_names", ["Official Twitter Accounts"]),
("next_token", None),
(
"data",
{
"owned_lists": [
{"id": "84839422", "name": "Official Twitter Accounts"}
]
},
),
("included", {}),
("meta", {}),
("error", ""),
("data", [{"id": "84839422", "name": "Official Twitter Accounts"}]),
],
test_mock={
"get_owned_lists": lambda *args, **kwargs: (
{
"owned_lists": [
{"id": "84839422", "name": "Official Twitter Accounts"}
]
},
[{"id": "84839422", "name": "Official Twitter Accounts"}],
{},
{},
["84839422"],

View File

@@ -256,9 +256,6 @@ class TwitterGetListMembersBlock(Block):
{"id": "67890", "username": "testuser2"},
],
),
("included", {}),
("meta", {"next_token": "next_token_value"}),
("next_token", "next_token_value"),
],
test_mock={
"get_list_members": lambda *args, **kwargs: (
@@ -269,8 +266,8 @@ class TwitterGetListMembersBlock(Block):
{"id": "67890", "username": "testuser2"},
],
{},
{"next_token": "next_token_value"},
"next_token_value",
{},
None,
)
},
)
@@ -417,7 +414,7 @@ class TwitterGetListMembershipsBlock(Block):
test_input={
"user_id": "123456789",
"max_results": 50,
"pagination_token": None,
"pagination_token": "",
"credentials": TEST_CREDENTIALS_INPUT,
"expansions": [],
"list_fields": [],
@@ -426,16 +423,13 @@ class TwitterGetListMembershipsBlock(Block):
test_credentials=TEST_CREDENTIALS,
test_output=[
("list_ids", ["84839422"]),
("data", {"lists": [{"id": "84839422"}]}),
("included", {}),
("meta", {"next_token": None}),
("next_token", None),
("data", [{"id": "84839422"}]),
],
test_mock={
"get_list_memberships": lambda *args, **kwargs: (
{"lists": [{"id": "84839422"}]},
[{"id": "84839422"}],
{},
{},
{"next_token": None},
["84839422"],
None,
)

View File

@@ -98,15 +98,11 @@ class TwitterGetListTweetsBlock(Block):
test_output=[
("tweet_ids", ["1234567890"]),
("texts", ["Test tweet"]),
("next_token", None),
("data", {"list_tweets": [{"id": "1234567890", "text": "Test tweet"}]}),
("included", {}),
("meta", {}),
("error", ""),
("data", [{"id": "1234567890", "text": "Test tweet"}]),
],
test_mock={
"get_list_tweets": lambda *args, **kwargs: (
{"list_tweets": [{"id": "1234567890", "text": "Test tweet"}]},
[{"id": "1234567890", "text": "Test tweet"}],
{},
{},
["1234567890"],

View File

@@ -228,11 +228,7 @@ class TwitterCreateListBlock(Block):
("list_id", "1234567890"),
("url", "https://twitter.com/i/lists/1234567890"),
],
test_mock={
"create_list": lambda *args, **kwargs: cast(
Response, {"data": {"id": "1234567890"}}
)
},
test_mock={"create_list": lambda *args, **kwargs: ("1234567890")},
)
@staticmethod
@@ -253,7 +249,10 @@ class TwitterCreateListBlock(Block):
user_auth=False,
),
)
return response
list_id = str(response.data["id"])
return list_id
except tweepy.TweepyException:
raise
@@ -269,10 +268,9 @@ class TwitterCreateListBlock(Block):
**kwargs,
) -> BlockOutput:
try:
response = self.create_list(
list_id = self.create_list(
credentials, input_data.name, input_data.description, input_data.private
)
list_id = str(response.data["id"])
yield "list_id", list_id
yield "url", f"https://twitter.com/i/lists/{list_id}"

View File

@@ -198,16 +198,11 @@ class TwitterGetPinnedListsBlock(Block):
test_output=[
("list_ids", ["84839422"]),
("list_names", ["Twitter List"]),
(
"data",
{"pinned_lists": [{"id": "84839422", "name": "Twitter List"}]},
),
("included", {}),
("meta", {}),
("data", [{"id": "84839422", "name": "Twitter List"}]),
],
test_mock={
"get_pinned_lists": lambda *args, **kwargs: (
{"pinned_lists": [{"id": "84839422", "name": "Twitter List"}]},
[{"id": "84839422", "name": "Twitter List"}],
{},
{},
["84839422"],

View File

@@ -63,7 +63,7 @@ class TwitterSearchSpacesBlock(Block):
next_token: str = SchemaField(description="Next token for pagination")
# Complete outputs for advanced use
data: dict = SchemaField(description="Complete space data")
data: list[dict] = SchemaField(description="Complete space data")
includes: dict = SchemaField(
description="Additional data requested via expansions"
)
@@ -83,7 +83,6 @@ class TwitterSearchSpacesBlock(Block):
"max_results": 10,
"state": "live",
"credentials": TEST_CREDENTIALS_INPUT,
"pagination": "",
"expansions": [],
"space_fields": [],
"user_fields": [],
@@ -93,30 +92,17 @@ class TwitterSearchSpacesBlock(Block):
("ids", ["1234"]),
("titles", ["Tech Talk"]),
("host_ids", ["5678"]),
("next_token", "next_token_value"),
(
"data",
{
"spaces": [
{"id": "1234", "title": "Tech Talk", "host_id": "5678"}
]
},
),
("includes", {}),
("meta", {"next_token": "next_token_value"}),
("error", ""),
("data", [{"id": "1234", "title": "Tech Talk", "host_ids": ["5678"]}]),
],
test_mock={
"search_spaces": lambda *args, **kwargs: (
{
"spaces": [
{"id": "1234", "title": "Tech Talk", "host_id": "5678"}
]
},
[{"id": "1234", "title": "Tech Talk", "host_ids": ["5678"]}],
{},
{"next_token": "next_token_value"},
"next_token_value",
"",
{},
["1234"],
["Tech Talk"],
["5678"],
None,
)
},
)

View File

@@ -83,7 +83,7 @@ class TwitterGetSpacesBlock(Block):
output_schema=TwitterGetSpacesBlock.Output,
test_input={
"space_ids": ["1DXxyRYNejbKM"],
"user_ids": None,
"user_ids": [],
"credentials": TEST_CREDENTIALS_INPUT,
"expansions": [],
"space_fields": [],
@@ -93,21 +93,31 @@ class TwitterGetSpacesBlock(Block):
test_output=[
("ids", ["1DXxyRYNejbKM"]),
("titles", ["Test Space"]),
("host_ids", ["1234567"]),
(
"data",
{
"spaces": [
{
"id": "1DXxyRYNejbKM",
"title": "Test Space",
"host_id": "1234567",
}
]
},
[
{
"id": "1DXxyRYNejbKM",
"title": "Test Space",
"host_id": "1234567",
}
],
),
("includes", {}),
],
test_mock={
"get_spaces": lambda *args, **kwargs: (
[
{
"id": "1DXxyRYNejbKM",
"title": "Test Space",
"host_id": "1234567",
}
],
{},
["1DXxyRYNejbKM"],
["Test Space"],
)
},
)
@staticmethod
@@ -236,18 +246,26 @@ class TwitterGetSpaceByIdBlock(Block):
test_output=[
("id", "1DXxyRYNejbKM"),
("title", "Test Space"),
("host_id", "1234567"),
("host_ids", ["1234567"]),
(
"data",
{
"id": "1DXxyRYNejbKM",
"title": "Test Space",
"host_id": "1234567",
"host_ids": ["1234567"],
},
),
("includes", {}),
("error", None),
],
test_mock={
"get_space": lambda *args, **kwargs: (
{
"id": "1DXxyRYNejbKM",
"title": "Test Space",
"host_ids": ["1234567"],
},
{},
)
},
)
@staticmethod
@@ -385,11 +403,17 @@ class TwitterGetSpaceBuyersBlock(Block):
("usernames", ["testuser"]),
(
"data",
{"id": "2244994945", "username": "testuser", "name": "Test User"},
[{"id": "2244994945", "username": "testuser", "name": "Test User"}],
),
("includes", {}),
("error", None),
],
test_mock={
"get_space_buyers": lambda *args, **kwargs: (
[{"id": "2244994945", "username": "testuser", "name": "Test User"}],
{},
["2244994945"],
["testuser"],
)
},
)
@staticmethod
@@ -510,11 +534,17 @@ class TwitterGetSpaceTweetsBlock(Block):
test_output=[
("tweet_ids", ["1234567890"]),
("texts", ["Test tweet"]),
("data", {"tweets": [{"id": "1234567890", "text": "Test tweet"}]}),
("includes", {}),
("meta", {}),
("error", None),
("data", [{"id": "1234567890", "text": "Test tweet"}]),
],
test_mock={
"get_space_tweets": lambda *args, **kwargs: (
[{"id": "1234567890", "text": "Test tweet"}], # data
{},
["1234567890"],
["Test tweet"],
{},
)
},
)
@staticmethod

View File

@@ -63,6 +63,7 @@ class TwitterBookmarkTweetBlock(Block):
test_output=[
("success", True),
],
test_mock={"bookmark_tweet": lambda *args, **kwargs: True},
)
@staticmethod
@@ -164,10 +165,19 @@ class TwitterGetBookmarkedTweetsBlock(Block):
("userId", ["12345"]),
("userName", ["testuser"]),
("data", [{"id": "1234567890", "text": "Test tweet"}]),
("included", {"users": [{"id": "12345", "username": "testuser"}]}),
("meta", {"result_count": 1}),
("next_token", "next_token_value"),
],
test_mock={
"get_bookmarked_tweets": lambda *args, **kwargs: (
["1234567890"],
["Test tweet"],
["12345"],
["testuser"],
[{"id": "1234567890", "text": "Test tweet"}],
{},
{},
None,
)
},
)
@staticmethod

View File

@@ -46,6 +46,7 @@ class TwitterHideReplyBlock(Block):
test_output=[
("success", True),
],
test_mock={"hide_reply": lambda *args, **kwargs: True},
)
@staticmethod
@@ -116,6 +117,7 @@ class TwitterUnhideReplyBlock(Block):
test_output=[
("success", True),
],
test_mock={"unhide_reply": lambda *args, **kwargs: True},
)
@staticmethod

View File

@@ -68,6 +68,7 @@ class TwitterLikeTweetBlock(Block):
test_output=[
("success", True),
],
test_mock={"like_tweet": lambda *args, **kwargs: True},
)
@staticmethod
@@ -169,30 +170,18 @@ class TwitterGetLikingUsersBlock(Block):
},
test_credentials=TEST_CREDENTIALS,
test_output=[
("id", ["12345", "67890"]),
("username", ["user1", "user2"]),
(
"data",
[
{"id": "12345", "username": "user1"},
{"id": "67890", "username": "user2"},
],
),
("included", {}),
("meta", {"result_count": 2, "next_token": "next_token_value"}),
("next_token", "next_token_value"),
("id", ["1234567890"]),
("username", ["testuser"]),
("data", [{"id": "1234567890", "username": "testuser"}]),
],
test_mock={
"get_liking_users": lambda *args, **kwargs: (
["12345", "67890"],
["user1", "user2"],
[
{"id": "12345", "username": "user1"},
{"id": "67890", "username": "user2"},
],
["1234567890"],
["testuser"],
[{"id": "1234567890", "username": "testuser"}],
{},
{"result_count": 2, "next_token": "next_token_value"},
"next_token_value",
{},
None,
)
},
)
@@ -373,17 +362,6 @@ class TwitterGetLikedTweetsBlock(Block):
{"id": "67890", "text": "Tweet 2"},
],
),
(
"included",
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
),
("meta", {"result_count": 2, "next_token": "next_token_value"}),
("next_token", "next_token_value"),
],
test_mock={
"get_liked_tweets": lambda *args, **kwargs: (
@@ -395,14 +373,9 @@ class TwitterGetLikedTweetsBlock(Block):
{"id": "12345", "text": "Tweet 1"},
{"id": "67890", "text": "Tweet 2"},
],
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
{"result_count": 2, "next_token": "next_token_value"},
"next_token_value",
{},
{},
None,
)
},
)
@@ -566,6 +539,7 @@ class TwitterUnlikeTweetBlock(Block):
test_output=[
("success", True),
],
test_mock={"unlike_tweet": lambda *args, **kwargs: True},
)
@staticmethod

View File

@@ -410,16 +410,6 @@ class TwitterSearchRecentTweetsBlock(Block):
},
],
),
("included", {}),
(
"meta",
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
),
("next_token", "next_token_value"),
],
test_mock={
"search_tweets": lambda *args, **kwargs: (
@@ -439,12 +429,8 @@ class TwitterSearchRecentTweetsBlock(Block):
},
],
{},
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
"next_token_value",
{},
None,
)
},
)

View File

@@ -116,9 +116,6 @@ class TwitterGetQuoteTweetsBlock(Block):
{"id": "67890", "text": "Tweet 2"},
],
),
("included", {}),
("meta", {"result_count": 2, "next_token": "next_token_value"}),
("next_token", "next_token_value"),
],
test_mock={
"get_quote_tweets": lambda *args, **kwargs: (
@@ -129,8 +126,8 @@ class TwitterGetQuoteTweetsBlock(Block):
{"id": "67890", "text": "Tweet 2"},
],
{},
{"result_count": 2, "next_token": "next_token_value"},
"next_token_value",
{},
None,
)
},
)

View File

@@ -57,7 +57,10 @@ class TwitterRetweetBlock(Block):
"credentials": TEST_CREDENTIALS_INPUT,
},
test_credentials=TEST_CREDENTIALS,
test_output=[("success", True), ("error", "")],
test_output=[
("success", True),
],
test_mock={"retweet": lambda *args, **kwargs: True},
)
@staticmethod
@@ -133,6 +136,7 @@ class TwitterRemoveRetweetBlock(Block):
test_output=[
("success", True),
],
test_mock={"remove_retweet": lambda *args, **kwargs: True},
)
@staticmethod
@@ -244,23 +248,20 @@ class TwitterGetRetweetersBlock(Block):
("ids", ["12345"]),
("names", ["Test User"]),
("usernames", ["testuser"]),
("next_token", "next_token_value"),
(
"data",
[{"id": "12345", "name": "Test User", "username": "testuser"}],
),
("included", {}),
("meta", {"next_token": "next_token_value"}),
],
test_mock={
"get_retweeters": lambda *args, **kwargs: (
[{"id": "12345", "name": "Test User", "username": "testuser"}],
{},
{"next_token": "next_token_value"},
{},
["12345"],
["Test User"],
["testuser"],
"next_token_value",
None,
)
},
)

View File

@@ -99,7 +99,7 @@ class TwitterGetUserMentionsBlock(Block):
"since_id": "",
"until_id": "",
"sort_order": "",
"pagination": "",
"pagination_token": "",
"expansions": [],
"media_fields": [],
"place_fields": [],
@@ -120,24 +120,6 @@ class TwitterGetUserMentionsBlock(Block):
{"id": "1372627771717869568", "text": "Test mention 2"},
],
),
(
"included",
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
),
(
"meta",
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
),
("next_token", "next_token_value"),
],
test_mock={
"get_mentions": lambda *args, **kwargs: (
@@ -149,18 +131,9 @@ class TwitterGetUserMentionsBlock(Block):
{"id": "1373001119480344583", "text": "Test mention 1"},
{"id": "1372627771717869568", "text": "Test mention 2"},
],
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
"next_token_value",
{},
{},
None,
)
},
)
@@ -366,7 +339,7 @@ class TwitterGetHomeTimelineBlock(Block):
"since_id": "",
"until_id": "",
"sort_order": "",
"pagination": "",
"pagination_token": "",
"expansions": [],
"media_fields": [],
"place_fields": [],
@@ -387,24 +360,6 @@ class TwitterGetHomeTimelineBlock(Block):
{"id": "1372627771717869568", "text": "Test tweet 2"},
],
),
(
"included",
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
),
(
"meta",
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
),
("next_token", "next_token_value"),
],
test_mock={
"get_timeline": lambda *args, **kwargs: (
@@ -416,18 +371,9 @@ class TwitterGetHomeTimelineBlock(Block):
{"id": "1373001119480344583", "text": "Test tweet 1"},
{"id": "1372627771717869568", "text": "Test tweet 2"},
],
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
"next_token_value",
{},
{},
None,
)
},
)
@@ -636,7 +582,7 @@ class TwitterGetUserTweetsBlock(Block):
"since_id": "",
"until_id": "",
"sort_order": "",
"pagination": "",
"pagination_token": "",
"expansions": [],
"media_fields": [],
"place_fields": [],
@@ -657,24 +603,6 @@ class TwitterGetUserTweetsBlock(Block):
{"id": "1372627771717869568", "text": "Test tweet 2"},
],
),
(
"included",
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
),
(
"meta",
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
),
("next_token", "next_token_value"),
],
test_mock={
"get_user_tweets": lambda *args, **kwargs: (
@@ -686,18 +614,9 @@ class TwitterGetUserTweetsBlock(Block):
{"id": "1373001119480344583", "text": "Test tweet 1"},
{"id": "1372627771717869568", "text": "Test tweet 2"},
],
{
"users": [
{"id": "67890", "username": "testuser1"},
{"id": "67891", "username": "testuser2"},
]
},
{
"newest_id": "1373001119480344583",
"oldest_id": "1372627771717869568",
"next_token": "next_token_value",
},
"next_token_value",
{},
{},
None,
)
},
)

View File

@@ -90,7 +90,10 @@ class TwitterGetTweetBlock(Block):
test_mock={
"get_tweet": lambda *args, **kwargs: (
{"id": "1460323737035677698", "text": "Test tweet content"},
{},
{"users": [{"id": "12345", "username": "testuser"}]},
{"result_count": 1},
"12345",
"testuser",
)
},
)
@@ -248,8 +251,15 @@ class TwitterGetTweetsBlock(Block):
],
test_mock={
"get_tweets": lambda *args, **kwargs: (
{"id": "1460323737035677698", "text": "Test tweet content"},
{},
["1460323737035677698"], # ids
["Test tweet content"], # texts
["67890"], # user_ids
["testuser1"], # user_names
[
{"id": "1460323737035677698", "text": "Test tweet content"}
], # data
{"users": [{"id": "67890", "username": "testuser1"}]}, # included
{"result_count": 1}, # meta
)
},
)

View File

@@ -57,6 +57,7 @@ class TwitterUnblockUserBlock(Block):
test_output=[
("success", True),
],
test_mock={"unblock_user": lambda *args, **kwargs: True},
)
@staticmethod
@@ -140,10 +141,16 @@ class TwitterGetBlockedUsersBlock(Block):
test_output=[
("user_ids", ["12345", "67890"]),
("usernames_", ["testuser1", "testuser2"]),
("included", {}),
("meta", {"next_token": "next_token_value"}),
("next_token", "next_token_value"),
],
test_mock={
"get_blocked_users": lambda *args, **kwargs: (
{}, # included
{}, # meta
["12345", "67890"], # user_ids
["testuser1", "testuser2"], # usernames
None, # next_token
)
},
)
@staticmethod
@@ -267,6 +274,7 @@ class TwitterBlockUserBlock(Block):
test_output=[
("success", True),
],
test_mock={"block_user": lambda *args, **kwargs: True},
)
@staticmethod

View File

@@ -62,6 +62,7 @@ class TwitterUnfollowUserBlock(Block):
test_output=[
("success", True),
],
test_mock={"unfollow_user": lambda *args, **kwargs: True},
)
@staticmethod
@@ -126,7 +127,8 @@ class TwitterFollowUserBlock(Block):
"credentials": TEST_CREDENTIALS_INPUT,
},
test_credentials=TEST_CREDENTIALS,
test_output=[("success", True), ("error", "")],
test_output=[("success", True)],
test_mock={"follow_user": lambda *args, **kwargs: True},
)
@staticmethod
@@ -221,9 +223,6 @@ class TwitterGetFollowersBlock(Block):
("ids", ["1234567890"]),
("usernames", ["testuser"]),
("data", [{"id": "1234567890", "username": "testuser"}]),
("includes", {}),
("meta", {"result_count": 1}),
("next_token", "next_token_value"),
],
test_mock={
"get_followers": lambda *args, **kwargs: (
@@ -231,8 +230,8 @@ class TwitterGetFollowersBlock(Block):
["testuser"],
[{"id": "1234567890", "username": "testuser"}],
{},
{"result_count": 1},
"next_token_value",
{},
None,
)
},
)
@@ -397,9 +396,6 @@ class TwitterGetFollowingBlock(Block):
("ids", ["1234567890"]),
("usernames", ["testuser"]),
("data", [{"id": "1234567890", "username": "testuser"}]),
("includes", {}),
("meta", {"result_count": 1}),
("next_token", "next_token_value"),
],
test_mock={
"get_following": lambda *args, **kwargs: (
@@ -407,8 +403,8 @@ class TwitterGetFollowingBlock(Block):
["testuser"],
[{"id": "1234567890", "username": "testuser"}],
{},
{"result_count": 1},
"next_token_value",
{},
None,
)
},
)

View File

@@ -62,6 +62,7 @@ class TwitterUnmuteUserBlock(Block):
test_output=[
("success", True),
],
test_mock={"unmute_user": lambda *args, **kwargs: True},
)
@staticmethod
@@ -156,9 +157,6 @@ class TwitterGetMutedUsersBlock(Block):
{"id": "67890", "username": "testuser2"},
],
),
("includes", {}),
("meta", {"next_token": "next_token_value"}),
("next_token", "next_token_value"),
],
test_mock={
"get_muted_users": lambda *args, **kwargs: (
@@ -169,8 +167,8 @@ class TwitterGetMutedUsersBlock(Block):
{"id": "67890", "username": "testuser2"},
],
{},
{"next_token": "next_token_value"},
"next_token_value",
{},
None,
)
},
)
@@ -298,6 +296,7 @@ class TwitterMuteUserBlock(Block):
test_output=[
("success", True),
],
test_mock={"mute_user": lambda *args, **kwargs: True},
)
@staticmethod

View File

@@ -71,7 +71,7 @@ class TwitterGetUserBlock(Block):
input_schema=TwitterGetUserBlock.Input,
output_schema=TwitterGetUserBlock.Output,
test_input={
"user_id": None,
"user_id": "",
"username": "twitter",
"credentials": TEST_CREDENTIALS_INPUT,
"expansions": [],
@@ -93,9 +93,22 @@ class TwitterGetUserBlock(Block):
}
},
),
("included", {}),
("error", None),
],
test_mock={
"get_user": lambda *args, **kwargs: (
{
"user": {
"id": "783214",
"username": "twitter",
"name": "Twitter",
}
},
{},
"twitter",
"783214",
"Twitter",
)
},
)
@staticmethod
@@ -239,20 +252,32 @@ class TwitterGetUsersBlock(Block):
("names_", ["Twitter", "Twitter Dev"]),
(
"data",
{
"users": [
{"id": "783214", "username": "twitter", "name": "Twitter"},
{
"id": "2244994945",
"username": "twitterdev",
"name": "Twitter Dev",
},
]
},
[
{"id": "783214", "username": "twitter", "name": "Twitter"},
{
"id": "2244994945",
"username": "twitterdev",
"name": "Twitter Dev",
},
],
),
("included", {}),
("error", None),
],
test_mock={
"get_users": lambda *args, **kwargs: (
[
{"id": "783214", "username": "twitter", "name": "Twitter"},
{
"id": "2244994945",
"username": "twitterdev",
"name": "Twitter Dev",
},
],
{},
["twitter", "twitterdev"],
["783214", "2244994945"],
["Twitter", "Twitter Dev"],
)
},
)
@staticmethod