Shorten names for everything

This commit is contained in:
Swen Kooij
2017-05-25 19:06:44 +03:00
parent bb84d7577c
commit a1a02552b7
18 changed files with 36 additions and 23 deletions

34
tests/test_form.py Normal file
View File

@@ -0,0 +1,34 @@
from django.conf import settings
from django.test import TestCase
from localized_fields.forms import LocalizedFieldForm
class LocalizedFieldFormTestCase(TestCase):
"""Tests the workings of the :see:LocalizedFieldForm class."""
@staticmethod
def test_init():
"""Tests whether the constructor correctly
creates a field for every language."""
form = LocalizedFieldForm()
for (lang_code, _), field in zip(settings.LANGUAGES, form.fields):
assert field.label == lang_code
if lang_code == settings.LANGUAGE_CODE:
assert field.required
else:
assert not field.required
@staticmethod
def test_compress():
"""Tests whether the :see:compress function
is working properly."""
input_value = [lang_name for _, lang_name in settings.LANGUAGES]
output_value = LocalizedFieldForm().compress(input_value)
for lang_code, lang_name in settings.LANGUAGES:
assert output_value.get(lang_code) == lang_name