Tests passing on Django 2.0a1

This commit is contained in:
Marco Bonetti 2017-09-23 21:16:16 +02:00
parent d6fe378676
commit 0bd2f6e3dc
8 changed files with 34 additions and 14 deletions

View file

@ -19,6 +19,8 @@ matrix:
env: TOX_ENV=py27-django110
- python: "2.7"
env: TOX_ENV=py27-django111
- python: "3.6"
env: TOX_ENV=py36-django20
install:
- pip install tox

View file

@ -4,6 +4,7 @@ Version History
Version 0.7.14 (unreleased)
---------------------------
* Updated installation docs (PR #190, thanks @AuHau)
* Test against Django 2.0a1
Version 0.7.13

View file

@ -30,7 +30,7 @@ def is_superuser_staff_or_in_translators_group(user):
if not getattr(settings, 'ROSETTA_REQUIRES_AUTH', True):
return True
try:
if not user.is_authenticated():
if not user.is_authenticated:
return False
elif user.is_superuser and user.is_staff:
return True
@ -46,7 +46,7 @@ def can_translate_language(user, langid):
try:
if not rosetta_settings.ROSETTA_LANGUAGE_GROUPS:
return can_translate(user)
elif not user.is_authenticated():
elif not user.is_authenticated:
return False
elif user.is_superuser and user.is_staff:
return True

View file

@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
import django
from django.conf import settings
from django.core.urlresolvers import reverse, resolve
if django.VERSION < (1, 10): # NOQA
from django.core.urlresolvers import reverse, resolve # NOQA
else: # NOQA
from django.urls import reverse, resolve # NOQA
from django.core.exceptions import ImproperlyConfigured
from django.core.cache import cache
from django.test import TestCase
@ -11,8 +15,6 @@ from rosetta.signals import entry_changed, post_save
import os
import shutil
import six
import django
# import vcr
import hashlib
@ -246,7 +248,8 @@ class RosettaTestCase(TestCase):
self.assertTrue('save-conflict' in str(r.content))
# client 2 won
pofile_content = open(self.dest_file, 'r').read()
with open(self.dest_file, 'r') as po_file:
pofile_content = po_file.read()
self.assertTrue('Hello, world, from client two!' in pofile_content)
# Both clients show all strings, error messages are gone
@ -265,6 +268,7 @@ class RosettaTestCase(TestCase):
self.assertTrue('save-conflict' not in str(r2.content))
self.assertTrue('save-conflict' not in str(r.content))
def test_10_issue_79_num_entries(self):
shutil.copy(os.path.normpath(os.path.join(self.curdir, './django.po.issue79.template')), self.dest_file)
self.client.get(reverse('rosetta-pick-file') + '?filter=third-party')
@ -406,7 +410,9 @@ class RosettaTestCase(TestCase):
# post a translation, it should have properly wrapped lines
r = self.client.post(reverse('rosetta-home'), dict(m_bb9d8fe6159187b9ea494c1b313d23d4='Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.', _next='_next'))
pofile_content = open(self.dest_file, 'r').read()
with open(self.dest_file, 'r') as po_file:
pofile_content = po_file.read()
self.assertTrue('"pede mollis pretium."' in pofile_content)
# Again, with unwrapped lines
@ -417,7 +423,8 @@ class RosettaTestCase(TestCase):
self.assertTrue('m_bb9d8fe6159187b9ea494c1b313d23d4' in str(r.content))
rosetta_settings.POFILE_WRAP_WIDTH = 0
r = self.client.post(reverse('rosetta-home'), dict(m_bb9d8fe6159187b9ea494c1b313d23d4='Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.', _next='_next'))
pofile_content = open(self.dest_file, 'r').read()
with open(self.dest_file, 'r') as po_file:
pofile_content = po_file.read()
self.assertTrue('felis eu pede mollis pretium."' in pofile_content)
def test_19_Test_Issue_gh34(self):
@ -435,7 +442,8 @@ class RosettaTestCase(TestCase):
m_ff7060c1a9aae9c42af4d54ac8551f67_0='Foo %s',
m_ff7060c1a9aae9c42af4d54ac8551f67_1='Bar %s',
m_09f7e02f1290be211da707a266f153b3='Salut', _next='_next'))
pofile_content = open(self.dest_file, 'r').read()
with open(self.dest_file, 'r') as po_file:
pofile_content = po_file.read()
self.assertTrue('msgstr "Salut\\n"' in pofile_content)
self.assertTrue('msgstr[0] ""\n"\\n"\n"Foo %s\\n"' in pofile_content)
self.assertTrue('msgstr[1] ""\n"\\n"\n"Bar %s\\n"' in pofile_content)
@ -460,7 +468,8 @@ class RosettaTestCase(TestCase):
m_9efd113f7919952523f06e0d88da9c54='Testing cookie length',
_next='_next'
))
pofile_content = open(self.dest_file, 'r').read()
with open(self.dest_file, 'r') as po_file:
pofile_content = po_file.read()
self.assertTrue('Testing cookie length' in pofile_content)
self.client.get(reverse('rosetta-home') + '?filter=translated')
@ -590,7 +599,7 @@ class RosettaTestCase(TestCase):
self.assertTrue('<li class="active"><a href="?filter=third-party">' in str(r.content))
def test_29_unsupported_p3_django_16_storage(self):
if django.VERSION[0:2] >= (1, 6):
if django.VERSION[0:2] >= (1, 6) and django.VERSION[0:2] < (2, 0):
self.assertTrue('django.contrib.sessions.middleware.SessionMiddleware' in settings.MIDDLEWARE_CLASSES)
settings.SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"

View file

@ -1,7 +1,12 @@
import django
from django.conf import settings
from django.contrib.auth.decorators import user_passes_test
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
if django.VERSION < (1, 10): # NOQA
from django.core.urlresolvers import reverse # NOQA
else: # NOQA
from django.urls import reverse # NOQA
from django.http import Http404, HttpResponseRedirect, HttpResponse
from django.shortcuts import render
from django.utils.encoding import iri_to_uri

View file

@ -59,6 +59,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
)
MIDDLEWARE = MIDDLEWARE_CLASSES
# Note: languages are overridden in the test runner
LANGUAGES = (

View file

@ -4,7 +4,7 @@ from django.contrib import admin
admin.autodiscover()
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', admin.site.urls),
url(r'^rosetta/', include('rosetta.urls'))
]

View file

@ -1,6 +1,7 @@
[tox]
envlist =
{py27,py36}-django{18,19,110,111},
py36-django20,
gettext,docs
skipsdist = True
@ -19,9 +20,10 @@ deps =
django19: Django==1.9.4
django110: Django==1.10
django111: Django==1.11
django20: Django==2.0a1
py27-django{17,18,19,110,111}: python-memcached
py36-django{17,18,19,110,111}: python3-memcached
py36-django{17,18,19,110,111,20}: python3-memcached
# py27-django18: pudb
requests
polib>=1.0.6