From a9ce02348ba7dcdb736c91e0afda7e0a61551003 Mon Sep 17 00:00:00 2001 From: Adam Sah <140002+asah@users.noreply.github.com> Date: Fri, 29 Apr 2022 11:17:50 +0000 Subject: [PATCH] testing: Improve backend code coverage for semaphore webhook. --- tools/test-backend | 1 - .../webhooks/semaphore/fixtures/unknown.json | 25 +++++++++++++++++++ zerver/webhooks/semaphore/tests.py | 10 ++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 zerver/webhooks/semaphore/fixtures/unknown.json diff --git a/tools/test-backend b/tools/test-backend index 97491d206e..28b71b6be4 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -133,7 +133,6 @@ not_yet_fully_covered = [ "zerver/webhooks/jira/view.py", "zerver/webhooks/librato/view.py", "zerver/webhooks/pivotal/view.py", - "zerver/webhooks/semaphore/view.py", "zerver/webhooks/solano/view.py", "zerver/webhooks/teamcity/view.py", "zerver/webhooks/travis/view.py", diff --git a/zerver/webhooks/semaphore/fixtures/unknown.json b/zerver/webhooks/semaphore/fixtures/unknown.json new file mode 100644 index 0000000000..ca422e07e9 --- /dev/null +++ b/zerver/webhooks/semaphore/fixtures/unknown.json @@ -0,0 +1,25 @@ +{ + "project_name":"knighthood", + "project_hash_id":"dff749fa-6acf-467c-85c9-119d63c8af4b", + "server_name":"lamancha-271", + "number":17, + "event":"unknown", + "result":"passed", + "created_at":"2016-06-17T00:59:09Z", + "updated_at":"2016-06-17T01:00:11Z", + "started_at":"2016-06-17T00:59:11Z", + "finished_at":"2016-06-17T00:59:21Z", + "html_url":"https://semaphoreci.com/donquixote/knighthood/servers/lamancha-271/deploys/17", + "build_number":314, + "build_html_url":"https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314", + "branch_name":"master", + "branch_html_url":"https://semaphoreci.com/donquixote/knighthood/branches/master", + "commit":{ + "id":"a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf", + "url":"https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf", + "author_name":"Don Quixote", + "author_email":"don@lamancha.com", + "message":"Create user account for Rocinante\n\nThe user is an admin user", + "timestamp":"2016-06-16T18:29:08Z" + } +} diff --git a/zerver/webhooks/semaphore/tests.py b/zerver/webhooks/semaphore/tests.py index 0f638f77ba..13fcbf12aa 100644 --- a/zerver/webhooks/semaphore/tests.py +++ b/zerver/webhooks/semaphore/tests.py @@ -117,6 +117,16 @@ class SemaphoreHookTests(WebhookTestCase): "tag", expected_topic, expected_message, content_type="application/json" ) + def test_semaphore_unknown(self) -> None: + expected_topic = "knighthood/master" + expected_message = "unknown: passed" + self.check_webhook( + "unknown", + expected_topic, + expected_message, + content_type="application/x-www-form-urlencoded", + ) + def test_semaphore_unknown_event(self) -> None: expected_topic = "notifications" expected_message = """