Skip to content

Commit

Permalink
Rework test matrix and structure
Browse files Browse the repository at this point in the history
  • Loading branch information
SebCorbin committed Apr 18, 2020
1 parent c5f7c10 commit 622f3ea
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 148 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
*.pyc
.coverage
htmlcov
*.egg-info
.tox
74 changes: 39 additions & 35 deletions .travis.yml
@@ -1,42 +1,46 @@
language: python

python:
- 2.6
- 2.7
- 3.2
- 3.3
- 3.4
matrix:
fast_finish: true
allow_failures:
- env: DJANGO=master
include:
- python: 2.7
env: DJANGO=1.11

env:
- DJANGO_VERSION=1.4 MODULE=jsignature
- DJANGO_VERSION=1.5 MODULE=jsignature
- DJANGO_VERSION=1.6 MODULE=jsignature.tests
- DJANGO_VERSION=1.7 MODULE=jsignature.tests
- python: 3.5
env: DJANGO=1.11
- python: 3.5
env: DJANGO=2.2

install:
- pip install -r requirements.txt --use-mirrors
- pip install -q Django==$DJANGO_VERSION --use-mirrors
- pip install coverage
- python: 3.6
env: DJANGO=1.11
- python: 3.6
env: DJANGO=2.2
- python: 3.6
env: DJANGO=3.0
- python: 3.6
env: DJANGO=master

script: coverage run quicktest.py $MODULE
- python: 3.7
env: DJANGO=2.2
- python: 3.7
env: DJANGO=3.0
- python: 3.7
env: DJANGO=master

after_success:
- pip install coveralls
- coveralls

# We need to exclude old versions of Django for tests with python 3.
# We need to exclude old versions of Python for tests with Django >= 1.7.
matrix:
exclude:
- python: 3.2
env: DJANGO_VERSION=1.4 MODULE=jsignature
- python: 3.3
env: DJANGO_VERSION=1.4 MODULE=jsignature
- python: 3.4
env: DJANGO_VERSION=1.4 MODULE=jsignature
- python: 3.4
env: DJANGO_VERSION=1.5 MODULE=jsignature
- python: 3.4
env: DJANGO_VERSION=1.6 MODULE=jsignature.tests
- python: 2.6
env: DJANGO_VERSION=1.7 MODULE=jsignature.tests
- python: 3.8
env: DJANGO=2.2
- python: 3.8
env: DJANGO=3.0
- python: 3.8
env: DJANGO=master

