Skip to content

Commit

Permalink
Merge pull request hovel#66 from hovel/travis_improvement
Browse files Browse the repository at this point in the history
Travis ci improvement, django 1.3 full compatibility
  • Loading branch information
zeus committed Mar 10, 2013
2 parents 1c3fa0c + 6bad37e commit efe22c2
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 60 deletions.
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options

install: "sudo pip install -r test/example_thirdparty/requirements.txt -r test/example_thirdparty/requirements_test.txt"

script: "python test/example_thirdparty/manage.py test pybb"

language: python
python:
- "2.6"
- "2.7"
env:
- DJANGO=1.3.7
- DJANGO=1.4.5
- DJANGO=1.5
install:
- pip install Django==$DJANGO --use-mirrors
- pip install -r test/test_project/requirements_test.txt
script:
- python setup.py test

4 changes: 2 additions & 2 deletions pybb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __unicode__(self):
return self.name

def update_counters(self):
posts = Post.objects.filter(topic__forum_id=self.id)
posts = Post.objects.filter(topic__forum__id=self.id)
self.post_count = posts.count()
self.topic_count = Topic.objects.filter(forum=self).count()
try:
Expand Down Expand Up @@ -225,7 +225,7 @@ def delete(self, using=None):

def update_counters(self):
self.post_count = self.posts.count()
last_post = Post.objects.filter(topic_id=self.id).order_by('-created')[0]
last_post = Post.objects.filter(topic__id=self.id).order_by('-created')[0]
self.updated = last_post.updated or last_post.created
self.save()

Expand Down
4 changes: 2 additions & 2 deletions pybb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ def setUp(self):
self.create_user()
self.create_initial()

def test_attachment(self):
def test_attachment_one(self):
add_post_url = reverse('pybb:add_post', kwargs={'topic_id': self.topic.id})
self.login_client()
response = self.client.get(add_post_url)
Expand All @@ -977,7 +977,7 @@ def test_attachment(self):
self.assertEqual(response.status_code, 200)
self.assertTrue(Post.objects.filter(body='test attachment').exists())

def test_attachment(self):
def test_attachment_two(self):
add_post_url = reverse('pybb:add_post', kwargs={'topic_id': self.topic.id})
self.login_client()
response = self.client.get(add_post_url)
Expand Down
6 changes: 4 additions & 2 deletions pybb/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-

from django.conf.urls import *
try:
from django.conf.urls import patterns, include, url
except ImportError:
from django.conf.urls.defaults import patterns, include, url

from pybb.feeds import LastPosts, LastTopics
from pybb.views import IndexView, CategoryView, ForumView, TopicView,\
Expand Down
75 changes: 75 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python
import sys
import os
from os.path import dirname, abspath
from optparse import OptionParser

from django.conf import settings
import django

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.request',
'pybb.context_processors.processor',
)

if django.get_version() >= (1, 4):
TEMPLATE_CONTEXT_PROCESSORS += ['django.core.context_processors.tz',]

# For convenience configure settings if they are not pre-configured or if we
# haven't been provided settings to use by environment variable.
if not settings.configured and not os.environ.get('DJANGO_SETTINGS_MODULE'):
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
}
},
INSTALLED_APPS=[
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'pytils',
'sorl.thumbnail',
'pure_pagination',
'pybb',
],
ROOT_URLCONF='test.test_project.test_urls',
DEBUG=False,
SITE_ID=1,
STATIC_URL='/static/',
AUTH_PROFILE_MODULE='pybb.Profile',
TEMPLATE_DIRS=(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test/test_project/templates'), ),
PYBB_ATTACHMENT_ENABLE=True,
TEMPLATE_CONTEXT_PROCESSORS=TEMPLATE_CONTEXT_PROCESSORS,
)

from django.test.simple import DjangoTestSuiteRunner


def runtests(*test_args, **kwargs):
if 'south' in settings.INSTALLED_APPS:
from south.management.commands import patch_for_test_db_setup
patch_for_test_db_setup()

