Skip to content

Commit

Permalink
django 1.7 compatibility, tox, travis
Browse files Browse the repository at this point in the history
  • Loading branch information
NotSqrt committed Oct 30, 2014
1 parent 6ec2c95 commit c991db4
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 8 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@ python:
env:
- DJANGO_PACKAGE="Django>=1.5,<1.6"
- DJANGO_PACKAGE="Django>=1.6,<1.7"
install: pip install $DJANGO_PACKAGE --use-mirrors
- DJANGO_PACKAGE="Django>=1.7,<1.8"

matrix:
exclude:
- python: "2.6"
env: DJANGO_PACKAGE="Django>=1.7,<1.8"

install:
- pip install $DJANGO_PACKAGE --use-mirrors
- if [[ $TRAVIS_PYTHON_VERSION == 2.6 ]]; then pip install --use-mirrors unittest2; fi
script: python setup.py test
63 changes: 63 additions & 0 deletions django_comments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings


class Migration(migrations.Migration):

dependencies = [
('sites', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contenttypes', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('object_pk', models.TextField(verbose_name='object ID')),
('user_name', models.CharField(max_length=50, verbose_name="user's name", blank=True)),
('user_email', models.EmailField(max_length=75, verbose_name="user's email address", blank=True)),
('user_url', models.URLField(verbose_name="user's URL", blank=True)),
('comment', models.TextField(max_length=3000, verbose_name='comment')),
('submit_date', models.DateTimeField(default=None, verbose_name='date/time submitted')),
('ip_address', models.GenericIPAddressField(unpack_ipv4=True, null=True, verbose_name='IP address', blank=True)),
('is_public', models.BooleanField(default=True, help_text='Uncheck this box to make the comment effectively disappear from the site.', verbose_name='is public')),
('is_removed', models.BooleanField(default=False, help_text='Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.', verbose_name='is removed')),
('content_type', models.ForeignKey(related_name='content_type_set_for_comment', verbose_name='content type', to='contenttypes.ContentType')),
('site', models.ForeignKey(to='sites.Site')),
('user', models.ForeignKey(related_name='comment_comments', verbose_name='user', blank=True, to=settings.AUTH_USER_MODEL, null=True)),
],
options={
'ordering': ('submit_date',),
'db_table': 'django_comments',
'verbose_name': 'comment',
'verbose_name_plural': 'comments',
'permissions': [('can_moderate', 'Can moderate comments')],
},
bases=(models.Model,),
),
migrations.CreateModel(
name='CommentFlag',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('flag', models.CharField(max_length=30, verbose_name='flag', db_index=True)),
('flag_date', models.DateTimeField(default=None, verbose_name='date')),
('comment', models.ForeignKey(related_name='flags', verbose_name='comment', to='django_comments.Comment')),
('user', models.ForeignKey(related_name='comment_flags', verbose_name='user', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'django_comment_flags',
'verbose_name': 'comment flag',
'verbose_name_plural': 'comment flags',
},
bases=(models.Model,),
),
migrations.AlterUniqueTogether(
name='commentflag',
unique_together=set([('user', 'comment', 'flag')]),
),
]
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='django-contrib-comments',
version='1.5',
version='1.5.1',
url="http://github.com/django/django-contrib-comments",
description='The code formerly known as django.contrib.comments.',
long_description=long_description,
Expand Down
8 changes: 8 additions & 0 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import sys
import django

here = os.path.dirname(os.path.abspath(__file__))
parent = os.path.dirname(here)
Expand All @@ -24,6 +25,11 @@
"testapp",
"custom_comments",
],
MIDDLEWARE_CLASSES=(
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
),
ROOT_URLCONF = 'testapp.urls',
SECRET_KEY = "it's a secret to everyone",
SITE_ID = 1,
Expand All @@ -32,6 +38,8 @@
from django.test.simple import DjangoTestSuiteRunner

def main():
if django.VERSION >= (1, 7):
django.setup()
runner = DjangoTestSuiteRunner(failfast=True, verbosity=1)
failures = runner.run_tests(['testapp'], interactive=True)
sys.exit(failures)
Expand Down
2 changes: 1 addition & 1 deletion tests/testapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Entry(models.Model):
title = models.CharField(max_length=250)
body = models.TextField()
pub_date = models.DateField()
enable_comments = models.BooleanField()
enable_comments = models.BooleanField(default=False)

def __str__(self):
return self.title
Expand Down
10 changes: 8 additions & 2 deletions tests/testapp/tests/app_api_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from __future__ import absolute_import

try:
import unittest2 as unittest
except ImportError:
import unittest


import django
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.test.utils import override_settings
Expand All @@ -18,6 +25,7 @@ class CommentAppAPITests(CommentTestCase):
def testGetCommentApp(self):
self.assertEqual(django_comments.get_comment_app(), django_comments)

@unittest.skipIf(django.VERSION >= (1, 7), "Missing apps raise ImportError with django 1.7")
@override_settings(
COMMENTS_APP='missing_app',
INSTALLED_APPS=list(settings.INSTALLED_APPS) + ['missing_app'],
Expand Down Expand Up @@ -47,8 +55,6 @@ def getGetApproveURL(self):

@override_settings(
COMMENTS_APP='custom_comments',
INSTALLED_APPS=list(settings.INSTALLED_APPS) + [
'custom_comments'],
)
class CustomCommentTest(CommentTestCase):
urls = 'testapp.urls'
Expand Down
22 changes: 19 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[tox]
envlist = py26-django15, py27-django15, py32-django15, py33-django15,
py26-django16, py27-django16, py32-django16, py33-django16
py26-django16, py27-django16, py32-django16, py33-django16,
py27-django17, py32-django17, py33-django17

[testenv]
commands = {envpython} setup.py test

[testenv:py26-django15]
basepython = python2.6
deps = Django>=1.5,<1.6
deps =
Django>=1.5,<1.6
unittest2

[testenv:py27-django15]
basepython = python2.7
Expand All @@ -23,7 +26,9 @@ deps = Django>=1.5,<1.6

[testenv:py26-django16]
basepython = python2.6
deps = Django>=1.6,<1.7
deps =
Django>=1.6,<1.7
unittest2

[testenv:py27-django16]
basepython = python2.7
Expand All @@ -37,3 +42,14 @@ deps = Django>=1.6,<1.7
basepython = python3.3
deps = Django>=1.6,<1.7

[testenv:py27-django17]
basepython = python2.7
deps = Django>=1.7,<1.8

[testenv:py32-django17]
basepython = python3.2
deps = Django>=1.7,<1.8

[testenv:py33-django17]
basepython = python3.3
deps = Django>=1.7,<1.8

0 comments on commit c991db4

Please sign in to comment.