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:
41
tests/test_file_field_form.py
Normal file
41
tests/test_file_field_form.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.forms.widgets import FILE_INPUT_CONTRADICTION
|
||||
from django.test import TestCase
|
||||
|
||||
from localized_fields.forms import LocalizedFileFieldForm
|
||||
|
||||
|
||||
class LocalizedFileFieldFormTestCase(TestCase):
|
||||
"""Tests the workings of the :see:LocalizedFileFieldForm class."""
|
||||
|
||||
def test_clean(self):
|
||||
"""Tests whether the :see:clean function is working properly."""
|
||||
|
||||
formfield = LocalizedFileFieldForm(required=True)
|
||||
with self.assertRaises(ValidationError):
|
||||
formfield.clean([])
|
||||
with self.assertRaises(ValidationError):
|
||||
formfield.clean([], {'en': None})
|
||||
with self.assertRaises(ValidationError):
|
||||
formfield.clean("badvalue")
|
||||
with self.assertRaises(ValidationError):
|
||||
value = [FILE_INPUT_CONTRADICTION] * len(settings.LANGUAGES)
|
||||
formfield.clean(value)
|
||||
|
||||
formfield = LocalizedFileFieldForm(required=False)
|
||||
formfield.clean([''] * len(settings.LANGUAGES))
|
||||
formfield.clean(['', ''], ['', ''])
|
||||
|
||||
def test_bound_data(self):
|
||||
"""Tests whether the :see:bound_data function is returns correctly
|
||||
value"""
|
||||
|
||||
formfield = LocalizedFileFieldForm()
|
||||
assert formfield.bound_data([''], None) == ['']
|
||||
|
||||
initial = dict([(lang, '') for lang, _ in settings.LANGUAGES])
|
||||
value = [None] * len(settings.LANGUAGES)
|
||||
expected_value = [''] * len(settings.LANGUAGES)
|
||||
assert formfield.bound_data(value, initial) == expected_value
|
||||
|
||||
Reference in New Issue
Block a user