From 03e8a7383f4906dcd5af20d4c641da4f015b2b05 Mon Sep 17 00:00:00 2001 From: Emil Luta Date: Thu, 12 Jan 2017 16:35:07 +0200 Subject: [PATCH] Added test for dict init on LocalizedModel --- tests/test_localized_model.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_localized_model.py b/tests/test_localized_model.py index d385984..962c41a 100644 --- a/tests/test_localized_model.py +++ b/tests/test_localized_model.py @@ -27,3 +27,23 @@ class LocalizedModelTestCase(TestCase): obj = cls.TestModel() assert isinstance(obj.title, LocalizedValue) + + + @classmethod + def test_model_init_kwargs(cls): + """Tests whether all :see:LocalizedField + fields are assigned an empty :see:LocalizedValue + instance when the model is instanitiated.""" + data = { + 'title': { + 'en': 'english_title', + 'ro': 'romanian_title', + 'nl': 'dutch_title' + } + } + obj = cls.TestModel(**data) + + assert isinstance(obj.title, LocalizedValue) + assert obj.title.en == 'english_title' + assert obj.title.ro == 'romanian_title' + assert obj.title.nl == 'dutch_title' \ No newline at end of file