Skip to content

Commit d68909c

Browse files
authored
Adapted test matrix, fixes #36 and #32 (#37)
* adapted tests * added test for missing migrations * fixed spacing * added missing imports * added missing migrations * implemented #32 * adapted changelog * adapted changelok [ci-skip] * remove missplaced requirements file * fix from comment [ci-skip]
1 parent 76fac79 commit d68909c

File tree

9 files changed

+80
-25
lines changed

9 files changed

+80
-25
lines changed

.travis.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@ language: python
22

33
sudo: false
44

5-
env:
6-
- TOX_ENV=flake8
7-
# Django 1.11
8-
- TOX_ENV=py27-dj111-cms35
9-
- TOX_ENV=py35-dj111-cms35
10-
# Django 2.0
11-
- TOX_ENV=py35-dj20-cms35
12-
- TOX_ENV=py35-dj20-cms40
13-
# Django 2.1
14-
- TOX_ENV=py35-dj21-cms35
15-
- TOX_ENV=py35-dj21-cms40
5+
matrix:
6+
include:
7+
- python: 3.5
8+
env: TOX_ENV='flake8'
9+
# Django 1.11
10+
- python: 2.7
11+
env: DJANGO='dj111' CMS='cms34'
12+
- python: 3.5
13+
env: DJANGO='dj111' CMS='cms35'
14+
- python: 3.5
15+
env: DJANGO='dj111' CMS='cms36'
16+
# Django 2.0
17+
- python: 3.5
18+
env: DJANGO='dj20' CMS='cms36'
19+
# Django 2.1
20+
- python: 3.5
21+
env: DJANGO='dj21' CMS='cms36'
1622

1723
install:
1824
- pip install tox coverage
25+
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PY_VER=py27; fi"
26+
- "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PY_VER=py35; fi"
27+
- "if [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$CMS; fi"
1928

2029
script:
2130
- tox -e $TOX_ENV

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
Changelog
33
=========
44

5+
2.1.1 (unreleased)
6+
==================
7+
8+
* Fixed test matrix
9+
* Exclude ``tests`` folder from release build
10+
* Added missing migrations for Django 2.1
11+
* Added abstract models for ``File`` and ``Folder``
12+
* Improved readability of ``Folder.get_files``
13+
514

615
2.1.0 (2018-11-13)
716
==================
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.1.2 on 2018-12-11 03:57
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('djangocms_file', '0010_removed_null_fields'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='file',
15+
name='show_file_size',
16+
field=models.BooleanField(blank=True, default=False, help_text='Appends the file size at the end of the name.', verbose_name='Show file size'),
17+
),
18+
migrations.AlterField(
19+
model_name='folder',
20+
name='show_file_size',
21+
field=models.BooleanField(blank=True, default=False, help_text='Appends the file size at the end of the name.', verbose_name='Show file size'),
22+
),
23+
]

djangocms_file/models.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ def copy_relations(self, oldinstance):
183183
self.folder_src = oldinstance.folder_src
184184

185185
def get_files(self):
186-
folder_files = []
187-
if self.folder_src:
188-
for folder in self.folder_src.files:
189-
folder_files.append(folder)
190-
return folder_files
186+
if not self.folder_src:
187+
return []
188+
return list(self.folder_src.files)
191189

192190

193191
class File(AbstractFile):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
url='https://github.com/divio/djangocms-file',
4242
license='BSD',
4343
long_description=open('README.rst').read(),
44-
packages=find_packages(),
44+
packages=find_packages(exclude=['tests']),
4545
include_package_data=True,
4646
zip_safe=False,
4747
install_requires=REQUIREMENTS,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# requirements from setup.py
22
# other requirements
3-
djangocms-helper>=0.9.2,<0.10
3+
djangocms-helper
44
tox
55
coverage

tests/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
'filer',
88
'mptt',
99
],
10-
'ALLOWED_HOSTS': ['localhost'],
1110
'CMS_LANGUAGES': {
1211
1: [{
1312
'code': 'en',
1413
'name': 'English',
1514
}]
1615
},
1716
'LANGUAGE_CODE': 'en',
17+
'ALLOWED_HOSTS': ['localhost'],
1818
}
1919

2020

tests/tests_models.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from django.test import TestCase
3+
from django.core.management import call_command
4+
from django.utils.six import StringIO
5+
36
from filer.models import File as FilerFile
47
from filer.models import Folder as FilerFolder
58

@@ -34,3 +37,17 @@ def test_folder_instance(self):
3437
"""Folder instance has been created"""
3538
test_folder = FilerFolder.objects.get(name='test')
3639
self.assertEqual(test_folder.name, 'test')
40+
41+
42+
class MigrationTestCase(TestCase):
43+
44+
def test_makemigrations(self):
45+
"""Fail if there are schema changes with no migrations."""
46+
app_name = 'djangocms_file'
47+
out = StringIO()
48+
call_command('makemigrations', dry_run=True, no_input=True, stdout=out)
49+
output = out.getvalue()
50+
self.assertNotIn(app_name, output, (
51+
'`makemigrations` thinks there are schema changes without'
52+
' migrations.'
53+
))

tox.ini

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
[tox]
22
envlist =
33
flake8
4-
py{27,34,35,36}-dj111-cms{34,35}
5-
py{34,35,36}-dj20-cms{35,36,40}
6-
py{35,36}-dj21-cms{35,36,40}
4+
py{27,34,35,36}-dj111-cms{34,35,36}
5+
py{34,35,36}-dj20-cms36
6+
py{35,36}-dj21-cms36
77

88
skip_missing_interpreters=True
99

10-
1110
[testenv]
1211
deps =
13-
-r{toxinidir}/requirements.txt
12+
-r{toxinidir}/tests/requirements.txt
1413
dj111: Django>=1.11,<2.0
1514
dj20: Django>=2.0,<2.1
1615
dj21: Django>=2.1,<2.2
1716
cms34: django-cms>=3.4,<3.5
1817
cms35: django-cms>=3.5,<3.6
19-
cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip
18+
cms36: https://github.com/divio/django-cms/archive/release/3.6.x.zip
2019
commands =
2120
{envpython} --version
2221
{env:COMMAND:coverage} erase

0 commit comments

Comments
 (0)