webhook: Rename FIXTURE_DIR_NAME to WEBHOOK_DIR_NAME.

Since FIXTURE_DIR_NAME is the name of the folder that contains the view
and tests modules of the webhook and another folder called "fixtures" that
store the fixtures, it is more appropriate to call it WEBHOOK_DIR_NAME,
especially when we want to refer to the view module using this variable.
This commit is contained in:
PIG208
2021-06-26 15:18:33 +08:00
committed by Tim Abbott
parent b720e10d88
commit 5ecbfecd77
81 changed files with 89 additions and 89 deletions

View File

@@ -1374,7 +1374,7 @@ class WebhookTestCase(ZulipTestCase):
STREAM_NAME: Optional[str] = None
TEST_USER_EMAIL = "webhook-bot@zulip.com"
URL_TEMPLATE: str
FIXTURE_DIR_NAME: Optional[str] = None
WEBHOOK_DIR_NAME: Optional[str] = None
@property
def test_user(self) -> UserProfile:
@@ -1420,8 +1420,8 @@ class WebhookTestCase(ZulipTestCase):
payload = self.get_payload(fixture_name)
if content_type is not None:
kwargs["content_type"] = content_type
if self.FIXTURE_DIR_NAME is not None:
headers = get_fixture_http_headers(self.FIXTURE_DIR_NAME, fixture_name)
if self.WEBHOOK_DIR_NAME is not None:
headers = get_fixture_http_headers(self.WEBHOOK_DIR_NAME, fixture_name)
headers = standardize_headers(headers)
kwargs.update(headers)
@@ -1467,8 +1467,8 @@ class WebhookTestCase(ZulipTestCase):
payload = self.get_payload(fixture_name)
kwargs["content_type"] = content_type
if self.FIXTURE_DIR_NAME is not None:
headers = get_fixture_http_headers(self.FIXTURE_DIR_NAME, fixture_name)
if self.WEBHOOK_DIR_NAME is not None:
headers = get_fixture_http_headers(self.WEBHOOK_DIR_NAME, fixture_name)
headers = standardize_headers(headers)
kwargs.update(headers)
# The sender profile shouldn't be passed any further in kwargs, so we pop it.
@@ -1512,8 +1512,8 @@ class WebhookTestCase(ZulipTestCase):
return self.get_body(fixture_name)
def get_body(self, fixture_name: str) -> str:
assert self.FIXTURE_DIR_NAME is not None
body = self.webhook_fixture_data(self.FIXTURE_DIR_NAME, fixture_name)
assert self.WEBHOOK_DIR_NAME is not None
body = self.webhook_fixture_data(self.WEBHOOK_DIR_NAME, fixture_name)
# fail fast if we don't have valid json
orjson.loads(body)
return body

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class AirbrakeHookTests(WebhookTestCase):
STREAM_NAME = "airbrake"
URL_TEMPLATE = "/api/v1/external/airbrake?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "airbrake"
WEBHOOK_DIR_NAME = "airbrake"
def test_airbrake_error_message(self) -> None:
expected_topic = "ZulipIntegrationTest"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class AlertmanagerHookTests(WebhookTestCase):
STREAM_NAME = "alertmanager"
URL_TEMPLATE = "/api/v1/external/alertmanager?&api_key={api_key}&stream={stream}&name=topic&desc=description"
FIXTURE_DIR_NAME = "alertmanager"
WEBHOOK_DIR_NAME = "alertmanager"
def test_error_issue_message(self) -> None:
expected_topic = "andromeda"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class AnsibletowerHookTests(WebhookTestCase):
STREAM_NAME = "ansibletower"
URL_TEMPLATE = "/api/v1/external/ansibletower?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "ansibletower"
WEBHOOK_DIR_NAME = "ansibletower"
def test_ansibletower_project_update_successful_message(self) -> None:
"""

View File

@@ -5,7 +5,7 @@ from zerver.webhooks.appfollow.view import convert_markdown
class AppFollowHookTests(WebhookTestCase):
STREAM_NAME = "appfollow"
URL_TEMPLATE = "/api/v1/external/appfollow?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "appfollow"
WEBHOOK_DIR_NAME = "appfollow"
def test_sample(self) -> None:
expected_topic = "Webhook integration was successful."

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class AppveyorHookTests(WebhookTestCase):
STREAM_NAME = "appveyor"
URL_TEMPLATE = "/api/v1/external/appveyor?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "appveyor"
WEBHOOK_DIR_NAME = "appveyor"
def test_appveyor_build_success_message(self) -> None:
"""

