mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-12-14 07:42:24 +03:00
Shorten names for everything
This commit is contained in:
34
tests/test_form.py
Normal file
34
tests/test_form.py
Normal 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
|
||||
Reference in New Issue
Block a user