mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 19:52:54 +03:00
Added test for value_to_string
method
This commit is contained in:
parent
32696f4e1e
commit
2b34b6751e
@ -2,6 +2,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import tempfile as sys_tempfile
|
import tempfile as sys_tempfile
|
||||||
import pickle
|
import pickle
|
||||||
|
import json
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
@ -118,6 +119,20 @@ class LocalizedFileFieldTestCase(TestCase):
|
|||||||
filename = field.generate_filename(instance, 'test', 'en')
|
filename = field.generate_filename(instance, 'test', 'en')
|
||||||
assert filename == 'en_test'
|
assert filename == 'en_test'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@override_settings(LANGUAGES=(('en', 'English'),))
|
||||||
|
def test_value_to_string(cls):
|
||||||
|
"""Tests whether the :see:LocalizedFileField
|
||||||
|
class's :see:value_to_string function works properly."""
|
||||||
|
|
||||||
|
temp_file = File(tempfile.NamedTemporaryFile())
|
||||||
|
instance = cls.FileFieldModel()
|
||||||
|
field = cls.FileFieldModel._meta.get_field('file')
|
||||||
|
field.upload_to = ''
|
||||||
|
instance.file.en.save('testfilename', temp_file)
|
||||||
|
expected_value_to_string = json.dumps({'en': 'testfilename'})
|
||||||
|
assert field.value_to_string(instance) == expected_value_to_string
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test_get_prep_value():
|
def test_get_prep_value():
|
||||||
"""Tests whether the :see:get_prep_value function returns correctly
|
"""Tests whether the :see:get_prep_value function returns correctly
|
||||||
|
Loading…
x
Reference in New Issue
Block a user