install:
- pip install tox tox-travis
script:
- tox
after_success:
- pip install coveralls
- coveralls
3 changes: 2 additions & 1 deletion jsignature/mixins.py
Expand Up @@ -2,6 +2,7 @@
A django mixin providing fields to store a signature captured
with jSignature jQuery plugin
"""
import json
from datetime import datetime
from django.db import models
from django.utils.translation import ugettext_lazy as _
Expand All @@ -28,7 +29,7 @@ def save(self, *args, **kwargs):
original = not is_new and self.__class__.objects.get(pk=self.pk)

if self.signature:
if is_new or self.signature != original.signature:
if is_new or json.dumps(self.signature) != original.signature:
self.signature_date = datetime.now()
else:
self.signature_date = None
Expand Down
5 changes: 0 additions & 5 deletions jsignature/tests/__init__.py

This file was deleted.

82 changes: 0 additions & 82 deletions quicktest.py

This file was deleted.

15 changes: 15 additions & 0 deletions runtests.py
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys

import django
from django.conf import settings
from django.test.utils import get_runner

if __name__ == "__main__":
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(["tests"])
sys.exit(bool(failures))
Empty file added tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion jsignature/tests/models.py → tests/models.py
@@ -1,5 +1,5 @@
""" Provides a dummy model implementing JSignatureFieldsMixin """
from ..mixins import JSignatureFieldsMixin
from jsignature.mixins import JSignatureFieldsMixin


class JSignatureTestModel(JSignatureFieldsMixin):
Expand Down
34 changes: 34 additions & 0 deletions tests/settings.py
@@ -0,0 +1,34 @@
import os

DEBUG = True

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

SECRET_KEY = 'thisisntactuallysecretatall'

ALLOWED_HOSTS = ['*']

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}

# ROOT_URLCONF = 'tests.urls'

INSTALLED_APPS = [
'jsignature',
'tests',
]

PASSWORD_HASHERS = {
'django.contrib.auth.hashers.MD5PasswordHasher',
}

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
]
4 changes: 2 additions & 2 deletions jsignature/tests/fields.py → tests/test_fields.py
Expand Up @@ -4,8 +4,8 @@
from django.test import SimpleTestCase
from django.core.exceptions import ValidationError

from ..fields import JSignatureField
from ..forms import JSignatureField as JSignatureFormField
from jsignature.fields import JSignatureField
from jsignature.forms import JSignatureField as JSignatureFormField


class JSignatureFieldTest(SimpleTestCase):
Expand Down
4 changes: 2 additions & 2 deletions jsignature/tests/forms.py → tests/test_forms.py
@@ -1,8 +1,8 @@
from django.test import SimpleTestCase
from django.core.exceptions import ValidationError

from ..widgets import JSignatureWidget
from ..forms import JSignatureField
from jsignature.widgets import JSignatureWidget
from jsignature.forms import JSignatureField


class JSignatureFormFieldTest(SimpleTestCase):
Expand Down
18 changes: 2 additions & 16 deletions jsignature/tests/mixins.py → tests/test_mixins.py
@@ -1,24 +1,10 @@
from datetime import date
from django.conf import settings
from django.db.models import loading
from django.test import SimpleTestCase
from django.core.management import call_command
from django.test import TestCase

from .models import JSignatureTestModel


class JSignatureFieldsMixinTest(SimpleTestCase):

def setUp(self):
self.old_installed_apps = settings.INSTALLED_APPS
settings.INSTALLED_APPS = list(settings.INSTALLED_APPS)
settings.INSTALLED_APPS.append('jsignature.tests')
loading.cache.loaded = False
call_command('syncdb', verbosity=0)

def tearDown(self):
settings.INSTALLED_APPS = self.old_installed_apps

class JSignatureFieldsMixinTest(TestCase):
def test_save_create(self):
# If an object is created signed, signature date must be set
signature_value = [{"x": [1, 2], "y": [3, 4]}]
Expand Down
2 changes: 1 addition & 1 deletion jsignature/tests/utils.py → tests/test_utils.py
Expand Up @@ -4,7 +4,7 @@
from PIL import Image
from django.test import SimpleTestCase

from ..utils import draw_signature
from jsignature.utils import draw_signature

DUMMY_VALUE = [{"x": [205, 210], "y": [59, 63]},
{"x": [205, 207], "y": [67, 64]}]
Expand Down
6 changes: 3 additions & 3 deletions jsignature/tests/widgets.py → tests/test_widgets.py
Expand Up @@ -5,8 +5,8 @@
from django.test import SimpleTestCase
from django.core.exceptions import ValidationError

from ..widgets import JSignatureWidget
from ..settings import JSIGNATURE_HEIGHT
from jsignature.widgets import JSignatureWidget
from jsignature.settings import JSIGNATURE_HEIGHT


class JSignatureWidgetTest(SimpleTestCase):
Expand All @@ -15,7 +15,7 @@ def test_default_media(self):
widget = JSignatureWidget()
media = widget.media
media_js = list(media.render_js())
self.assertEqual(2, len(media_js))
self.assertEqual(3, len(media_js))
media_js_str = "".join(media_js)
self.assertIn('jSignature.min.js', media_js_str)
self.assertIn('django_jsignature.js', media_js_str)
Expand Down
23 changes: 23 additions & 0 deletions tox.ini
@@ -0,0 +1,23 @@
[tox]
envlist =
{py27,py35,py36}-django111,
{py35,py36,py37,py38}-django22,
{py36,py37,py38}-django{30,master}

[testenv]
deps=
django111: Django>=1.11,<2.0
django22: Django>=2.2,<3.0
django30: Django>=3.0,<4.0
djangomaster: https://github.com/django/django/archive/master.tar.gz
-r requirements.txt
coverage

commands= coverage run ./runtests.py

[travis:env]
DJANGO =
1.11: django111
2.2: django22
3.0: django30
master: djangomaster

0 comments on commit 622f3ea

Please sign in to comment.