View File

@@ -6,7 +6,7 @@ TOPIC = "Zulip HQ"
class BasecampHookTests(WebhookTestCase):
STREAM_NAME = "basecamp"
URL_TEMPLATE = "/api/v1/external/basecamp?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "basecamp"
WEBHOOK_DIR_NAME = "basecamp"
def test_basecamp_makes_doc_active(self) -> None:
expected_message = "Tomasz activated the document [New doc](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)."

View File

@@ -7,7 +7,7 @@ from zerver.lib.test_classes import WebhookTestCase
class BeeminderHookTests(WebhookTestCase):
STREAM_NAME = "beeminder"
URL_TEMPLATE = "/api/v1/external/beeminder?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "beeminder"
WEBHOOK_DIR_NAME = "beeminder"
@patch("zerver.webhooks.beeminder.view.time.time")
def test_beeminder_derail(self, time: Any) -> None:

View File

@@ -9,7 +9,7 @@ TOPIC_BRANCH_EVENTS = "Repository name / master"
class BitbucketHookTests(WebhookTestCase):
STREAM_NAME = "bitbucket"
URL_TEMPLATE = "/api/v1/external/bitbucket?stream={stream}"
FIXTURE_DIR_NAME = "bitbucket"
WEBHOOK_DIR_NAME = "bitbucket"
def test_bitbucket_on_push_event(self) -> None:
fixture_name = "push"

View File

@@ -12,7 +12,7 @@ TOPIC_BRANCH_EVENTS = "Repository name / master"
class Bitbucket2HookTests(WebhookTestCase):
STREAM_NAME = "bitbucket2"
URL_TEMPLATE = "/api/v1/external/bitbucket2?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "bitbucket2"
WEBHOOK_DIR_NAME = "bitbucket2"
def test_bitbucket2_on_push_event(self) -> None:
commit_info = "* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"

View File

