Skip to content

Commit

Permalink
Merge pull request #16 from nephila/feature/django17
Browse files Browse the repository at this point in the history
Update test suite
  • Loading branch information
yakky committed Jun 5, 2015
2 parents c381056 + f63511c commit 0471830
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 186 deletions.
22 changes: 11 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
language: python

python:
- 3.4
- 3.3
- 3.4
- 2.7
- 2.6

env:
matrix:
- DJANGO='django>=1.4,<1.5'
- DJANGO='django>=1.5,<1.6'
- DJANGO='django>=1.6,<1.7'
- DJANGO='django16'
- DJANGO='django17'

# 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: coverage run `which djangocms-helper` djangocms_page_meta test --cms --nose
script: COMMAND='coverage run' tox -e"$PYVER-$DJANGO"

after_success: coveralls

matrix:
exclude:
- python: 3.3
env: DJANGO='django>=1.4,<1.5'
- python: 3.4
env: DJANGO='django>=1.4,<1.5'
- python: 2.6
env: DJANGO='django17'
4 changes: 3 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ History
*******

0.5 (unreleased)
==================
================

* Add support for custom user model
* Fix the length of SEO fields
* Use djangocms-helper for tests
* Add support for Django 1.7
* Add support for django CMS 3.1

0.4.1 (2014-08-10)
==================
Expand Down
14 changes: 11 additions & 3 deletions cms_helper.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tempfile import mkdtemp

import sys
from tempfile import mkdtemp
gettext = lambda s: s

HELPER_SETTINGS = {
Expand All @@ -9,7 +11,6 @@
],
'ROOT_URLCONF': 'tests.test_utils.urls',
'INSTALLED_APPS': [
'django_nose',
'filer',
'meta',
'meta_mixin',
Expand Down Expand Up @@ -59,4 +60,11 @@
),
'FILE_UPLOAD_TEMP_DIR': mkdtemp()

}
}

def run():
from djangocms_helper import runner
runner.cms('djangocms_page_meta')

if __name__ == "__main__":
run()
5 changes: 4 additions & 1 deletion djangocms_page_meta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
__version__ = '0.4.2.b1'
# -*- coding: utf-8 -*-
__version__ = '0.5.0b1'
__author__ = 'Iacopo Spalletti <i.spalletti@nephila.it>'

