Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Commit

Permalink
Django 1.10 Py 3.6 tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartTC committed Mar 18, 2017
1 parent f9af3c6 commit 1bb07e2
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ language: python
python:
- 2.7
- 3.5
- 3.6

env:
- DJANGO=1.8.*
- DJANGO=1.9.*
- DJANGO=1.10.*

before_install:
- pip install codecov
Expand Down
89 changes: 58 additions & 31 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,43 +1,70 @@
=========
Changelog
=========

**1.0 (2016-03-23)**
* Code cleanup and update for Django 1.8+. Python3 Support. Better
test integration. Better docs.
v1.1 (2017-03-18):
------------------

- Django 1.10 compatibility and tests.
- Python 3.6 compatibility.
- `TEMPLATE_DEBUG` setting is no longer honored to raise individual
errors, in favor of standard `DEBUG`.

v1.0 (2016-03-23):
------------------

- Code cleanup and update for Django 1.8+. Python3 Support. Better
test integration. Better docs.

v0.9.1 (2010-03-22):
--------------------

- Django 1.2 compatibility! Fixed a bug where tests did not pass
under Django 1.2. Thanks to Brian Rosner for this.

v0.9 (2010-02-25):
------------------

- Fixed a bug where an integer was not allowed as a part of a slug.

v0.4 (2009-09-08):
------------------

- Added Danish translation.
- Added better documentation.
- Added unittests.
- If you fetch a not existing "primary key" object the templatetag
will fail silently if settings.TEMPLATE_DEBUG is False.

v0.3.0 (2009-03-21):
--------------------

- Added the *into* argument. You can now display any instance directly
without creating and rendering a template.

v0.2.1 (2009-03-20):
--------------------

**0.9.1** (2010-03-22)
* Django 1.2 compatibility! Fixed a bug where tests did not pass
under Django 1.2. Thanks to Brian Rosner for this.
- You can now pass a context variable with a integer to fetch a specific
object.

**v0.9** (2010-02-25)
* Fixed a bug where an integer was not allowed as a part of a slug.
v0.2.0 (2009-03-20):
--------------------

**v0.4** (2009-09-08)
* Added Danish translation.
* Added better documentation.
* Added unittests.
* If you fetch a not existing "primary key" object the templatetag
will fail silently if settings.TEMPLATE_DEBUG is False.
- Added the ability to pass an integer as slug. This will cause that the
templatetag fetches the specific *for* model with the primary key named
in *slug*.

**v0.3.0** (2009-03-21)
* Added the *into* argument. You can now display any instance directly
without creating and rendering a template.
v0.1.2 (2009-03-20):
--------------------

**v0.2.1** (2009-03-20)
* You can now pass a context variable with a integer to fetch a specific
object.
- Switched from distutils to setuptools. Fixed whitespace.

**v0.2.0** (2009-03-20)
* Added the ability to pass an integer as slug. This will cause that the
templatetag fetches the specific *for* model with the primary key named
in *slug*.
v0.1.1 (2009-03-15):
--------------------

**v0.1.2** (2009-03-20)
* Switched from distutils to setuptools. Fixed whitespace.
- Fixed wrong upload path of a contributed, generic block

**v0.1.1** (2009-03-15)
* Fixed wrong upload path of a contributed, generic block
v0.1 (2009-03-13):
------------------

**v0.1** (2009-03-13)
* Initial release
- Initial release
4 changes: 2 additions & 2 deletions django_generic_flatblocks/templatetags/generic_flatblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_content_object(self, related_model, slug):
related_object = related_model._default_manager.get(pk=slug)
return None, related_object
except related_model.DoesNotExist:
if settings.TEMPLATE_DEBUG:
if settings.DEBUG:
raise
related_object = related_model()
return None, related_object
Expand Down Expand Up @@ -119,7 +119,7 @@ def render(self, context):
try:
t = select_template(template_paths)
except:
if settings.TEMPLATE_DEBUG:
if settings.DEBUG:
raise
return ''
content = t.render(context)
Expand Down
36 changes: 18 additions & 18 deletions django_generic_flatblocks/tests/test_flatblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def setUp(self):
dummy_user.first_name = u'John'
dummy_user.last_naem = u'Doe'
dummy_user.save()

self.assertEqual(dummy_user.pk, 1)
self.dummy_user = dummy_user

self.admin_user = User.objects.create_superuser(u'admin', u'admin@example.com', u'foobar')

