Skip to content

Commit 74324f1

Browse files
tukymilind-shakya-sp
authored andcommitted
test models with DJANGO_CELERY_BEAT_NAME_MAX_LENGTH=191 in own process; pep8
1 parent 88a32e8 commit 74324f1

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

t/unit/test_models.py

+28-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,43 @@
22

33
import importlib
44

5-
from django.test import TestCase
5+
from django.test import TestCase, override_settings
6+
from django.utils import six
67

7-
from django_celery_beat.models import PeriodicTask
8+
from django_celery_beat import models
89

910

1011
class ModelMigrationTests(TestCase):
1112
def test_periodic_task_name_max_length_defaults_to_200_in_model(self):
12-
self.assertEqual(200, PeriodicTask._meta.get_field('name').max_length)
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)
1322

1423
def test_periodic_task_name_max_length_defaults_to_200_in_migration(self):
15-
initial_migration = importlib.import_module('django_celery_beat.migrations.0001_initial').Migration
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
1628
periodic_task_creation = initial_migration.operations[2]
1729
fields = dict(periodic_task_creation.fields)
1830

1931
self.assertEqual('PeriodicTask', periodic_task_creation.name)
2032
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

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ 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+
42+
[testenv:models]
43+
commands =
44+
py.test -xv -k 'ModelMigrationTests'
4145

4246
[testenv:apicheck]
4347
basepython = python3.5
@@ -70,4 +74,4 @@ usedevelop = true
7074
commands =
7175
pip install -U https://github.com/celery/celery/zipball/master#egg=celery
7276
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
77+
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)