mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-12-14 07:42:24 +03:00
Re-format all files
This commit is contained in:
@@ -12,6 +12,7 @@ from .fake_model import get_fake_model
|
||||
@override_settings(LOCALIZED_FIELDS_EXPERIMENTAL=True)
|
||||
class LocalizedLookupsTestCase(TestCase):
|
||||
"""Tests whether localized lookups properly work with."""
|
||||
|
||||
TestModel1 = None
|
||||
|
||||
@classmethod
|
||||
@@ -21,31 +22,29 @@ class LocalizedLookupsTestCase(TestCase):
|
||||
super(LocalizedLookupsTestCase, cls).setUpClass()
|
||||
|
||||
# reload app as setting has changed
|
||||
config = apps.get_app_config('localized_fields')
|
||||
config = apps.get_app_config("localized_fields")
|
||||
config.ready()
|
||||
|
||||
cls.TestModel = get_fake_model(
|
||||
{
|
||||
'text': LocalizedField(),
|
||||
}
|
||||
)
|
||||
cls.TestModel = get_fake_model({"text": LocalizedField()})
|
||||
|
||||
def test_localized_lookup(self):
|
||||
"""Tests whether localized lookup properly works."""
|
||||
|
||||
self.TestModel.objects.create(
|
||||
text=LocalizedValue(dict(en='text_en', ro='text_ro', nl='text_nl')),
|
||||
text=LocalizedValue(dict(en="text_en", ro="text_ro", nl="text_nl"))
|
||||
)
|
||||
|
||||
# assert that it properly lookups the currently active language
|
||||
for lang_code, _ in settings.LANGUAGES:
|
||||
translation.activate(lang_code)
|
||||
assert self.TestModel.objects.filter(text='text_' + lang_code).exists()
|
||||
assert self.TestModel.objects.filter(
|
||||
text="text_" + lang_code
|
||||
).exists()
|
||||
|
||||
# ensure that the default language is used in case no
|
||||
# language is active at all
|
||||
translation.deactivate_all()
|
||||
assert self.TestModel.objects.filter(text='text_en').exists()
|
||||
assert self.TestModel.objects.filter(text="text_en").exists()
|
||||
|
||||
# ensure that hstore lookups still work
|
||||
assert self.TestModel.objects.filter(text__ro='text_ro').exists()
|
||||
assert self.TestModel.objects.filter(text__ro="text_ro").exists()
|
||||
|
||||
Reference in New Issue
Block a user