summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/requests/tests.py13
-rw-r--r--tests/utils_tests/test_encoding.py14
2 files changed, 25 insertions, 2 deletions
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index 36d1d80a69..22b3021d1f 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -35,6 +35,19 @@ class RequestsTests(SimpleTestCase):
# and FILES should be MultiValueDict
self.assertEqual(request.FILES.getlist('foo'), [])
+ def test_httprequest_full_path(self):
+ request = HttpRequest()
+ request.path = request.path_info = '/;some/?awful/=path/foo:bar/'
+ request.META['QUERY_STRING'] = ';some=query&+query=string'
+ expected = '/%3Bsome/%3Fawful/%3Dpath/foo:bar/?;some=query&+query=string'
+ self.assertEqual(request.get_full_path(), expected)
+
+ def test_httprequest_full_path_with_query_string_and_fragment(self):
+ request = HttpRequest()
+ request.path = request.path_info = '/foo#bar'
+ request.META['QUERY_STRING'] = 'baz#quux'
+ self.assertEqual(request.get_full_path(), '/foo%23bar?baz#quux')
+
def test_httprequest_repr(self):
request = HttpRequest()
request.path = '/somepath/'
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py
index 1685c82def..3119b6467a 100644
--- a/tests/utils_tests/test_encoding.py
+++ b/tests/utils_tests/test_encoding.py
@@ -5,8 +5,10 @@ import unittest
import datetime
from django.utils import six
-from django.utils.encoding import (filepath_to_uri, force_bytes, force_text,
- iri_to_uri, uri_to_iri)
+from django.utils.encoding import (
+ filepath_to_uri, force_bytes, force_text, escape_uri_path,
+ iri_to_uri, uri_to_iri,
+)
from django.utils.http import urlquote_plus
@@ -40,6 +42,14 @@ class TestEncodingUtils(unittest.TestCase):
today = datetime.date.today()
self.assertEqual(force_bytes(today, strings_only=True), today)
+ def test_escape_uri_path(self):
+ self.assertEqual(
+ escape_uri_path('/;some/=awful/?path/:with/@lots/&of/+awful/chars'),
+ '/%3Bsome/%3Dawful/%3Fpath/:with/@lots/&of/+awful/chars'
+ )
+ self.assertEqual(escape_uri_path('/foo#bar'), '/foo%23bar')
+ self.assertEqual(escape_uri_path('/foo?bar'), '/foo%3Fbar')
+
class TestRFC3987IEncodingUtils(unittest.TestCase):