Skip to content

Commit f0bbdda

Browse files
Merge pull request #1 from tuky/fix_max_length_mysql_issue
test that PeriodicTask.name.max_length defaults to 200
2 parents 510da36 + 92ee660 commit f0bbdda

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

t/proj/settings.py

-1
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,4 @@
122122
# https://docs.djangoproject.com/en/1.9/howto/static-files/
123123

124124
STATIC_URL = '/static/'
125-
DJANGO_CELERY_BEAT_NAME_MAX_LENGTH = 191
126125
DJANGO_CELERY_BEAT_TZ_AWARE = True

t/unit/test_models.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from __future__ import absolute_import, unicode_literals
2+
3+
import importlib
4+
5+
from django.test import TestCase, override_settings
6+
from django.utils import six
7+
8+
from django_celery_beat import models
9+
10+
11+
class ModelMigrationTests(TestCase):
12+
def test_periodic_task_name_max_length_defaults_to_200_in_model(self):
13+
six.moves.reload_module(models)
14+
self.assertEqual(
15+
200, models.PeriodicTask._meta.get_field('name').max_length)
16+
17+
@override_settings(DJANGO_CELERY_BEAT_NAME_MAX_LENGTH=191)
18+
def test_periodic_task_name_max_length_changed_to_191_in_model(self):
19+
six.moves.reload_module(models)
20+
self.assertEqual(
21+
191, models.PeriodicTask._meta.get_field('name').max_length)
22+
23+
def test_periodic_task_name_max_length_defaults_to_200_in_migration(self):
24+
initial_migration_module = importlib.import_module(
25+
'django_celery_beat.migrations.0001_initial')
26+
six.moves.reload_module(initial_migration_module)
27+
initial_migration = initial_migration_module.Migration
28+
periodic_task_creation = initial_migration.operations[2]
29+
fields = dict(periodic_task_creation.fields)
30+
31+
self.assertEqual('PeriodicTask', periodic_task_creation.name)
32+
self.assertEqual(200, fields['name'].max_length)
33+
34+
@override_settings(DJANGO_CELERY_BEAT_NAME_MAX_LENGTH=191)
35+
def test_periodic_task_name_max_length_changed_to_191_in_migration(self):
36+
initial_migration_module = importlib.import_module(
37+
'django_celery_beat.migrations.0001_initial')
38+
six.moves.reload_module(initial_migration_module)
39+
initial_migration = initial_migration_module.Migration
40+
periodic_task_creation = initial_migration.operations[2]
41+
fields = dict(periodic_task_creation.fields)
42+
43+
self.assertEqual('PeriodicTask', periodic_task_creation.name)
44+
self.assertEqual(191, fields['name'].max_length)

tox.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ recreate = False
3737
commands =
3838
pip install -U https://github.com/celery/celery/zipball/master#egg=celery
3939
pip install -U https://github.com/celery/kombu/zipball/master#egg=kombu
40-
py.test -xv
40+
py.test -xv --ignore=t/unit/test_models.py
41+
py.test -xv -k 'ModelMigrationTests'
4142

4243
[testenv:apicheck]
4344
basepython = python3.5
@@ -70,4 +71,4 @@ usedevelop = true
7071
commands =
7172
pip install -U https://github.com/celery/celery/zipball/master#egg=celery
7273
pip install -U https://github.com/celery/kombu/zipball/master#egg=kombu
73-
py.test -x --cov=django_celery_beat --cov-report=xml --no-cov-on-fail
74+
py.test -x --cov=django_celery_beat --cov-report=xml --no-cov-on-fail --ignore=t/unit/test_models.py

0 commit comments

Comments
 (0)