Skip to content

Commit

Permalink
Add additional enforcement to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiky30 committed Mar 16, 2020
1 parent 53b6a56 commit 3a2cda1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/test_wizards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib.sites.models import Site
from django.utils import translation

from cms.wizards.forms import WizardStep2BaseForm, step2_form_factory
from cms.wizards.helpers import get_entries as get_wizard_entires
Expand Down Expand Up @@ -72,6 +73,7 @@ def test_create_alias_wizard_form_with_no_category_fallback_language(self):
"""When creating an Alias via the Wizard an error can occur if the category
doesn't have a valid translation
"""
translation.activate('en')
# A japanese translation that does not have any fallback settings!
Category.objects.language('ja').create(name='Japanese category')

Expand All @@ -80,16 +82,20 @@ def test_create_alias_wizard_form_with_no_category_fallback_language(self):
'name': 'Content #1',
'category': None,
}

form_class = step2_form_factory(
mixin_cls=WizardStep2BaseForm,
entry_form_class=wizard.form,
)
form = form_class(**self._get_form_kwargs(data))
category_form_queryset = form.declared_fields['category'].queryset

categories = form.declared_fields['category'].queryset.all()
# Be sure that we have untranslated categories that enforces a fair test
self.assertNotEqual(
category_form_queryset.all().count(),
category_form_queryset.active_translations().count()
)

for category in categories:
for category in category_form_queryset.all():
# Each category string representation can be accessed without an error
category_name = str(category)

Expand Down

0 comments on commit 3a2cda1

Please sign in to comment.