diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-01-02 16:57:53 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-01-02 16:57:53 +0000 |
| commit | 7e322b5908bf5ec255c90c615d1b45b358ecee5f (patch) | |
| tree | 3390dc70c5b4c4a8ff583308bd904eb749f97c04 /tests/regressiontests | |
| parent | ef0f46f1d0b9e41c811d3d6b833f1652ad46aec3 (diff) | |
gis: Merged revisions 6920-6989 via svnmerge from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6990 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/forms/localflavor/ca.py | 6 | ||||
| -rw-r--r-- | tests/regressiontests/forms/localflavor/cl.py | 8 | ||||
| -rw-r--r-- | tests/regressiontests/forms/localflavor/uk.py | 29 | ||||
| -rw-r--r-- | tests/regressiontests/httpwrappers/tests.py | 38 | ||||
| -rw-r--r-- | tests/regressiontests/templates/filters.py | 4 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 12 | ||||
| -rw-r--r-- | tests/regressiontests/views/media/file.unknown | 1 | ||||
| -rw-r--r-- | tests/regressiontests/views/tests/static.py | 8 |
8 files changed, 86 insertions, 20 deletions
diff --git a/tests/regressiontests/forms/localflavor/ca.py b/tests/regressiontests/forms/localflavor/ca.py index a13a6de65f..48171b0558 100644 --- a/tests/regressiontests/forms/localflavor/ca.py +++ b/tests/regressiontests/forms/localflavor/ca.py @@ -213,13 +213,13 @@ u'046-454-286' >>> f.clean('046-454-287') Traceback (most recent call last): ... -ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'] +ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'] >>> f.clean('046 454 286') Traceback (most recent call last): ... -ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'] +ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'] >>> f.clean('046-44-286') Traceback (most recent call last): ... -ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'] +ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'] """ diff --git a/tests/regressiontests/forms/localflavor/cl.py b/tests/regressiontests/forms/localflavor/cl.py index 407f6610e4..23e7a41902 100644 --- a/tests/regressiontests/forms/localflavor/cl.py +++ b/tests/regressiontests/forms/localflavor/cl.py @@ -41,7 +41,7 @@ Strict RUT usage (does not allow imposible values) >>> rut.clean('11-6') Traceback (most recent call last): ... -ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.'] +ValidationError: [u'Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'] # valid format, bad verifier. >>> rut.clean('11.111.111-0') @@ -53,17 +53,17 @@ ValidationError: [u'The Chilean RUT is not valid.'] >>> rut.clean('767484100') Traceback (most recent call last): ... -ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.'] +ValidationError: [u'Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'] >>> rut.clean('78.412.790-7') u'78.412.790-7' >>> rut.clean('8.334.6043') Traceback (most recent call last): ... -ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.'] +ValidationError: [u'Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'] >>> rut.clean('76793310-K') Traceback (most recent call last): ... -ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.'] +ValidationError: [u'Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.'] ## CLRegionSelect ######################################################### >>> from django.contrib.localflavor.cl.forms import CLRegionSelect diff --git a/tests/regressiontests/forms/localflavor/uk.py b/tests/regressiontests/forms/localflavor/uk.py index d7848f70a8..258c22e5a9 100644 --- a/tests/regressiontests/forms/localflavor/uk.py +++ b/tests/regressiontests/forms/localflavor/uk.py @@ -12,13 +12,15 @@ u'BT32 4PX' >>> f.clean('GIR 0AA') u'GIR 0AA' >>> f.clean('BT324PX') +u'BT32 4PX' +>>> f.clean('1NV 4L1D') Traceback (most recent call last): ... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] ->>> f.clean('1NV 4L1D') +ValidationError: [u'Enter a valid postcode.'] +>>> f.clean('1NV4L1D') Traceback (most recent call last): ... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] +ValidationError: [u'Enter a valid postcode.'] >>> f.clean(None) Traceback (most recent call last): ... @@ -27,7 +29,20 @@ ValidationError: [u'This field is required.'] Traceback (most recent call last): ... ValidationError: [u'This field is required.'] - +>>> f.clean(' so11aa ') +u'SO1 1AA' +>>> f.clean(' so1 1aa ') +u'SO1 1AA' +>>> f.clean('G2 3wt') +u'G2 3WT' +>>> f.clean('EC1A 1BB') +u'EC1A 1BB' +>>> f.clean('Ec1a1BB') +u'EC1A 1BB' +>>> f.clean(' b0gUS') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid postcode.'] >>> f = UKPostcodeField(required=False) >>> f.clean('BT32 4PX') u'BT32 4PX' @@ -36,11 +51,9 @@ u'GIR 0AA' >>> f.clean('1NV 4L1D') Traceback (most recent call last): ... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] +ValidationError: [u'Enter a valid postcode.'] >>> f.clean('BT324PX') -Traceback (most recent call last): -... -ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.'] +u'BT32 4PX' >>> f.clean(None) u'' >>> f.clean('') diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py index 5cfae029bb..31b956a99d 100644 --- a/tests/regressiontests/httpwrappers/tests.py +++ b/tests/regressiontests/httpwrappers/tests.py @@ -391,9 +391,45 @@ u'\ufffd' >>> q.getlist('foo') [u'bar', u'\ufffd'] + +###################################### +# HttpResponse with Unicode headers # +###################################### + +>>> r = HttpResponse() + +If we insert a unicode value it will be converted to an ascii +string. This makes sure we comply with the HTTP specifications. + +>>> r['value'] = u'test value' +>>> isinstance(r['value'], str) +True + +An error is raised When a unicode object with non-ascii is assigned. + +>>> r['value'] = u't\xebst value' # doctest:+ELLIPSIS +Traceback (most recent call last): +... +UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format + +The response also converts unicode keys to strings. + +>>> r[u'test'] = 'testing key' +>>> l = list(r.items()) +>>> l.sort() +>>> l[1] +('test', 'testing key') + +It will also raise errors for keys with non-ascii data. + +>>> r[u't\xebst'] = 'testing key' # doctest:+ELLIPSIS +Traceback (most recent call last): +... +UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format + """ -from django.http import QueryDict +from django.http import QueryDict, HttpResponse if __name__ == "__main__": import doctest diff --git a/tests/regressiontests/templates/filters.py b/tests/regressiontests/templates/filters.py index 4175bdbe5f..f38b2cdef1 100644 --- a/tests/regressiontests/templates/filters.py +++ b/tests/regressiontests/templates/filters.py @@ -108,8 +108,8 @@ def get_filter_tests(): 'filter-urlize05': ('{% autoescape off %}{{ a|urlize }}{% endautoescape %}', {"a": "<script>alert('foo')</script>"}, "<script>alert('foo')</script>"), 'filter-urlize06': ('{{ a|urlize }}', {"a": "<script>alert('foo')</script>"}, '<script>alert('foo')</script>'), - 'filter-urlizetrunc01': ('{% autoescape off %}{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}{% endautoescape %}', {"a": "http://example.com/x=&y=", "b": mark_safe("http://example.com?x=&y=")}, u'<a href="http://example.com/x=&y=" rel="nofollow">http:...</a> <a href="http://example.com?x=&y=" rel="nofollow">http:...</a>'), - 'filter-urlizetrunc02': ('{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}', {"a": "http://example.com/x=&y=", "b": mark_safe("http://example.com?x=&y=")}, u'<a href="http://example.com/x=&y=" rel="nofollow">http:...</a> <a href="http://example.com?x=&y=" rel="nofollow">http:...</a>'), + 'filter-urlizetrunc01': ('{% autoescape off %}{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}{% endautoescape %}', {"a": '"Unsafe" http://example.com/x=&y=', "b": mark_safe('"Safe" http://example.com?x=&y=')}, u'"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">http:...</a> "Safe" <a href="http://example.com?x=&y=" rel="nofollow">http:...</a>'), + 'filter-urlizetrunc02': ('{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}', {"a": '"Unsafe" http://example.com/x=&y=', "b": mark_safe('"Safe" http://example.com?x=&y=')}, u'"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">http:...</a> "Safe" <a href="http://example.com?x=&y=" rel="nofollow">http:...</a>'), 'filter-wordcount01': ('{% autoescape off %}{{ a|wordcount }} {{ b|wordcount }}{% endautoescape %}', {"a": "a & b", "b": mark_safe("a & b")}, "3 3"), 'filter-wordcount02': ('{{ a|wordcount }} {{ b|wordcount }}', {"a": "a & b", "b": mark_safe("a & b")}, "3 3"), diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 846023afc9..ef8fd43292 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -441,6 +441,8 @@ class Templates(unittest.TestCase): 'for-tag-vars02': ("{% for val in values %}{{ forloop.counter0 }}{% endfor %}", {"values": [6, 6, 6]}, "012"), 'for-tag-vars03': ("{% for val in values %}{{ forloop.revcounter }}{% endfor %}", {"values": [6, 6, 6]}, "321"), 'for-tag-vars04': ("{% for val in values %}{{ forloop.revcounter0 }}{% endfor %}", {"values": [6, 6, 6]}, "210"), + 'for-tag-vars05': ("{% for val in values %}{% if forloop.first %}f{% else %}x{% endif %}{% endfor %}", {"values": [6, 6, 6]}, "fxx"), + 'for-tag-vars06': ("{% for val in values %}{% if forloop.last %}l{% else %}x{% endif %}{% endfor %}", {"values": [6, 6, 6]}, "xxl"), 'for-tag-unpack01': ("{% for key,value in items %}{{ key }}:{{ value }}/{% endfor %}", {"items": (('one', 1), ('two', 2))}, "one:1/two:2/"), 'for-tag-unpack03': ("{% for key, value in items %}{{ key }}:{{ value }}/{% endfor %}", {"items": (('one', 1), ('two', 2))}, "one:1/two:2/"), 'for-tag-unpack04': ("{% for key , value in items %}{{ key }}:{{ value }}/{% endfor %}", {"items": (('one', 1), ('two', 2))}, "one:1/two:2/"), @@ -807,6 +809,16 @@ class Templates(unittest.TestCase): '{% endfor %},' + \ '{% endfor %}', {}, ''), + + # Test syntax. + 'regroup03': ('{% regroup data by bar as %}', {}, + template.TemplateSyntaxError), + 'regroup04': ('{% regroup data by bar thisaintright grouped %}', {}, + template.TemplateSyntaxError), + 'regroup05': ('{% regroup data thisaintright bar as grouped %}', {}, + template.TemplateSyntaxError), + 'regroup06': ('{% regroup data by bar as grouped toomanyargs %}', {}, + template.TemplateSyntaxError), ### TEMPLATETAG TAG ####################################################### 'templatetag01': ('{% templatetag openblock %}', {}, '{%'), diff --git a/tests/regressiontests/views/media/file.unknown b/tests/regressiontests/views/media/file.unknown new file mode 100644 index 0000000000..77dcda8970 --- /dev/null +++ b/tests/regressiontests/views/media/file.unknown @@ -0,0 +1 @@ +An unknown file extension. diff --git a/tests/regressiontests/views/tests/static.py b/tests/regressiontests/views/tests/static.py index c731b249e8..d7e87d19d2 100644 --- a/tests/regressiontests/views/tests/static.py +++ b/tests/regressiontests/views/tests/static.py @@ -13,11 +13,15 @@ class StaticTests(TestCase): response = self.client.get('/views/site_media/%s' % filename) file = open(path.join(media_dir, filename)) self.assertEquals(file.read(), response.content) + self.assertEquals(len(response.content), int(response['Content-Length'])) + + def test_unknown_mime_type(self): + response = self.client.get('/views/site_media/file.unknown') + self.assertEquals('application/octet-stream', response['Content-Type']) def test_copes_with_empty_path_component(self): file_name = 'file.txt' response = self.client.get('/views/site_media//%s' % file_name) file = open(path.join(media_dir, file_name)) self.assertEquals(file.read(), response.content) - - + |
