Add test coverage for /notify_tornado.

We now have test coverage for all of our endpoints.
This commit is contained in:
Steve Howell
2016-11-17 07:52:28 -08:00
committed by Tim Abbott
parent 059cd1e7aa
commit 3a8282ff44
2 changed files with 45 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ from contextlib import contextmanager
from typing import (cast, Any, Callable, Dict, Generator, Iterable, List, Mapping, Optional,
Sized, Tuple, Union)
from django.core.urlresolvers import resolve
from django.conf import settings
from django.test import TestCase
from django.test.client import (
@@ -134,6 +135,21 @@ class ZulipTestCase(TestCase):
django_client = self.client # see WRAPPER_COMMENT
return django_client.post(url, info, **kwargs)
@instrument_url
def client_post_request(self, url, req):
# type: (text_type, Any) -> HttpResponse
"""
We simulate hitting an endpoint here, although we
actually resolve the URL manually and hit the view
directly. We have this helper method to allow our
instrumentation to work for /notify_tornado and
future similar methods that require doing funny
things to a request object.
"""
match = resolve(url)
return match.func(req)
@instrument_url
def client_get(self, url, info={}, **kwargs):
# type: (text_type, Dict[str, Any], **Any) -> HttpResponse