@@ -7,7 +7,7 @@ TOPIC_BRANCH_EVENTS = "sandbox / {branch}"
class Bitbucket3HookTests(WebhookTestCase):
STREAM_NAME = "bitbucket3"
URL_TEMPLATE = "/api/v1/external/bitbucket3?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "bitbucket3"
WEBHOOK_DIR_NAME = "bitbucket3"
# Diagnostics events:
def test_ping(self) -> None:

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class BuildbotHookTests(WebhookTestCase):
STREAM_NAME = "buildbot"
URL_TEMPLATE = "/api/v1/external/buildbot?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "buildbot"
WEBHOOK_DIR_NAME = "buildbot"
def test_build_started(self) -> None:
expected_topic = "buildbot-hello"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class CanarytokenHookTests(WebhookTestCase):
STREAM_NAME = "canarytoken"
URL_TEMPLATE = "/api/v1/external/canarytoken?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "canarytoken"
WEBHOOK_DIR_NAME = "canarytoken"
def test_canarytoken_new(self) -> None:
expected_message = (

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class CircleCiHookTests(WebhookTestCase):
STREAM_NAME = "circleci"
URL_TEMPLATE = "/api/v1/external/circleci?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "circleci"
WEBHOOK_DIR_NAME = "circleci"
def test_private_repo_with_pull_request_off_bitbucket(self) -> None:
expected_topic = "circleci-test"

View File

@@ -7,7 +7,7 @@ from zerver.lib.test_classes import WebhookTestCase
class ClubhouseWebhookTest(WebhookTestCase):
STREAM_NAME = "clubhouse"
URL_TEMPLATE = "/api/v1/external/clubhouse?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "clubhouse"
WEBHOOK_DIR_NAME = "clubhouse"
def test_story_create(self) -> None:
expected_message = "New story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) of type **feature** was created."

View File

@@ -5,7 +5,7 @@ class CodeshipHookTests(WebhookTestCase):
STREAM_NAME = "codeship"
URL_TEMPLATE = "/api/v1/external/codeship?stream={stream}&api_key={api_key}"
TOPIC = "codeship/docs"
FIXTURE_DIR_NAME = "codeship"
WEBHOOK_DIR_NAME = "codeship"
def test_codeship_build_in_testing_status_message(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class CrashlyticsHookTests(WebhookTestCase):
STREAM_NAME = "crashlytics"
URL_TEMPLATE = "/api/v1/external/crashlytics?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "crashlytics"
WEBHOOK_DIR_NAME = "crashlytics"
def test_crashlytics_verification_message(self) -> None:
expected_topic = "Setup"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class DelightedHookTests(WebhookTestCase):
STREAM_NAME = "delighted"
URL_TEMPLATE = "/api/v1/external/delighted?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "delighted"
WEBHOOK_DIR_NAME = "delighted"
def test_feedback_message_promoter(self) -> None:
expected_topic = "Survey response"

View File

@@ -14,7 +14,7 @@ from zerver.lib.test_classes import WebhookTestCase
class DeskDotComHookTests(WebhookTestCase):
STREAM_NAME = "deskdotcom"
URL_TEMPLATE = "/api/v1/external/deskdotcom?stream={stream}"
FIXTURE_DIR_NAME = "deskdotcom"
WEBHOOK_DIR_NAME = "deskdotcom"
def test_static_text_message(self) -> None:

View File

@@ -3,7 +3,7 @@ from zerver.lib.test_classes import WebhookTestCase
class DialogflowHookTests(WebhookTestCase):
URL_TEMPLATE = "/api/v1/external/dialogflow?api_key={api_key}&email=AARON@zulip.com"
FIXTURE_DIR_NAME = "dialogflow"
WEBHOOK_DIR_NAME = "dialogflow"
def test_dialogflow_default(self) -> None:
email = self.example_user("aaron").email

View File

@@ -5,7 +5,7 @@ from zerver.lib.users import get_api_key
class DropboxHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/dropbox?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "dropbox"
WEBHOOK_DIR_NAME = "dropbox"
def test_file_updated(self) -> None:
expected_topic = "Dropbox"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class ErrBitHookTests(WebhookTestCase):
STREAM_NAME = "errbit"
URL_TEMPLATE = "/api/v1/external/errbit?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "errbit"
WEBHOOK_DIR_NAME = "errbit"
def test_errbit_error_message(self) -> None:
expected_topic = "ZulipIntegrationTest / ErrbitEnvName"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class FlockHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/flock?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "flock"
WEBHOOK_DIR_NAME = "flock"
def test_flock_message(self) -> None:
expected_topic = "Flock notifications"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class FreshdeskHookTests(WebhookTestCase):
STREAM_NAME = "freshdesk"
URL_TEMPLATE = "/api/v1/external/freshdesk?stream={stream}"
FIXTURE_DIR_NAME = "freshdesk"
WEBHOOK_DIR_NAME = "freshdesk"
def test_ticket_creation(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class FreshpingHookTests(WebhookTestCase):
STREAM_NAME = "freshping"
URL_TEMPLATE = "/api/v1/external/freshping?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "freshping"
WEBHOOK_DIR_NAME = "freshping"
def test_freshping_check_test(self) -> None:
"""

View File

@@ -7,7 +7,7 @@ from zerver.webhooks.freshstatus.view import MISCONFIGURED_PAYLOAD_ERROR_MESSAGE
class FreshstatusHookTests(WebhookTestCase):
STREAM_NAME = "freshstatus"
URL_TEMPLATE = "/api/v1/external/freshstatus?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "freshstatus"
WEBHOOK_DIR_NAME = "freshstatus"
def test_freshstatus_incident_open_multiple_services(self) -> None:
"""

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class FrontHookTests(WebhookTestCase):
STREAM_NAME = "front"
URL_TEMPLATE = "/api/v1/external/front?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "front"
WEBHOOK_DIR_NAME = "front"
# Scenario 1: Conversation starts from an outbound message.

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class GoogleCodeInTests(WebhookTestCase):
STREAM_NAME = "gci"
URL_TEMPLATE = "/api/v1/external/gci?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "gci"
WEBHOOK_DIR_NAME = "gci"
def test_abandon_event_message(self) -> None:
expected_topic = "student-yqqtag"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class GiteaHookTests(WebhookTestCase):
STREAM_NAME = "commits"
URL_TEMPLATE = "/api/v1/external/gitea?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "gitea"
WEBHOOK_DIR_NAME = "gitea"
def test_multiple_commits(self) -> None:
expected_topic = "test / d"

View File

@@ -17,7 +17,7 @@ TOPIC_WIKI = "public-repo / wiki pages"
class GitHubWebhookTest(WebhookTestCase):
STREAM_NAME = "github"
URL_TEMPLATE = "/api/v1/external/github?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "github"
WEBHOOK_DIR_NAME = "github"
def test_ping_event(self) -> None:
expected_message = "GitHub webhook has been successfully configured by TomaszKolek."

View File

@@ -7,7 +7,7 @@ from zerver.lib.webhooks.git import COMMITS_LIMIT
class GitlabHookTests(WebhookTestCase):
STREAM_NAME = "gitlab"
URL_TEMPLATE = "/api/v1/external/gitlab?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "gitlab"
WEBHOOK_DIR_NAME = "gitlab"
def test_push_event_specified_topic(self) -> None:
self.url = self.build_webhook_url("topic=Specific%20topic")

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class GocdHookTests(WebhookTestCase):
STREAM_NAME = "gocd"
URL_TEMPLATE = "/api/v1/external/gocd?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "gocd"
WEBHOOK_DIR_NAME = "gocd"
TOPIC = "https://github.com/gocd/gocd"
def test_gocd_message(self) -> None:

View File

@@ -7,7 +7,7 @@ from zerver.lib.webhooks.git import COMMITS_LIMIT
class GogsHookTests(WebhookTestCase):
STREAM_NAME = "commits"
URL_TEMPLATE = "/api/v1/external/gogs?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "gogs"
WEBHOOK_DIR_NAME = "gogs"
def test_push(self) -> None:
expected_topic = "try-git / master"

View File

@@ -5,7 +5,7 @@ from zerver.webhooks.gosquared.view import CHAT_MESSAGE_TEMPLATE
class GoSquaredHookTests(WebhookTestCase):
STREAM_NAME = "gosquared"
URL_TEMPLATE = "/api/v1/external/gosquared?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "gosquared"
WEBHOOK_DIR_NAME = "gosquared"
# Note: Include a test function per each distinct message condition your integration supports
def test_traffic_message(self) -> None:

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class GrafanaHookTests(WebhookTestCase):
STREAM_NAME = "grafana"
URL_TEMPLATE = "/api/v1/external/grafana?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "grafana"
WEBHOOK_DIR_NAME = "grafana"
# Note: Include a test function per each distinct message condition your integration supports
def test_alert(self) -> None:

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class GreenhouseHookTests(WebhookTestCase):
STREAM_NAME = "greenhouse"
URL_TEMPLATE = "/api/v1/external/greenhouse?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "greenhouse"
WEBHOOK_DIR_NAME = "greenhouse"
CONTENT_TYPE = "application/x-www-form-urlencoded"
def test_message_candidate_hired(self) -> None:

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class GrooveHookTests(WebhookTestCase):
STREAM_NAME = "groove"
URL_TEMPLATE = "/api/v1/external/groove?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "groove"
WEBHOOK_DIR_NAME = "groove"
# This test simulates the condition when a new ticket comes.
def test_groove_ticket_started(self) -> None:

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class HarborHookTests(WebhookTestCase):
STREAM_NAME = "harbor"
URL_TEMPLATE = "/api/v1/external/harbor?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "harbor"
WEBHOOK_DIR_NAME = "harbor"
def test_push_image(self) -> None:
expected_topic = "example/test"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class HelloSignHookTests(WebhookTestCase):
STREAM_NAME = "hellosign"
URL_TEMPLATE = "/api/v1/external/hellosign?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "hellosign"
WEBHOOK_DIR_NAME = "hellosign"
def test_signatures_message(self) -> None:
expected_topic = "NDA with Acme Co."

View File

@@ -8,7 +8,7 @@ class HelloWorldHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/helloworld?&api_key={api_key}&stream={stream}"
PM_URL_TEMPLATE = "/api/v1/external/helloworld?&api_key={api_key}"
FIXTURE_DIR_NAME = "helloworld"
WEBHOOK_DIR_NAME = "helloworld"
# Note: Include a test function per each distinct message condition your integration supports
def test_hello_message(self) -> None:

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class HomeAssistantHookTests(WebhookTestCase):
STREAM_NAME = "homeassistant"
URL_TEMPLATE = "/api/v1/external/homeassistant?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "homeassistant"
WEBHOOK_DIR_NAME = "homeassistant"
def test_simplereq(self) -> None:
expected_topic = "homeassistant"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class IFTTTHookTests(WebhookTestCase):
STREAM_NAME = "ifttt"
URL_TEMPLATE = "/api/v1/external/ifttt?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "ifttt"
WEBHOOK_DIR_NAME = "ifttt"
def test_ifttt_when_subject_and_body_are_correct(self) -> None:
expected_topic = "Email sent from email@email.com"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class InspingHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/insping?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "insping"
WEBHOOK_DIR_NAME = "insping"
def test_website_state_available_message(self) -> None:
expected_topic = "insping"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class IntercomWebHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/intercom?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "intercom"
WEBHOOK_DIR_NAME = "intercom"
@patch("zerver.webhooks.intercom.view.check_send_webhook_message")
def test_ping_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:

View File

@@ -8,7 +8,7 @@ from zerver.lib.users import get_api_key
class JiraHookTests(WebhookTestCase):
STREAM_NAME = "jira"
URL_TEMPLATE = "/api/v1/external/jira?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "jira"
WEBHOOK_DIR_NAME = "jira"
def test_custom_stream(self) -> None:
api_key = get_api_key(self.test_user)

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class JotFormHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/jotform?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "jotform"
WEBHOOK_DIR_NAME = "jotform"
def test_response(self) -> None:
expected_title = "Form"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class JsonHookTests(WebhookTestCase):
STREAM_NAME = "json"
URL_TEMPLATE = "/api/v1/external/json?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "json"
WEBHOOK_DIR_NAME = "json"
def test_json_github_push__1_commit_message(self) -> None:
"""

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class LibratoHookTests(WebhookTestCase):
STREAM_NAME = "librato"
URL_TEMPLATE = "/api/v1/external/librato?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "librato"
WEBHOOK_DIR_NAME = "librato"
IS_ATTACHMENT = False
def get_body(self, fixture_name: str) -> str:

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class LidarrHookTests(WebhookTestCase):
STREAM_NAME = "lidarr"
URL_TEMPLATE = "/api/v1/external/lidarr?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "lidarr"
WEBHOOK_DIR_NAME = "lidarr"
def test_lidarr_test(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class MentionHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/mention?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "mention"
WEBHOOK_DIR_NAME = "mention"
def test_mention_webfeed(self) -> None:
expected_topic = "news"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class NetlifyHookTests(WebhookTestCase):
STREAM_NAME = "netlify"
URL_TEMPLATE = "/api/v1/external/netlify?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "netlify"
WEBHOOK_DIR_NAME = "netlify"
def test_building_message(self) -> None:
expected_topic = "master"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class NewRelicHookTests(WebhookTestCase):
STREAM_NAME = "newrelic"
URL_TEMPLATE = "/api/v1/external/newrelic?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "newrelic"
WEBHOOK_DIR_NAME = "newrelic"
def test_open(self) -> None:
expected_topic = "Test policy name (1234)"

View File

@@ -5,7 +5,7 @@ from zerver.webhooks.opbeat.view import get_value
class OpbeatHookTests(WebhookTestCase):
STREAM_NAME = "opbeat"
URL_TEMPLATE = "/api/v1/external/opbeat?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "opbeat"
WEBHOOK_DIR_NAME = "opbeat"
def test_comment(self) -> None:
expected_topic = "foo commented on E#2"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class OpsGenieHookTests(WebhookTestCase):
STREAM_NAME = "opsgenie"
URL_TEMPLATE = "/api/v1/external/opsgenie?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "opsgenie"
WEBHOOK_DIR_NAME = "opsgenie"
def test_acknowledge_alert(self) -> None:
expected_topic = "Integration1"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class PagerDutyHookTests(WebhookTestCase):
STREAM_NAME = "pagerduty"
URL_TEMPLATE = "/api/v1/external/pagerduty?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "pagerduty"
WEBHOOK_DIR_NAME = "pagerduty"
def test_trigger(self) -> None:
expected_message = "Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) triggered by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)).\n\n``` quote\nfoo\n```"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class PapertrailHookTests(WebhookTestCase):
STREAM_NAME = "papertrail"
URL_TEMPLATE = "/api/v1/external/papertrail?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "papertrail"
WEBHOOK_DIR_NAME = "papertrail"
def test_short_message(self) -> None:
expected_topic = "logs"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class PingdomHookTests(WebhookTestCase):
STREAM_NAME = "pingdom"
URL_TEMPLATE = "/api/v1/external/pingdom?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "pingdom"
WEBHOOK_DIR_NAME = "pingdom"
def test_pingdom_from_up_to_down_http_check_message(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class RadarrHookTests(WebhookTestCase):
STREAM_NAME = "radarr"
URL_TEMPLATE = "/api/v1/external/radarr?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "radarr"
WEBHOOK_DIR_NAME = "radarr"
def test_radarr_test(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class RaygunHookTests(WebhookTestCase):
STREAM_NAME = "raygun"
URL_TEMPLATE = "/api/v1/external/raygun?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "raygun"
WEBHOOK_DIR_NAME = "raygun"
def test_status_changed_message(self) -> None:
expected_topic = "test"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class ReviewBoardHookTests(WebhookTestCase):
STREAM_NAME = "reviewboard"
URL_TEMPLATE = "/api/v1/external/reviewboard?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "reviewboard"
WEBHOOK_DIR_NAME = "reviewboard"
def test_review_request_published(self) -> None:
expected_topic = "Scheduler"

View File

@@ -8,7 +8,7 @@ from zerver.lib.test_classes import WebhookTestCase
class SemaphoreHookTests(WebhookTestCase):
STREAM_NAME = "semaphore"
URL_TEMPLATE = "/api/v1/external/semaphore?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "semaphore"
WEBHOOK_DIR_NAME = "semaphore"
# Messages are generated by Semaphore on git push. The subject lines below
# contain information on the repo and branch, and the message has links and

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class SentryHookTests(WebhookTestCase):
STREAM_NAME = "sentry"
URL_TEMPLATE = "/api/v1/external/sentry?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "sentry"
WEBHOOK_DIR_NAME = "sentry"
def test_event_for_exception_golang(self) -> None:
expected_topic = '*url.Error: Get "bad_url": unsupported protocol scheme ""'

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class SlackWebhookTests(WebhookTestCase):
STREAM_NAME = "slack"
URL_TEMPLATE = "/api/v1/external/slack?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "slack"
WEBHOOK_DIR_NAME = "slack"
def test_slack_channel_to_topic(self) -> None:

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class SlackIncomingHookTests(WebhookTestCase):
STREAM_NAME = "slack_incoming"
URL_TEMPLATE = "/api/v1/external/slack_incoming?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "slack_incoming"
WEBHOOK_DIR_NAME = "slack_incoming"
def test_message(self) -> None:
expected_topic = "(no topic)"

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class SolanoHookTests(WebhookTestCase):
STREAM_NAME = "solano labs"
URL_TEMPLATE = "/api/v1/external/solano?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "solano"
WEBHOOK_DIR_NAME = "solano"
def test_solano_message_001(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class SonarrHookTests(WebhookTestCase):
STREAM_NAME = "sonarr"
URL_TEMPLATE = "/api/v1/external/sonarr?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "sonarr"
WEBHOOK_DIR_NAME = "sonarr"
def test_sonarr_test(self) -> None:
"""

View File

@@ -5,7 +5,7 @@ class SplunkHookTests(WebhookTestCase):
STREAM_NAME = "splunk"
URL_TEMPLATE = "/api/v1/external/splunk?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "splunk"
WEBHOOK_DIR_NAME = "splunk"
def test_splunk_search_one_result(self) -> None:
self.url = self.build_webhook_url(topic="New Search Alert")

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class StatuspageHookTests(WebhookTestCase):
STREAM_NAME = "statuspage-test"
URL_TEMPLATE = "/api/v1/external/statuspage?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "statuspage"
WEBHOOK_DIR_NAME = "statuspage"
def test_statuspage_incident(self) -> None:
expected_topic = "Database query delays: All Systems Operational"

View File

@@ -7,7 +7,7 @@ from zerver.lib.test_classes import WebhookTestCase
class StripeHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/stripe?&api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "stripe"
WEBHOOK_DIR_NAME = "stripe"
def test_charge_dispute_closed(self) -> None:
expected_topic = "disputes"

View File

@@ -5,7 +5,7 @@ class TaigaHookTests(WebhookTestCase):
STREAM_NAME = "taiga"
TOPIC = "subject"
URL_TEMPLATE = "/api/v1/external/taiga?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "taiga"
WEBHOOK_DIR_NAME = "taiga"
def setUp(self) -> None:
super().setUp()

View File

@@ -10,7 +10,7 @@ class TeamcityHookTests(WebhookTestCase):
STREAM_NAME = "teamcity"
URL_TEMPLATE = "/api/v1/external/teamcity?stream={stream}&api_key={api_key}"
TOPIC = "Project :: Compile"
FIXTURE_DIR_NAME = "teamcity"
WEBHOOK_DIR_NAME = "teamcity"
def test_teamcity_success(self) -> None:
expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
@@ -36,7 +36,7 @@ class TeamcityHookTests(WebhookTestCase):
def test_teamcity_personal(self) -> None:
expected_message = "Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
payload = orjson.dumps(
orjson.loads(self.webhook_fixture_data(self.FIXTURE_DIR_NAME, "personal"))
orjson.loads(self.webhook_fixture_data(self.WEBHOOK_DIR_NAME, "personal"))
)
self.client_post(self.url, payload, content_type="application/json")
msg = self.get_last_message()

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class ThinkstHookTests(WebhookTestCase):
STREAM_NAME = "thinkst"
URL_TEMPLATE = "/api/v1/external/thinkst?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "thinkst"
WEBHOOK_DIR_NAME = "thinkst"
def test_canary_dummy(self) -> None:
expected_message = (

View File

@@ -8,7 +8,7 @@ class TransifexHookTests(WebhookTestCase):
URL_TEMPLATE = "/api/v1/external/transifex?stream={stream}&api_key={api_key}"
URL_REVIEWED_METHOD_TEMPLATE = "reviewed=100"
URL_TRANSLATED_METHOD_TEMPLATE = "translated=100"
FIXTURE_DIR_NAME = "transifex"
WEBHOOK_DIR_NAME = "transifex"
PROJECT = "project-title"
LANGUAGE = "en"

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class TravisHookTests(WebhookTestCase):
STREAM_NAME = "travis"
URL_TEMPLATE = "/api/v1/external/travis?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "travis"
WEBHOOK_DIR_NAME = "travis"
TOPIC = "builds"
EXPECTED_MESSAGE = """
Author: josh_mandel

View File

@@ -9,7 +9,7 @@ from zerver.lib.test_classes import WebhookTestCase
class TrelloHookTests(WebhookTestCase):
STREAM_NAME = "trello"
URL_TEMPLATE = "/api/v1/external/trello?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "trello"
WEBHOOK_DIR_NAME = "trello"
def test_trello_confirmation_request(self) -> None:
response = self.client_head(self.build_webhook_url())

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class UpdownHookTests(WebhookTestCase):
STREAM_NAME = "updown"
URL_TEMPLATE = "/api/v1/external/updown?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "updown"
WEBHOOK_DIR_NAME = "updown"
def test_updown_check_down_event(self) -> None:
expected_topic = "https://updown.io"

View File

@@ -7,7 +7,7 @@ from zerver.webhooks.uptimerobot.view import MISCONFIGURED_PAYLOAD_ERROR_MESSAGE
class UptimeRobotHookTests(WebhookTestCase):
STREAM_NAME = "uptimerobot"
URL_TEMPLATE = "/api/v1/external/uptimerobot?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "uptimerobot"
WEBHOOK_DIR_NAME = "uptimerobot"
def test_uptimerobot_monitor_down(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class WordPressHookTests(WebhookTestCase):
STREAM_NAME = "wordpress"
URL_TEMPLATE = "/api/v1/external/wordpress?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "wordpress"
WEBHOOK_DIR_NAME = "wordpress"
def test_publish_post(self) -> None:

View File

@@ -6,7 +6,7 @@ from zerver.lib.test_classes import WebhookTestCase
class YoHookTests(WebhookTestCase):
STREAM_NAME = "yo"
URL_TEMPLATE = "/api/v1/external/yo?api_key={api_key}"
FIXTURE_DIR_NAME = "yo"
WEBHOOK_DIR_NAME = "yo"
def test_yo_message(self) -> None:
"""

View File

@@ -7,7 +7,7 @@ from zerver.webhooks.zabbix.view import MISCONFIGURED_PAYLOAD_ERROR_MESSAGE
class ZabbixHookTests(WebhookTestCase):
STREAM_NAME = "zabbix"
URL_TEMPLATE = "/api/v1/external/zabbix?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "zabbix"
WEBHOOK_DIR_NAME = "zabbix"
def test_zabbix_alert_message(self) -> None:
"""

View File

@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
class ZapierHookTests(WebhookTestCase):
STREAM_NAME = "zapier"
URL_TEMPLATE = "/api/v1/external/zapier?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "zapier"
WEBHOOK_DIR_NAME = "zapier"
def test_zapier_when_subject_and_body_are_correct(self) -> None:
expected_topic = "New email from zulip@zulip.com"
@@ -27,7 +27,7 @@ class ZapierHookTests(WebhookTestCase):
class ZapierZulipAppTests(WebhookTestCase):
STREAM_NAME = "zapier"
URL_TEMPLATE = "/api/v1/external/zapier?api_key={api_key}&stream={stream}"
FIXTURE_DIR_NAME = "zapier"
WEBHOOK_DIR_NAME = "zapier"
def test_auth(self) -> None:
payload = self.get_body("zapier_zulip_app_auth")