| Total Complexity | 8 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | from django.test import TestCase |
||
| 8 | class LocalizedModelTestCase(TestCase): |
||
| 9 | """Tests whether the :see:LocalizedModel class.""" |
||
| 10 | |||
| 11 | TestModel = None |
||
| 12 | |||
| 13 | @classmethod |
||
| 14 | def setUpClass(cls): |
||
| 15 | """Creates the test model in the database.""" |
||
| 16 | |||
| 17 | super(LocalizedModelTestCase, cls).setUpClass() |
||
| 18 | |||
| 19 | cls.TestModel = get_fake_model() |
||
| 20 | |||
| 21 | @classmethod |
||
| 22 | def test_defaults(cls): |
||
| 23 | """Tests whether all :see:LocalizedField |
||
| 24 | fields are assigned an empty :see:LocalizedValue |
||
| 25 | instance when the model is instanitiated.""" |
||
| 26 | |||
| 27 | obj = cls.TestModel() |
||
| 28 | |||
| 29 | assert isinstance(obj.title, LocalizedValue) |
||
| 30 | |||
| 31 | |||
| 32 | @classmethod |
||
| 33 | def test_model_init_kwargs(cls): |
||
| 34 | """Tests whether all :see:LocalizedField |
||
| 35 | fields are assigned an empty :see:LocalizedValue |
||
| 36 | instance when the model is instanitiated.""" |
||
| 37 | data = { |
||
| 38 | 'title': { |
||
| 39 | 'en': 'english_title', |
||
| 40 | 'ro': 'romanian_title', |
||
| 41 | 'nl': 'dutch_title' |
||
| 42 | } |
||
| 43 | } |
||
| 44 | obj = cls.TestModel(**data) |
||
| 45 | |||
| 46 | assert isinstance(obj.title, LocalizedValue) |
||
| 47 | assert obj.title.en == 'english_title' |
||
| 48 | assert obj.title.ro == 'romanian_title' |
||
| 49 | assert obj.title.nl == 'dutch_title' |