default_app_config = 'djangocms_page_meta.apps.PageMetaConfig'
8 changes: 8 additions & 0 deletions djangocms_page_meta/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class PageMetaConfig(AppConfig):
name = 'djangocms_page_meta'
verbose_name = _("django CMS Page Meta")
4 changes: 2 additions & 2 deletions djangocms_page_meta/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from cms.extensions import PageExtension, TitleExtension
from cms.extensions.extension_pool import extension_pool
from cms.models import Title, Page
from django.core.cache import cache
from cms.models import Page, Title
from django.conf import settings
from django.core.cache import cache
from django.db import models
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
Expand Down
76 changes: 41 additions & 35 deletions djangocms_page_meta/templates/djangocms_page_meta/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,47 @@
{% if meta %}
{% if meta.description %}{% meta 'description' meta.description %}{% endif %}
{% if meta.keywords %}{% meta_list 'keywords' meta.keywords %}{% endif %}
{% if meta.title %}{% og_prop 'title' meta.title %}{% endif %}
{% if meta.url %}{% og_prop 'url' meta.url %}{% endif %}
{% if meta.og_description %}{% og_prop 'description' meta.og_description %}{% endif %}
{% if meta.image %}{% og_prop 'image' meta.image %}{% endif %}
{% if meta.og_type %}{% og_prop 'type' meta.og_type %}{% endif %}
{% if meta.site_name %}{% og_prop 'site_name' meta.site_name %}{% endif %}
{% if meta.og_author_url %}
{% generic_prop 'article' 'author' meta.og_author_url %}
{% elif meta.og_author %}
{% generic_prop 'article' 'author:first_name' meta.og_author.first_name %}
{% generic_prop 'article' 'author:last_name' meta.og_author.last_name %}
{% if meta.use_og %}
{% if meta.title %}{% og_prop 'title' meta.title %}{% endif %}
{% if meta.url %}{% og_prop 'url' meta.url %}{% endif %}
{% if meta.og_description %}{% og_prop 'description' meta.og_description %}{% endif %}
{% if meta.image %}{% og_prop 'image' meta.image %}{% endif %}
{% if meta.og_type %}{% og_prop 'type' meta.og_type %}{% endif %}
{% if meta.site_name %}{% og_prop 'site_name' meta.site_name %}{% endif %}
{% if meta.og_author_url %}
{% generic_prop 'article' 'author' meta.og_author_url %}
{% elif meta.og_author %}
{% generic_prop 'article' 'author:first_name' meta.og_author.first_name %}
{% generic_prop 'article' 'author:last_name' meta.og_author.last_name %}
{% endif %}
{% if meta.published_time %}{% generic_prop 'article' 'published_time' meta.published_time %}{% endif %}
{% if meta.modified_time %}{% generic_prop 'article' 'modified_time' meta.modified_time %}{% endif %}
{% if meta.expiration_time %}{% generic_prop 'article' 'expiration_time' meta.expiration_time %}{% endif %}
{% if meta.og_publisher %}{% generic_prop 'article' 'publisher' meta.og_publisher %}{% endif %}
{% if meta.og_app_id %}{% generic_prop 'fb' 'app_id' meta.og_app_id %}{% endif %}
{% if meta.og_profile_id %}{% generic_prop 'fb' 'profile_id' meta.og_profile_id %}{% endif %}
{% if meta.tag %}{% generic_prop 'article' 'tag' meta.tag %}{% endif %}
{% if meta.locale %}{% og_prop 'locale' meta.locale %}{% endif %}
{% endif %}
{% if meta.published_time %}{% generic_prop 'article' 'published_time' meta.published_time %}{% endif %}
{% if meta.modified_time %}{% generic_prop 'article' 'modified_time' meta.modified_time %}{% endif %}
{% if meta.expiration_time %}{% generic_prop 'article' 'expiration_time' meta.expiration_time %}{% endif %}
{% if meta.og_publisher %}{% generic_prop 'article' 'publisher' meta.og_publisher %}{% endif %}
{% if meta.og_app_id %}{% generic_prop 'fb' 'app_id' meta.og_app_id %}{% endif %}
{% if meta.og_profile_id %}{% generic_prop 'fb' 'profile_id' meta.og_profile_id %}{% endif %}
{% if meta.tag %}{% generic_prop 'article' 'tag' meta.tag %}{% endif %}
{% if meta.locale %}{% og_prop 'locale' meta.locale %}{% endif %}
{% twitter_prop 'domain' meta.get_domain %}
{% if meta.twitter_type %}{% twitter_prop 'card' meta.twitter_type %}{% endif %}
{% if meta.title %}{% twitter_prop 'title' meta.title %}{% endif %}
{% if meta.url %}{% twitter_prop 'url' meta.url %}{% endif %}
{% if meta.twitter_description %}{% twitter_prop 'description' meta.twitter_description %}{% endif %}
{% if meta.image %}{% twitter_prop 'image:src' meta.image %}{% endif %}
{% if meta.twitter_author %}{% twitter_prop 'creator' meta.twitter_author %}{% endif %}
{% if meta.twitter_site %}{% twitter_prop 'site_name' meta.twitter_site %}{% endif %}
{% if meta.gplus_author %}
<link rel="author" href="https://plus.google.com/{{ meta.gplus_author }}"/>
{% if meta.use_twitter %}
{% twitter_prop 'domain' meta.get_domain %}
{% if meta.twitter_type %}{% twitter_prop 'card' meta.twitter_type %}{% endif %}
{% if meta.title %}{% twitter_prop 'title' meta.title %}{% endif %}
{% if meta.url %}{% twitter_prop 'url' meta.url %}{% endif %}
{% if meta.twitter_description %}{% twitter_prop 'description' meta.twitter_description %}{% endif %}
{% if meta.image %}{% twitter_prop 'image:src' meta.image %}{% endif %}
{% if meta.twitter_author %}{% twitter_prop 'creator' meta.twitter_author %}{% endif %}
{% if meta.twitter_site %}{% twitter_prop 'site_name' meta.twitter_site %}{% endif %}
{% endif %}
{% if meta.use_googleplus %}
{% if meta.gplus_author %}
<link rel="author" href="https://plus.google.com/{{ meta.gplus_author }}"/>
{% endif %}
{% if meta.title %}{% googleplus_prop 'name' meta.title %}{% endif %}
{% if meta.published_time %}{% googleplus_prop 'datePublished' meta.published_time %}{% endif %}
{% if meta.modified_time %}{% googleplus_prop 'dateModified' meta.modified_time %}{% endif %}
{% if meta.url %}{% googleplus_prop 'url' meta.url %}{% endif %}
{% if meta.gplus_description %}{% googleplus_prop 'description' meta.gplus_description %}{% endif %}
{% if meta.image %}{% googleplus_prop 'image' meta.image %}{% endif %}
{% endif %}
{% if meta.title %}{% googleplus_prop 'name' meta.title %}{% endif %}
{% if meta.published_time %}{% googleplus_prop 'datePublished' meta.published_time %}{% endif %}
{% if meta.modified_time %}{% googleplus_prop 'dateModified' meta.modified_time %}{% endif %}
{% if meta.url %}{% googleplus_prop 'url' meta.url %}{% endif %}
{% if meta.gplus_description %}{% googleplus_prop 'description' meta.gplus_description %}{% endif %}
{% if meta.image %}{% googleplus_prop 'image' meta.image %}{% endif %}
{% endif %}
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
license='BSD',
zip_safe=False,
keywords='django cms, meta tags, OpenGraph, Twitter Cards, Google+',
test_suite='cms_helper.run',
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Django',
Expand Down
80 changes: 11 additions & 69 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# -*- coding: utf-8 -*-
from cms.models import Page
from cms.utils.i18n import get_language_list
from django.contrib.auth.models import User
from django.http import SimpleCookie
from django.test import TestCase, RequestFactory
from django.utils.six import StringIO
from djangocms_helper.base_test import BaseTestCase

