github webhooks: Fix message for unsupported team payloads.

The main thing fixed here is that we weren't turning
on our keys into a list.  And then I refined the message
a bit more, including sorting the keys.

I also avoid the unnecessary "else".
This commit is contained in:
Steve Howell
2020-09-02 12:23:52 +00:00
committed by Tim Abbott
parent 8785790a27
commit c6b9a23c17
2 changed files with 7 additions and 2 deletions

View File

@@ -452,4 +452,8 @@ A temporary team so that I can get some webhook fixtures!
stack_info = m.call_args[1]["stack_info"]
self.assertIn("content_type: application/json", msg)
self.assertIn(
"summary: The 'team/edited (changes: bogus_key1/bogus_key2)' event isn't currently supported by the GitHub webhook",
msg,
)
self.assertTrue(stack_info)

View File

@@ -280,8 +280,9 @@ def get_team_body(helper: Helper) -> str:
if "privacy" in changes:
new_visibility = payload["team"]["privacy"]
return f"Team visibility changed to `{new_visibility}`"
else:
raise UnexpectedWebhookEventType("GitHub", f"Team Edited: {changes.keys()}")
missing_keys = "/".join(sorted(list(changes.keys())))
raise UnexpectedWebhookEventType("GitHub", f"team/edited (changes: {missing_keys})")
def get_release_body(helper: Helper) -> str:
payload = helper.payload