Skip to content

Commit

Permalink
wsgi: test /osm/webhooks routing
Browse files Browse the repository at this point in the history
Tested-by: Travis
  • Loading branch information
vmiklos authored and Travis CI committed Jan 27, 2020
1 parent a3cd5a3 commit 0f6f08d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_wsgi.py
Expand Up @@ -23,9 +23,12 @@
import urllib.error
import xml.etree.ElementTree as ET

import yattag

import areas
import webframe
import wsgi
import util

if TYPE_CHECKING:
# pylint: disable=no-name-in-module,import-error,unused-import
Expand Down Expand Up @@ -540,6 +543,20 @@ def mock_subprocess_run(args: List[str], check: bool) -> None:
self.assertEqual(actual_args[-1], "deploy-pythonanywhere")
self.assertTrue(actual_check)

def test_route(self) -> None:
"""Tests the /osm/webhooks/github -> handle_github_webhook() routing."""

mock_called = False

def mock_handler(_environ: Dict[str, BinaryIO]) -> yattag.Doc:
nonlocal mock_called
mock_called = True
return util.html_escape("")

with unittest.mock.patch("wsgi.handle_github_webhook", mock_handler):
self.get_dom_for_path("/osm/webhooks/github")
self.assertTrue(mock_called)


class TestStatic(TestWsgi):
"""Tests /osm/static/."""
Expand Down

0 comments on commit 0f6f08d

Please sign in to comment.