|
@@ -1,7 +1,37 @@
|
|
|
|
+from django.core.urlresolvers import reverse
|
|
from django.test import TestCase
|
|
from django.test import TestCase
|
|
|
|
+from django.test.client import RequestFactory
|
|
from misago.views.utils import is_request_to_misago
|
|
from misago.views.utils import is_request_to_misago
|
|
|
|
|
|
-class MisagoExceptionHandlerTests(TestCase):
|
|
|
|
|
|
+
|
|
|
|
+VALID_PATHS = (
|
|
|
|
+ "/",
|
|
|
|
+ "/threads/",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+INVALID_PATHS = (
|
|
|
|
+ "",
|
|
|
|
+ "somewhere/",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class IsRequestToMisagoTests(TestCase):
|
|
def test_is_request_to_misago(self):
|
|
def test_is_request_to_misago(self):
|
|
- """is_request_to_misago correctly detects requests directed at Misago"""
|
|
|
|
- self.fail("Not yet implemented")
|
|
|
|
|
|
+ """
|
|
|
|
+ is_request_to_misago correctly detects requests directed at Misago
|
|
|
|
+ """
|
|
|
|
+ misago_prefix = reverse('forum_index')
|
|
|
|
+
|
|
|
|
+ for path in VALID_PATHS:
|
|
|
|
+ request = RequestFactory().get('/')
|
|
|
|
+ request.path_info = path
|
|
|
|
+ self.assertTrue(
|
|
|
|
+ is_request_to_misago(request),
|
|
|
|
+ '"%s" is not overlapped by "%s"' % (path, misago_prefix))
|
|
|
|
+
|
|
|
|
+ for path in INVALID_PATHS:
|
|
|
|
+ request = RequestFactory().get('/')
|
|
|
|
+ request.path_info = path
|
|
|
|
+ self.assertFalse(
|
|
|
|
+ is_request_to_misago(request),
|
|
|
|
+ '"%s" is overlapped by "%s"' % (path, misago_prefix))
|