Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

trello tests: Generalize test for createCheckItem.

Steve Howell37159fc23511
diff --git a/zerver/webhooks/trello/fixtures/create_check_item.json b/zerver/webhooks/trello/fixtures/create_check_item.json
deleted file mode 100644
index a9985280268..00000000000
--- a/zerver/webhooks/trello/fixtures/create_check_item.json
+++ /dev/null
@@ -1,102 +0,0 @@
-{
- "model":{
- "id":"597958d15c95392f2830e9f5",
- "name":"Zulip",
- "desc":"",
- "descData":null,
- "closed":false,
- "idOrganization":null,
- "pinned":false,
- "url":"https://trello.com/b/l9NqJcCd/zulip",
- "shortUrl":"https://trello.com/b/l9NqJcCd",
- "prefs":{
- "permissionLevel":"private",
- "voting":"disabled",
- "comments":"members",
- "invitations":"members",
- "selfJoin":false,
- "cardCovers":true,
- "cardAging":"regular",
- "calendarFeedEnabled":false,
- "background":"blue",
- "backgroundImage":null,
- "backgroundImageScaled":null,
- "backgroundTile":false,
- "backgroundBrightness":"dark",
- "backgroundColor":"#0079BF",
- "backgroundBottomColor":"#0079BF",
- "backgroundTopColor":"#0079BF",
- "canBePublic":true,
- "canBeEnterprise":true,
- "canBeOrg":true,
- "canBePrivate":true,
- "canInvite":true
- },
- "labelNames":{
- "green":"",
- "yellow":"",
- "orange":"",
- "red":"",
- "purple":"",
- "blue":"",
- "sky":"",
- "lime":"",
- "pink":"",
- "black":""
- }
- },
- "action":{
- "id":"5c6f1a64af711461f2534922",
- "idMemberCreator":"59780df0f985476615f5ea66",
- "data":{
- "checkItem":{
- "state":"incomplete",
- "name":"Tomatoes",
- "id":"5c6f1a64af711461f2534921"
- },
- "checklist":{
- "name":"Checklist",
- "id":"5c6f1a58d61c527c91892ba1"
- },
- "board":{
- "shortLink":"l9NqJcCd",
- "name":"Zulip",
- "id":"597958d15c95392f2830e9f5"
- },
- "card":{
- "shortLink":"R2thJK3P",
- "idShort":3,
- "name":"Something something",
- "id":"5abd0cc638506013c1ebb33f"
- }
- },
- "type":"createCheckItem",
- "date":"2019-02-21T21:38:44.070Z",
- "limits":{
-
- },
- "display":{
- "translationKey":"unknown",
- "entities":{
- "memberCreator":{
- "type":"member",
- "id":"59780df0f985476615f5ea66",
- "username":"eeshangarg",
- "text":"Eeshan Garg"
- }
- }
- },
- "memberCreator":{
- "id":"59780df0f985476615f5ea66",
- "avatarHash":null,
- "avatarUrl":null,
- "fullName":"Eeshan Garg",
- "idMemberReferrer":null,
- "initials":"EG",
- "nonPublic":{
-
- },
- "username":"eeshangarg"
- }
- }
-}
diff --git a/zerver/webhooks/trello/tests.py b/zerver/webhooks/trello/tests.py
index 5711e404454..4a79a025dfb 100644
--- a/zerver/webhooks/trello/tests.py
+++ b/zerver/webhooks/trello/tests.py
@@ -1,5 +1,7 @@
from unittest.mock import patch
+import orjson
+
from zerver.lib.test_classes import WebhookTestCase
@@ -111,7 +113,19 @@ class TrelloHookTests(WebhookTestCase):
self.verify_post_is_ignored(payload)
def test_create_card_check_item_ignore(self) -> None:
- payload = self.get_body('create_check_item')
+ """
+ Certain card-related actions are now ignored solely based on the
+ action type, and we don't need to do any other parsing to ignore
+ them as invalid.
+ """
+ action = "createCheckItem"
+ data = dict(
+ model="whatever",
+ action=dict(
+ type=action,
+ ),
+ )
+ payload = orjson.dumps(data).decode()
self.verify_post_is_ignored(payload)
def test_trello_webhook_when_description_was_added_to_card(self) -> None: