| Total Complexity | 7 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | from django.test import TestCase |
||
| 10 | class LocalizedModelTestCase(TestCase): |
||
| 11 | """Tests whether the :see:LocalizedValueDescriptor class.""" |
||
| 12 | |||
| 13 | TestModel = None |
||
| 14 | |||
| 15 | @classmethod |
||
| 16 | def setUpClass(cls): |
||
| 17 | """Creates the test model in the database.""" |
||
| 18 | |||
| 19 | super(LocalizedModelTestCase, cls).setUpClass() |
||
| 20 | |||
| 21 | cls.TestModel = get_fake_model() |
||
| 22 | |||
| 23 | @classmethod |
||
| 24 | def test_defaults(cls): |
||
| 25 | """Tests whether all :see:LocalizedField |
||
| 26 | fields are assigned an empty :see:LocalizedValue |
||
| 27 | instance when the model is instanitiated.""" |
||
| 28 | |||
| 29 | obj = cls.TestModel() |
||
| 30 | |||
| 31 | assert isinstance(obj.title, LocalizedValue) |
||
| 32 | |||
| 33 | @classmethod |
||
| 34 | def test_set(cls): |
||
| 35 | """Tests whether the :see:LocalizedValueDescriptor |
||
| 36 | class's see:set function works properly.""" |
||
| 37 | |||
| 38 | obj = cls.TestModel() |
||
| 39 | |||
| 40 | for language, value in get_init_values(): |
||
| 41 | translation.activate(language) |
||
| 42 | obj.title = value |
||
| 43 | assert obj.title.get(language) == value |
||
| 44 | assert getattr(obj.title, language) == value |
||
| 45 |