summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e4707d7)
Test for Django up to 1.11.
Drop Python 2.6, 3.2, 3.3.
12 files changed:
and for sane caching settings.
"""
and for sane caching settings.
"""
- def get_available_name(self, name):
+ def get_available_name(self, name, max_length=None):
if self.exists(name):
self.delete(name)
return name
if self.exists(name):
self.delete(name)
return name
import re
from django.conf import settings
import re
from django.conf import settings
-from django.conf.urls import patterns
from django.core.urlresolvers import LocaleRegexURLResolver
from django.core.urlresolvers import LocaleRegexURLResolver
-from django.utils.translation import get_language, string_concat
+from django.utils.translation import get_language
class MyLocaleRegexURLResolver(LocaleRegexURLResolver):
class MyLocaleRegexURLResolver(LocaleRegexURLResolver):
return self._regex_dict[language_code]
return self._regex_dict[language_code]
-def i18n_patterns(prefix, *args):
+def i18n_patterns(*args):
"""
Adds the language code prefix to every URL pattern within this
function. This may only be used in the root URLconf, not in an included
URLconf.
"""
"""
Adds the language code prefix to every URL pattern within this
function. This may only be used in the root URLconf, not in an included
URLconf.
"""
- pattern_list = patterns(prefix, *args)
+ pattern_list = list(args)
if not settings.USE_I18N:
return pattern_list
return pattern_list + [MyLocaleRegexURLResolver(pattern_list)]
if not settings.USE_I18N:
return pattern_list
return pattern_list + [MyLocaleRegexURLResolver(pattern_list)]
],
LANGUAGE_CODE='pl',
MEDIA_ROOT=media_root,
],
LANGUAGE_CODE='pl',
MEDIA_ROOT=media_root,
+ MIDDLEWARE_CLASSES=[
+ 'django.middleware.common.CommonMiddleware',
+ 'fnpdjango.middleware.URLLocaleMiddleware',
+ 'fnpdjango.middleware.SetRemoteAddrFromXRealIP',
+ ],
+ FNPDJANGO_REALIP = True,
+ ROOT_URLCONF='tests.urls',
+ TEMPLATES=[
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ },
+ ],
TEST_LAZY_UGETTEXT_LAZY=_("Lazy setting."),
TEST_LAZY_UGETTEXT_LAZY=_("Lazy setting."),
)
else:
media_root = None
)
else:
media_root = None
author='Radek Czajka',
author_email='radekczajka@nowoczesnapolska.org.pl',
url='',
author='Radek Czajka',
author_email='radekczajka@nowoczesnapolska.org.pl',
url='',
'fnpdjango.management.commands': ['babel.cfg'],
},
install_requires=[
'fnpdjango.management.commands': ['babel.cfg'],
},
install_requires=[
'textile==2.3.16',
],
license='LICENSE',
'textile==2.3.16',
],
license='LICENSE',
test_* modules by itself.
"""
test_* modules by itself.
"""
+from .test_middleware import *
from .test_storage import *
from .test_templatetags_fnp_markup import *
from .test_storage import *
from .test_templatetags_fnp_markup import *
+from .test_templatetags_macros import *
from .test_utils_settings import *
from .test_utils_settings import *
+from .test_utils_urls import *
--- /dev/null
+from django.test import TestCase
+
+
+class MiddlewareTests(TestCase):
+ def test_realip(self):
+ self.assertEqual(
+ self.client.get('/ip/').content.decode('latin1'),
+ '127.0.0.1'
+ )
+ self.assertEqual(
+ self.client.get(
+ '/ip/',
+ HTTP_X_REAL_IP='1.2.3.4'
+ ).content.decode('latin1'),
+ '1.2.3.4'
+ )
#
from __future__ import unicode_literals
#
from __future__ import unicode_literals
from django.test import TestCase
from django.test import TestCase
-try:
- from unittest import skipIf
-except ImportError:
- # Don't need skipping for Python2.6.
- skipIf = lambda expr, comment: lambda test: test
-
-@skipIf(sys.version_info[:2] == (3, 2),
- "No usable python-textile for Python 3.2.")
class TemplatetagsFNPMarkupTestCase(TestCase):
def test_textile_en(self):
class TemplatetagsFNPMarkupTestCase(TestCase):
def test_textile_en(self):
--- /dev/null
+from __future__ import unicode_literals
+
+from django.test import TestCase
+from django.template import Template, Context
+
+
+class MacrosTests(TestCase):
+ def test_macro(self):
+ tmpl = Template("""
+ {% load macros %}
+ {% macro my_macro arg1 %}
+ Parameter: {{ arg1 }} <br/>
+ {% endmacro %}
+ {% usemacro my_macro "String parameter" %}
+ """)
+ self.assertEqual(
+ tmpl.render(Context()).strip(),
+ "Parameter: String parameter <br/>"
+ )
--- /dev/null
+from django.test import TestCase
+
+
+class UrlsTestCase(TestCase):
+ def test_i18n_patterns(self):
+ self.assertEqual(self.client.get('/').content.decode('latin1'), 'pl')
+ self.assertEqual(self.client.get('/en/').content.decode('latin1'), 'en')
--- /dev/null
+from django.conf.urls import url
+from fnpdjango.utils.urls import i18n_patterns
+from . import views
+
+
+urlpatterns = [
+ url(r'^ip/$', views.ip),
+] + i18n_patterns(
+ url(r'^$', views.get_lang),
+)
--- /dev/null
+from django.http import HttpResponse
+from django.utils.translation import get_language
+
+
+def get_lang(request):
+ return HttpResponse(get_language())
+
+
+def ip(request):
+ return HttpResponse(request.META['REMOTE_ADDR'])
- d14-py{26,27},
- d1{5,6}-py{26,27,32,33},
- d17-py{27,32,33,34},
- d18-py{27,32,33,34,35},
- d{19,d}-py{27,34,35},
+ d1{4,5,6}-py27,
+ d17-py{27,34},
+ d{18,19,110}-py{27,34,35},
+ d111-py{27,34,35,36,37},
+ #d20-py{34,35,36,37},
+ #d21-py{35,36,37},
-indexserver=https://py.mdrn.pl:8443
commands=coverage run --source=fnpdjango --append --branch runtests.py
deps=
d14: Django>=1.4,<1.5
commands=coverage run --source=fnpdjango --append --branch runtests.py
deps=
d14: Django>=1.4,<1.5
d17: Django>=1.7,<1.8
d18: Django>=1.8,<1.9
d19: Django>=1.9,<1.10
d17: Django>=1.7,<1.8
d18: Django>=1.8,<1.9
d19: Django>=1.9,<1.10
- dd: https://github.com/django/django/zipball/master
+ d110: Django>=1.10,<1.11
+ d111: Django>=1.11,<2.0
+ d20: Django>=2.0,<2.1
+ d21: Django>=2.1,<2.2
-install_command =
- pip install --process-dependency-links {opts} {packages}
[testenv:clear]
basepython=python3.4
[testenv:clear]
basepython=python3.4