if not test_args:
test_args = ['pybb']
parent = dirname(abspath(__file__))
sys.path.insert(0, parent)
test_runner = DjangoTestSuiteRunner(verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast'))
failures = test_runner.run_tests(test_args)
sys.exit(failures)

if __name__ == '__main__':
parser = OptionParser()
parser.add_option('--failfast', action='store_true', default=False, dest='failfast')

(options, args) = parser.parse_args()

runtests(failfast=options.failfast, *args)
46 changes: 23 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
from setuptools import setup, find_packages

setup(
version = '0.12.4',
description = 'PyBB Modified. Django forum application',
long_description = open('README.rst').read(),
author = 'Pavel Zhukov',
author_email = 'gelios@gmail.com',
name = 'pybbm',
url = 'http://www.pybbm.org/',
packages = find_packages(),
include_package_data = True,
package_data = {'': ['pybb/templates', 'pybb/static']},
install_requires = [
'markdown',
'postmarkup',
'south',
'pytils',
'django-annoying',
'sorl-thumbnail',
'django-pure-pagination',
'django-mailer',
],

license = "BSD",
keywords = "django application forum board",
version='0.12.4',
description='PyBB Modified. Django forum application',
long_description=open('README.rst').read(),
author='Pavel Zhukov',
author_email='gelios@gmail.com',
name='pybbm',
url='http://www.pybbm.org/',
packages=find_packages(),
include_package_data=True,
package_data={'': ['pybb/templates', 'pybb/static']},
install_requires=[
'markdown',
'postmarkup',
'south',
'pytils',
'django-annoying',
'sorl-thumbnail',
'django-pure-pagination',
'django-mailer',
],
test_suite='runtests.runtests',
license="BSD",
keywords="django application forum board",
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
Expand Down
Empty file added test/__init__.py
Empty file.
5 changes: 4 additions & 1 deletion test/example_bootstrap/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from django.conf.urls.defaults import patterns, include, url
try:
from django.conf.urls import patterns, include, url
except ImportError:
from django.conf.urls.defaults import patterns, include, url

from django.contrib import admin
admin.autodiscover()
Expand Down
1 change: 0 additions & 1 deletion test/example_thirdparty/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Django>=1.4
South>=0.7.5
Markdown>=2.1
postmarkup>=1.2.0
Expand Down
24 changes: 0 additions & 24 deletions test/example_thirdparty/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,6 @@
]
AUTH_PROFILE_MODULE = 'pybb.Profile'

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Pybb
Expand Down
5 changes: 4 additions & 1 deletion test/example_thirdparty/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
try:
from django.conf.urls import patterns, include, url
except ImportError:
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin

admin.autodiscover()
Expand Down
Empty file added test/test_project/__init__.py
Empty file.
File renamed without changes.
17 changes: 17 additions & 0 deletions test/test_project/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% load url from future %}
{% load pytils_numeral %}
<!DOCTYPE html>
<html>
<head>
{% block extra_style %}{% endblock %}
<title>{% block title %}{% endblock %}</title>
{% block extra_head %}{% endblock %}
{% block extra_script %}{% endblock %}
</head>
<body>
{% block breadcrumb %}
{% endblock breadcrumb %}
{% block content %}
{% endblock content %}
</body>
</html>
19 changes: 19 additions & 0 deletions test/test_project/test_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
try:
from django.conf.urls import patterns, include, url
except ImportError:
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),

# TODO: we have to break such dependencies in application
url(r"^accounts/password/$", 'django.contrib.auth.views.password_change', name="auth_password_change"),
url(r"^accounts/signup/$", 'django.contrib.auth.views.login', name="registration_register", kwargs={'template_name': 'base.html'}),
url(r"^accounts/login/$", 'django.contrib.auth.views.login', name="auth_login", kwargs={'template_name': 'base.html'}),

url(r'^', include('pybb.urls', namespace='pybb')),
)

0 comments on commit efe22c2

Please sign in to comment.