From 8a6b54e1c92ce556a67fc441c9fdec1db3700c5b Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 1 Jan 2015 18:51:45 +0100 Subject: [PATCH 1/5] Refactor test run --- .travis.yml | 29 ++++++++++++++++------------- cms_helper.py | 11 +++++++++++ requirements-test.txt | 2 +- setup.py | 3 ++- tox.ini | 7 ++----- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index ebadd2b..5558c56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,35 +10,38 @@ python: env: matrix: - - DJANGO='django>=1.5,<1.6' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - - DJANGO='django>=1.6,<1.7' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - - DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + - DJANGO='django15' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + - DJANGO='django16' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + - DJANGO='django17' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - - pip install $DJANGO - - pip install -r requirements-test.txt + - pip install -U tox>=1.8 coveralls + - "if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then export PYVER=py26; fi" + - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PYVER=py27; fi" + - "if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then export PYVER=py33; fi" + - "if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then export PYVER=py34; fi" # command to run tests, e.g. python setup.py test -script: djangocms-helper djangocms_blog test --cms --nose-runner +script: COMMAND='coverage run' tox -e"$PYVER-$DJANGO" after_success: coveralls matrix: exclude: - python: 2.6 - env: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + env: DJANGO='django17' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 allow_failures: - python: 3.3 - env: DJANGO='django>=1.5,<1.6' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + env: DJANGO='django15' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - python: 3.3 - env: DJANGO='django>=1.6,<1.7' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + env: DJANGO='django16' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - python: 3.3 - end: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + end: DJANGO='django17' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - python: 3.4 - env: DJANGO='django>=1.5,<1.6' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + env: DJANGO='django15' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - python: 3.4 - env: DJANGO='django>=1.6,<1.7' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + env: DJANGO='django16' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 - python: 3.4 - env: DJANGO='django>=1.7,<1.8' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 + env: DJANGO='django17' NOSE_COVER_PACKAGE="djangocms_blog" NOSE_WITH_COVERAGE=1 diff --git a/cms_helper.py b/cms_helper.py index e8f561b..955ac5e 100644 --- a/cms_helper.py +++ b/cms_helper.py @@ -94,3 +94,14 @@ HELPER_SETTINGS = { } if 'test' in sys.argv: HELPER_SETTINGS['INSTALLED_APPS'].append('django_nose') + + +def run(): + from collections import defaultdict + from djangocms_helper import main + args = defaultdict(str) + args[''] = 'djangocms_blog' + args['test'] = True + args['--cms'] = True + args['--nose-runner'] = True + main.core(args=args, application='djangocms_blog') diff --git a/requirements-test.txt b/requirements-test.txt index 33852a6..59def67 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -5,5 +5,5 @@ mock>=1.0.1 nose>=1.3.0 django-nose>=1.2 flake8 -https://github.com/nephila/djangocms-helper/archive/django_17.zip +djangocms-helper>=0.5 tox>=1.8 diff --git a/setup.py b/setup.py index 3592631..0cabef4 100755 --- a/setup.py +++ b/setup.py @@ -50,11 +50,12 @@ setup( 'cmsplugin-filer', 'django-meta>=0.2', 'django-meta-mixin>=0.1.1', - 'south>=1.0.1', + 'south>=1.0.1', ], license="BSD", zip_safe=False, keywords='djangocms-blog, blog, django, wordpress, multilingual', + test_suite='cms_helper.run', classifiers=[ 'Development Status :: 4 - Beta', 'Framework :: Django', diff --git a/tox.ini b/tox.ini index 3a8ea73..9ed5420 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,11 @@ [tox] -envlist = {py26,py27}-django{15,16},{py27}-django{17} +envlist = py{26}-django{15,16},py{27,33,34}-django{15,16,17} [testenv] -basepython = - py26: python2.6 - py27: python2.7 deps = django15: Django>=1.5,<1.6 django16: Django>=1.6,<1.7 django17: Django>=1.7,<1.8 py26: unittest2 -r{toxinidir}/requirements-test.txt -commands = djangocms-helper djangocms_blog test --cms --nose +commands = {env:COMMAND:python} setup.py test From 1486583ed8b1e31e6d8a83171f1ac009f22f59f3 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 1 Jan 2015 19:07:45 +0100 Subject: [PATCH 2/5] Temporary fix for pip-setuptools / django CMS issues --- requirements-test.txt | 2 +- tox.ini | 2 ++ tox_pip.sh | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 tox_pip.sh diff --git a/requirements-test.txt b/requirements-test.txt index 59def67..f789bf8 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -5,5 +5,5 @@ mock>=1.0.1 nose>=1.3.0 django-nose>=1.2 flake8 -djangocms-helper>=0.5 +https://github.com/nephila/djangocms-helper/archive/develop.zip tox>=1.8 diff --git a/tox.ini b/tox.ini index 9ed5420..50cac40 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,8 @@ envlist = py{26}-django{15,16},py{27,33,34}-django{15,16,17} [testenv] +# temporary fix for pip-setuptools / django CMS issues +install_command = ./tox_pip.sh {opts} {packages} deps = django15: Django>=1.5,<1.6 django16: Django>=1.6,<1.7 diff --git a/tox_pip.sh b/tox_pip.sh new file mode 100755 index 0000000..a62ec1b --- /dev/null +++ b/tox_pip.sh @@ -0,0 +1,3 @@ +#!/bin/sh +pip install 'setuptools<8.0' 'pip<6' +pip install $@ \ No newline at end of file From 8c267e7b58b6bd944be713ed80bd72437bf3d133 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 4 Jan 2015 17:59:20 +0100 Subject: [PATCH 3/5] Use latest runner from djangoms-helper --- .gitignore | 2 ++ cms_helper.py | 15 +++++++-------- setup.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) mode change 100644 => 100755 cms_helper.py diff --git a/.gitignore b/.gitignore index 87c3612..ba996bc 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ lokalize* docs *~ +*.db +*.sqlite \ No newline at end of file diff --git a/cms_helper.py b/cms_helper.py old mode 100644 new mode 100755 index 955ac5e..ba5f7d1 --- a/cms_helper.py +++ b/cms_helper.py @@ -1,4 +1,6 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- + import sys from tempfile import mkdtemp gettext = lambda s: s @@ -97,11 +99,8 @@ if 'test' in sys.argv: def run(): - from collections import defaultdict - from djangocms_helper import main - args = defaultdict(str) - args[''] = 'djangocms_blog' - args['test'] = True - args['--cms'] = True - args['--nose-runner'] = True - main.core(args=args, application='djangocms_blog') + from djangocms_helper import runner + runner.cms('djangocms_blog') + +if __name__ == "__main__": + run() \ No newline at end of file diff --git a/setup.py b/setup.py index 0cabef4..acf4149 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- #!/usr/bin/env python +# -*- coding: utf-8 -*- import os import sys From aae7b87207d56be766fa5ea48945a6201b124fbc Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 4 Jan 2015 18:17:25 +0100 Subject: [PATCH 4/5] Use nose runner --- cms_helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cms_helper.py b/cms_helper.py index ba5f7d1..bbc314b 100755 --- a/cms_helper.py +++ b/cms_helper.py @@ -100,6 +100,7 @@ if 'test' in sys.argv: def run(): from djangocms_helper import runner + sys.argv.append('--nose-runner') runner.cms('djangocms_blog') if __name__ == "__main__": From 9b3ab6d1e89e5fb404f5812bc4177eee9d43e6bc Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 4 Jan 2015 18:27:45 +0100 Subject: [PATCH 5/5] Parametrise a test --- tests/test_models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 6eedae9..a06fbda 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -60,7 +60,8 @@ class AdminTest(BaseTest): post_admin = admin.site._registry[Post] post_admin.add_view(request) self.assertEqual(Post.objects.count(), 1) - self.assertEqual(Post.objects.get(translations__slug='first-post').author_id, 1) + self.assertEqual(Post.objects.get(translations__slug='first-post').author_id, + request.user.pk) with self.settings(BLOG_AUTHOR_DEFAULT=False): data = deepcopy(self.data['en'][1])