from djangocms_page_meta.models import TitleMeta, PageMeta


class BaseTest(TestCase):
class BaseTest(BaseTestCase):
"""
Base class with utility function
"""
request_factory = None
user = None
languages = get_language_list()
page_data = {
}
page_data = {}
_pages_data = (
{'en': {'title': 'page one', 'template': 'page_meta.html', 'publish': True},
'fr_FR': {'title': 'page un', 'publish': True},
'it': {'title': 'pagina uno', 'publish': True}},
{'en': {'title': 'page two', 'template': 'page_meta.html', 'publish': True},
'fr_FR': {'title': 'page deux', 'publish': True},
'it': {'title': 'pagina due', 'publish': True}},
)
title_data = {
'keywords': 'keyword1, keyword2, keyword3',
'description': 'lorem ipsum - english',
Expand Down Expand Up @@ -48,58 +45,3 @@ class BaseTest(TestCase):
'gplus_author': '+FakeUser',
'gplus_type': 'Article',
}

@classmethod
def setUpClass(cls):
cls.request_factory = RequestFactory()
cls.user = User.objects.create(username='admin', is_staff=True, is_superuser=True)
cls.user_staff = User.objects.create(username='staff', is_staff=True)
cls.user_normal = User.objects.create(username='normal')

def get_pages(self):
from cms.api import create_page, create_title
page = create_page(u'page one', 'page_meta.html', language='en')
page_2 = create_page(u'page two', 'page_meta.html', language='en')
create_title(language='fr_FR', title=u'page un', page=page)
create_title(language='it', title=u'pagina uno', page=page)
for lang in self.languages:
page.publish(lang)
page_2.publish('en')
return page.get_draft_object(), page_2.get_draft_object()

def get_request(self, page, lang):
request = self.request_factory.get(page.get_path(lang))
request.current_page = page
request.user = self.user
request.session = {}
request.cookies = SimpleCookie()
request.errors = StringIO()
request.LANGUAGE_CODE = lang
return request

def get_page_request(self, page, user, path=None, edit=False, lang_code='en'):
from cms.middleware.toolbar import ToolbarMiddleware
path = path or page and page.get_absolute_url(lang_code)
if edit:
path += '?edit'
request = RequestFactory().get(path)
request.session = {}
request.user = user
request.LANGUAGE_CODE = lang_code
if edit:
request.GET = {'edit': None}
else:
request.GET = {'edit_off': None}
request.current_page = page
mid = ToolbarMiddleware()
mid.process_request(request)
return request

def tearDown(self):
Page.objects.all().delete()
PageMeta.objects.all().delete()
TitleMeta.objects.all().delete()

@classmethod
def tearDownClass(cls):
User.objects.all().delete()
71 changes: 7 additions & 64 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,69 +1,12 @@
[tox]
envlist = py26dj14, py26dj15, py26dj16, py27dj14, py27dj15, py27dj16, py33dj15, py33dj16, py34dj15, py34dj16
envlist = py26-django16-cms{30,31} py{27,33,34}-django{16,17}-cms{30,31}

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/djangocms_page_meta
commands = djangocms-helper djangocms_page_meta test --cms --nose
commands = {env:COMMAND:python} setup.py test
deps =
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip
cms31: https://github.com/divio/django-cms/archive/develop.zip
py26: unittest2
-r{toxinidir}/requirements-test.txt

[testenv:py26dj14]
basepython=python2.6
deps =
django>=1.4,<1.5
{[testenv]deps}

[testenv:py26dj15]
basepython=python2.6
deps =
django>=1.5,<1.6
{[testenv]deps}

[testenv:py26dj16]
basepython=python2.6
deps =
django>=1.6,<1.7
{[testenv]deps}

[testenv:py27dj14]
basepython=python2.7
deps =
django>=1.4,<1.5
{[testenv]deps}

[testenv:py27dj15]
basepython=python2.7
deps =
django>=1.5,<1.6
{[testenv]deps}

[testenv:py27dj16]
basepython=python2.7
deps =
django>=1.6,<1.7
{[testenv]deps}

[testenv:py33dj15]
basepython=python3.3
deps =
django>=1.5,<1.6
{[testenv]deps}

[testenv:py33dj16]
basepython=python3.3
deps =
django>=1.6,<1.7
{[testenv]deps}

[testenv:py34dj15]
basepython=python3.4
deps =
django>=1.5,<1.6
{[testenv]deps}

[testenv:py34dj16]
basepython=python3.4
deps =
django>=1.6,<1.7
{[testenv]deps}

0 comments on commit 0471830

Please sign in to comment.