Skip to content

Commit

Permalink
test with up to 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Sep 19, 2019
1 parent 16336de commit 8150a10
Show file tree
Hide file tree
Showing 13 changed files with 489 additions and 78 deletions.
2 changes: 1 addition & 1 deletion examples/simple/simple/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .django_1_8 import *
from .dev import *
100 changes: 96 additions & 4 deletions examples/simple/simple/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,105 @@
import os
import sys

from django_nine import versions

from .core import PROJECT_DIR, gettext

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

try:
from .local_settings import DEBUG_TEMPLATE
except Exception as err:
DEBUG_TEMPLATE = False

try:
from .local_settings import USE_CACHED_TEMPLATE_LOADERS
except Exception as err:
USE_CACHED_TEMPLATE_LOADERS = False

if USE_CACHED_TEMPLATE_LOADERS:

_TEMPLATE_LOADERS = [
('django.template.loaders.cached.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
]
else:

_TEMPLATE_LOADERS = [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
]

if versions.DJANGO_GTE_1_10:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'APP_DIRS': True,
'DIRS': [PROJECT_DIR(os.path.join('..', 'templates'))],
'OPTIONS': {
'context_processors': [
"django.template.context_processors.debug",
'django.template.context_processors.request',
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django_nine.context_processors.versions",
],
'loaders': _TEMPLATE_LOADERS,
'debug': DEBUG_TEMPLATE,
}
},
]
elif versions.DJANGO_GTE_1_8:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'APP_DIRS': True,
'DIRS': [PROJECT_DIR(os.path.join('..', 'templates'))],
'OPTIONS': {
'context_processors': [
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"django.template.context_processors.request",
"django_nine.context_processors.versions",
],
'loaders': _TEMPLATE_LOADERS,
'debug': DEBUG_TEMPLATE,
}
},
]
else:
TEMPLATE_DEBUG = DEBUG_TEMPLATE

# List of callables that know how to import templates from various
# sources.
TEMPLATE_LOADERS = _TEMPLATE_LOADERS

TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request",
"django_nine.context_processors.versions",
)

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
# "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
PROJECT_DIR(os.path.join('..', 'templates')),
)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
Expand All @@ -27,11 +122,8 @@
DEBUG = True
DEV = False

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['*',]


# Application definition

INSTALLED_APPS = (
Expand All @@ -53,7 +145,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'simple.urls'
ROOT_URLCONF = 'urls'

WSGI_APPLICATION = 'simple.wsgi.application'

Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion examples/simple/simple/settings/django_1_10.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/simple/simple/settings/django_1_5.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/simple/simple/settings/django_1_6.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/simple/simple/settings/django_1_7.py

This file was deleted.

1 change: 0 additions & 1 deletion examples/simple/simple/settings/django_1_9.py

This file was deleted.

1 change: 1 addition & 0 deletions examples/simple/simple/templates/nine.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% if versions.DJANGO_GTE_2_1 %}A{% endif %}{% if versions.DJANGO_LTE_2_1 %}B{% endif %}
7 changes: 5 additions & 2 deletions examples/simple/simple/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView

urlpatterns = [
# Examples:
# url(r'^$', 'simple.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
url('^/$',
view=TemplateView.as_view(template_name="nine.html"),
name='django_nine'),
# url(r'^admin/', include(admin.site.urls)),
]
48 changes: 48 additions & 0 deletions src/django_nine/tests/test_context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# import unittest
# import mock
# # For Python3 >= 3.4
# try:
# from importlib import reload
# # For Python3 < 3.4
# except ImportError as err:
# try:
# from imp import reload
# except ImportError as err:
# pass
#
# from django.urls import reverse
# from django.test import RequestFactory, TestCase
#
# from .base import log_info
#
# __title__ = 'django_nine.tests.test_versions'
# __author__ = 'Artur Barseghyan'
# __copyright__ = 'Copyright (c) 2015 Artur Barseghyan'
# __license__ = 'GPL-2.0-only OR LGPL-2.1-or-later'
# __all__ = ('ContextProcessorsTest',)
#
#
# class ContextProcessorsTest(TestCase):
# """
# Tests of ``django_nine.context_processors`` module.
# """
# def setUp(self):
# self.factory = RequestFactory()
#
# @log_info
# @mock.patch('django.get_version', mock.MagicMock(return_value='2.1'))
# def test_django_2_1(self):
# """
# Tests as if we were using Django==2.1.
# """
# from django_nine import versions
# reload(versions)
#
# url = reverse('django_nine')
# response = self.client.get(url)
#
# import pytest; pytest.set_trace()
#
#
# if __name__ == "__main__":
# unittest.main()

0 comments on commit 8150a10

Please sign in to comment.