Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhooks/travis: Update fixtures.
sathwikshetty33ae9d3c5ece4b
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.pyindex 20669748d53..6ffb7a7e981 100644--- a/zerver/lib/integrations.py+++ b/zerver/lib/integrations.py@@ -936,7 +936,7 @@ INCOMING_WEBHOOK_INTEGRATIONS: list[IncomingWebhookIntegration] = [IncomingWebhookIntegration("travis",["continuous-integration"],- [WebhookScreenshotConfig("build.json", payload_as_query_param=True)],+ [WebhookScreenshotConfig("pull_request.json", payload_as_query_param=True)],display_name="Travis CI",),IncomingWebhookIntegration(diff --git a/zerver/webhooks/travis/fixtures/build.json b/zerver/webhooks/travis/fixtures/build.jsondeleted file mode 100644index 08d654d0f34..00000000000--- a/zerver/webhooks/travis/fixtures/build.json+++ /dev/null@@ -1,97 +0,0 @@-{- "id": 92495257,- "repository": {- "id": 2176580,- "name": "fhir-svn",- "owner_name": "hl7-fhir",- "url": null- },- "number": "4601",- "config": {- "language": "java",- "jdk": [- "oraclejdk8"- ],- "script": "./build.sh",- "sudo": false,- "notifications": {- "email": [ ],- "webhooks": [- "https://zulip.example.com/api/v1/external/travis?stream=travis&/topic=builds&api_key=abcdefg"- ]- },- "after_success": [ ],- "env": [- "[One+of+the+secure+variables+in+your+.travis.yml+has+an+invalid+format.]"- ],- ".result": "configured"- },- "status": 0,- "result": 0,- "status_message": "Passed",- "result_message": "Passed",- "started_at": "2015-11-21T23:28:22Z",- "finished_at": "2015-11-21T23:45:25Z",- "duration": 1023,- "build_url": "https://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257",- "commit_id": 26300989,- "commit": "6c457d366a31696c989c011ab75b734d8485a9ba",- "base_commit": null,- "head_commit": null,- "branch": "master",- "message": "Debug+build+hooks\n\ngit-svn-id:+http://gforge.hl7.org/svn/fhir/trunk/build@7323+2f0db536-2c49-4257-a3fa-e771ed206c19",- "compare_url": "https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6c457d366a31",- "committed_at": "2015-11-21T23:27:13Z",- "author_name": "josh_mandel",- "author_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "committer_name": "josh_mandel",- "committer_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "matrix": [- {- "id": 92495258,- "repository_id": 2176580,- "parent_id": 92495257,- "number": "4601.1",- "state": "finished",- "config": {- "language": "java",- "jdk": "oraclejdk8",- "script": "./build.sh",- "sudo": false,- "notifications": {- "email": [ ],- "webhooks": [- "https://zulip.example.com/api/v1/external/travis?stream=travis&topic=builds&api_key=abcdefg"- ]- },- "after_success": [ ],- ".result": "configured",- "global_env": [ ],- "language": "ruby",- "group": "stable",- "dist": "precise",- "os": "linux"- },- "status": 0,- "result": 0,- "commit": "6c457d366a31696c989c011ab75b734d8485a9ba",- "branch": "master",- "message": "Debug+build+hooks\n\ngit-svn-id:+http://gforge.hl7.org/svn/fhir/trunk/build@7323+2f0db536-2c49-4257-a3fa-e771ed206c19",- "compare_url": "https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6c457d366a31",- "started_at": "2015-11-21T23:28:22Z",- "finished_at": "2015-11-21T23:45:25Z",- "committed_at": "2015-11-21T23:27:13Z",- "author_name": "josh_mandel",- "author_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "committer_name": "josh_mandel",- "committer_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "allow_failure": false- }- ],- "type": "push",- "state": "passed",- "pull_request": false,- "pull_request_number": null,- "pull_request_title": null,- "tag": null-}diff --git a/zerver/webhooks/travis/fixtures/non_pull_request.json b/zerver/webhooks/travis/fixtures/non_pull_request.jsonnew file mode 100644index 00000000000..502f674f27e--- /dev/null+++ b/zerver/webhooks/travis/fixtures/non_pull_request.json@@ -0,0 +1,83 @@+{+ "id": 277712204,+ "number": "1",+ "config": {+ "language": "ruby",+ "os": [+ "linux"+ ],+ "dist": "focal",+ "notifications": {+ "webhooks": [+ {+ "urls": [+ "https://338d-49-37-250-23.ngrok-free.app/api/v1/external/travis?api_key=qgbRyggtXVwFxCWeEwRS2sCeyfMleyFZ&stream=12"+ ],+ "on_success": "always",+ "on_failure": "always",+ "on_start": "always"+ }+ ]+ }+ },+ "type": "push",+ "state": "started",+ "status": null,+ "result": null,+ "status_message": "Pending",+ "result_message": "Pending",+ "started_at": "2026-03-18T08:16:56Z",+ "finished_at": null,+ "duration": null,+ "build_url": "https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277712204",+ "commit_id": 1277737906,+ "commit": "193da1b723460e185115a27554dfddab7ae0ec6e",+ "base_commit": null,+ "head_commit": null,+ "branch": "main",+ "message": "Add Projects model.",+ "compare_url": "https://github.com/sathwikshetty33/travis-test/commit/193da1b72346",+ "committed_at": "2026-03-18T08:16:12Z",+ "author_name": "sathwikshetty33",+ "author_email": "[email protected]",+ "committer_name": "sathwikshetty33",+ "committer_email": "[email protected]",+ "pull_request": false,+ "pull_request_number": null,+ "pull_request_title": null,+ "tag": null,+ "repository": {+ "id": 29853331,+ "name": "travis-test",+ "owner_name": "sathwikshetty33",+ "url": null+ },+ "matrix": [+ {+ "id": 638473449,+ "repository_id": 29853331,+ "parent_id": 277712204,+ "number": "1.1",+ "state": "started",+ "config": {+ "os": "linux",+ "language": "ruby",+ "dist": "focal"+ },+ "status": null,+ "result": null,+ "commit": "193da1b723460e185115a27554dfddab7ae0ec6e",+ "branch": "main",+ "message": "Add Projects model.",+ "compare_url": "https://github.com/sathwikshetty33/travis-test/commit/193da1b72346",+ "started_at": "2026-03-18T08:16:56Z",+ "finished_at": null,+ "committed_at": "2026-03-18T08:16:12Z",+ "author_name": "sathwikshetty33",+ "author_email": "[email protected]",+ "committer_name": "sathwikshetty33",+ "committer_email": "[email protected]",+ "allow_failure": null+ }+ ]+}diff --git a/zerver/webhooks/travis/fixtures/pull_request.json b/zerver/webhooks/travis/fixtures/pull_request.jsonindex 4d832118ead..10022e02c82 100644--- a/zerver/webhooks/travis/fixtures/pull_request.json+++ b/zerver/webhooks/travis/fixtures/pull_request.json@@ -1,97 +1,83 @@{- "id": 92495257,- "repository": {- "id": 2176580,- "name": "fhir-svn",- "owner_name": "hl7-fhir",- "url": null- },- "number": "4601",+ "id": 277927122,+ "number": "42","config": {- "language": "java",- "jdk": [- "oraclejdk8"+ "language": "ruby",+ "os": [+ "linux"],- "script": "./build.sh",- "sudo": false,+ "dist": "focal","notifications": {- "email": [ ],"webhooks": [- "https://zulip.example.com/api/v1/external/travis?stream=travis&/topic=builds&api_key=abcdefg"+ {+ "urls": [+ "https://41da-49-37-250-179.ngrok-free.app/api/v1/external/travis?api_key=pDmnOb1fCfy181J2aTz8k2FI3dlxcXEV&stream=7"+ ],+ "on_success": "always",+ "on_failure": "always",+ "on_start": "always"+ }]- },- "after_success": [ ],- "env": [- "[One+of+the+secure+variables+in+your+.travis.yml+has+an+invalid+format.]"- ],- ".result": "configured"+ }+ },+ "type": "pull_request",+ "state": "failed",+ "status": 1,+ "result": 1,+ "status_message": "Failed",+ "result_message": "Failed",+ "started_at": "2026-04-15T16:39:52Z",+ "finished_at": "2026-04-15T16:40:15Z",+ "duration": 23,+ "build_url": "https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277927122",+ "commit_id": 1291891363,+ "commit": "853c38dfecb99b75e9d4987fba0c4f58eab0bae3",+ "base_commit": "6864d112b255e2c26cfc48882594397c4e561bab",+ "head_commit": "b2b0af11c1d6e03fe390050a97506c0a2f437d5a",+ "branch": "main",+ "message": "feat: Created Name.txt.",+ "compare_url": "https://github.com/sathwikshetty33/travis-test/pull/2",+ "committed_at": "2026-04-15T16:38:07Z",+ "author_name": "Sathwik Shetty",+ "author_email": "[email protected]",+ "committer_name": "GitHub",+ "committer_email": "[email protected]",+ "pull_request": true,+ "pull_request_number": 2,+ "pull_request_title": "feat: Add Name.txt.",+ "tag": null,+ "repository": {+ "id": 29853331,+ "name": "travis-test",+ "owner_name": "sathwikshetty33",+ "url": null},- "status": 0,- "result": 0,- "status_message": "Passed",- "result_message": "Passed",- "started_at": "2015-11-21T23:28:22Z",- "finished_at": "2015-11-21T23:45:25Z",- "duration": 1023,- "build_url": "https://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257",- "commit_id": 26300989,- "commit": "6c457d366a31696c989c011ab75b734d8485a9ba",- "base_commit": null,- "head_commit": null,- "branch": "master",- "message": "Debug+build+hooks\n\ngit-svn-id:+http://gforge.hl7.org/svn/fhir/trunk/build@7323+2f0db536-2c49-4257-a3fa-e771ed206c19",- "compare_url": "https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6c457d366a31",- "committed_at": "2015-11-21T23:27:13Z",- "author_name": "josh_mandel",- "author_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "committer_name": "josh_mandel",- "committer_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19","matrix": [{- "id": 92495258,- "repository_id": 2176580,- "parent_id": 92495257,- "number": "4601.1",- "state": "finished",+ "id": 638911273,+ "repository_id": 29853331,+ "parent_id": 277927122,+ "number": "42.1",+ "state": "failed","config": {- "language": "java",- "jdk": "oraclejdk8",- "script": "./build.sh",- "sudo": false,- "notifications": {- "email": [ ],- "webhooks": [- "https://zulip.example.com/api/v1/external/travis?stream=travis&topic=builds&api_key=abcdefg"- ]- },- "after_success": [ ],- ".result": "configured",- "global_env": [ ],+ "os": "linux","language": "ruby",- "group": "stable",- "dist": "precise",- "os": "linux"+ "dist": "focal"},- "status": 0,- "result": 0,- "commit": "6c457d366a31696c989c011ab75b734d8485a9ba",- "branch": "master",- "message": "Debug+build+hooks\n\ngit-svn-id:+http://gforge.hl7.org/svn/fhir/trunk/build@7323+2f0db536-2c49-4257-a3fa-e771ed206c19",- "compare_url": "https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6c457d366a31",- "started_at": "2015-11-21T23:28:22Z",- "finished_at": "2015-11-21T23:45:25Z",- "committed_at": "2015-11-21T23:27:13Z",- "author_name": "josh_mandel",- "author_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "committer_name": "josh_mandel",- "committer_email": "josh_mandel@2f0db536-2c49-4257-a3fa-e771ed206c19",- "allow_failure": false+ "status": 1,+ "result": 1,+ "commit": "853c38dfecb99b75e9d4987fba0c4f58eab0bae3",+ "branch": "main",+ "message": "feat: Created Name.txt.",+ "compare_url": "https://github.com/sathwikshetty33/travis-test/pull/2",+ "started_at": "2026-04-15T16:39:52Z",+ "finished_at": "2026-04-15T16:40:15Z",+ "committed_at": "2026-04-15T16:38:07Z",+ "author_name": "Sathwik Shetty",+ "author_email": "[email protected]",+ "committer_name": "GitHub",+ "committer_email": "[email protected]",+ "allow_failure": null}- ],- "type": "pull_request",- "state": "passed",- "pull_request": false,- "pull_request_number": null,- "pull_request_title": null,- "tag": null+ ]}diff --git a/zerver/webhooks/travis/tests.py b/zerver/webhooks/travis/tests.pyindex 375bc723563..75af2ab9bd8 100644--- a/zerver/webhooks/travis/tests.py+++ b/zerver/webhooks/travis/tests.py@@ -7,10 +7,16 @@ from zerver.lib.test_classes import WebhookTestCaseclass TravisHookTests(WebhookTestCase):TOPIC_NAME = "builds"- EXPECTED_MESSAGE = """-Author: josh_mandel-Build status: Passed :thumbs_up:-Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6c457d366a31), [build log](https://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)+ EXPECTED_NON_PULL_REQUEST_MESSAGE = """+Author: sathwikshetty33+Build status: Pending :counterclockwise:+Details: [changes](https://github.com/sathwikshetty33/travis-test/commit/193da1b72346), [build log](https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277712204)+""".strip()++ EXPECTED_PULL_REQUEST_MESSAGE = """+Author: Sathwik Shetty+Build status: Failed :thumbs_down:+Details: [changes](https://github.com/sathwikshetty33/travis-test/pull/2), [build log](https://app.travis-ci.com/sathwikshetty33/travis-test/builds/277927122)""".strip()def test_travis_message(self) -> None:@@ -22,9 +28,9 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6"""self.check_webhook(- "build",+ "non_pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_NON_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)@@ -34,12 +40,12 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6self.check_webhook("pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)self.check_webhook(- "build",+ "non_pull_request",content_type="application/x-www-form-urlencoded",expect_noop=True,)@@ -54,9 +60,9 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6)self.check_webhook(- "build",+ "non_pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_NON_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)@@ -64,9 +70,9 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6self.url = f'{self.build_webhook_url()}&only_events=["push"]'self.check_webhook(- "build",+ "non_pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_NON_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)@@ -80,7 +86,7 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6self.url = f'{self.build_webhook_url()}&exclude_events=["push"]'self.check_webhook(- "build",+ "non_pull_request",content_type="application/x-www-form-urlencoded",expect_noop=True,)@@ -88,7 +94,7 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6self.check_webhook("pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)@@ -98,14 +104,14 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6self.check_webhook("pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)self.check_webhook(- "build",+ "non_pull_request",self.TOPIC_NAME,- self.EXPECTED_MESSAGE,+ self.EXPECTED_NON_PULL_REQUEST_MESSAGE,content_type="application/x-www-form-urlencoded",)@@ -119,7 +125,7 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6)self.check_webhook(- "build",+ "non_pull_request",content_type="application/x-www-form-urlencoded",expect_noop=True,)@@ -133,7 +139,9 @@ one or more new messages.with self.assertRaises(Exception) as exc:self.check_webhook(- "build", content_type="application/x-www-form-urlencoded", expect_noop=True+ "non_pull_request",+ content_type="application/x-www-form-urlencoded",+ expect_noop=True,)self.assertEqual(str(exc.exception), expected_error_message)