def tearDown(self):
from django.contrib.auth.models import User
User.objects.all().delete()
Expand Down Expand Up @@ -129,16 +129,16 @@ def testWithArgument(self):
t = self.parseTemplate(template_string)
self.assertTrue(u'<h2></h2>' in t)

# Raise exception if the template does not exist if TEMPLATE_DEBUG is True
settings.TEMPLATE_DEBUG = True
# Raise exception if the template does not exist if DEBUG is True
settings.DEBUG = True
template_string = '''
{% load generic_flatblocks %}
{% gblock "title" for "auth.Permission" %}
'''
self.assertRaises((TemplateDoesNotExist, TemplateSyntaxError), self.parseTemplate, template_string)
settings.TEMPLATE_DEBUG = False
settings.DEBUG = False

# Fail silently if the template does not exist but TEMPLATE_DEBUG is False
# Fail silently if the template does not exist but DEBUG is False
template_string = '''
{% load generic_flatblocks %}
{% gblock "title" for "auth.Permission" %}
Expand Down Expand Up @@ -191,14 +191,14 @@ def testIntoArgument(self):


from django.contrib.auth.models import User
settings.TEMPLATE_DEBUG = True
settings.DEBUG = True
template_string = '''
{% load generic_flatblocks %}
{% gblock 5 for "auth.User" into "the_user" %}
<foo>{{ the_user.username }}</foo>
'''
self.assertRaises((User.DoesNotExist, TemplateSyntaxError), self.parseTemplate, template_string)
settings.TEMPLATE_DEBUG = False
settings.DEBUG = False

def testRelatedObjectDeletion(self):
template_string = '''
Expand Down Expand Up @@ -241,41 +241,41 @@ def testContributedModels(self):
self.assertTrue(isinstance(GenericFlatblock.objects.get(slug=u'image').content_object, models.Image))
self.assertTrue(isinstance(GenericFlatblock.objects.get(slug=u'title_and_text').content_object, models.TitleAndText))
self.assertTrue(isinstance(GenericFlatblock.objects.get(slug=u'title_text_and_image').content_object, models.TitleTextAndImage))

def testAdminLink(self):
template_string = '''
{% load generic_flatblocks %}
{% gblock "title" for "gblocks.Title" with "test_template.html" %}
'''
t = self.parseTemplate(template_string, admin_user=True)
t = self.parseTemplate(template_string, admin_user=True)
self.assertTrue("/admin/gblocks/title/1/" in t)


# The admin link gets appended to the "into" argument
template_string = '''
{% load generic_flatblocks %}
{% gblock "title" for "gblocks.Title" into "title_object" %}
{{ title_object_admin_url }}
'''
t = self.parseTemplate(template_string, admin_user=True)
t = self.parseTemplate(template_string, admin_user=True)
self.assertTrue("/admin/gblocks/title/1/" in t)

# You can define the admin prefix using a setting
from django.conf import settings
settings.ADMIN_URL_PREFIX = '/secret-admin-url/'

template_string = '''
{% load generic_flatblocks %}
{% gblock "title" for "gblocks.Title" with "test_template.html" %}
'''
t = self.parseTemplate(template_string, admin_user=True)
t = self.parseTemplate(template_string, admin_user=True)
self.assertTrue("/secret-admin-url/gblocks/title/1/" in t)


template_string = '''
{% load generic_flatblocks %}
{% gblock "title" for "gblocks.Title" into "title_object" %}
{{ title_object_admin_url }}
'''
t = self.parseTemplate(template_string, admin_user=True)
t = self.parseTemplate(template_string, admin_user=True)
self.assertTrue("/secret-admin-url/gblocks/title/1/" in t)
15 changes: 14 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
'NAME': 'dev.db',
},
},

'INSTALLED_APPS': [
'django_generic_flatblocks',
'django_generic_flatblocks.tests',
Expand All @@ -29,6 +28,20 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
'TEMPLATES': [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.i18n',
],
},
},
],
}

def runtests(*test_args):
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
toxworkdir=/tmp/tox/django-generic-flatblocks
envlist=
py{27,35}-django-{18,19}
py{27,35,36}-django-{18,19,110}

[testenv]
install_command =
Expand All @@ -14,3 +14,4 @@ deps=
# Django versions
django-18: django==1.8.*
django-19: django==1.9.*
django-110: django==1.10.*

0 comments on commit 1bb07e2

Please sign in to comment.