def test_models_data_to_data_with_url_path(self): from organicseeds_webshop_api import models data = models.Data() assert data.to_data() == {} appstruct = {"url_slug": {"default": "slug"}} data = models.Data(appstruct) assert data.to_data("default")["url_path"] == u"/slug" category = models.Category(appstruct) assert category.to_data("default")["url_path"] == u"/slug" item_group = models.ItemGroup(appstruct) assert item_group.to_data("default")["url_path"] == u"/slug" item = models.Item(appstruct) assert item.to_data("default")["url_path"] == u"/slug"
def test_models_data_to_data_with_lang_default_with_attributs(self): from organicseeds_webshop_api import models data = models.Data() appstruct = ({"title": {"default": "test"}, "ids": [{"id": {"default": 1, "fr": 2}}]}) data.from_appstruct(appstruct) assert data.to_data("default") == {"title": "test", "ids": [{"id": 1}]}
def test_models_data_to_data_with_lang_not_default_missing(self): from organicseeds_webshop_api import models data = models.Data() appstruct = ({"title": {"default": "test"}, "ids": [1, 2]}) data.from_appstruct(appstruct) assert data.to_data("fr") == {"title": "test", "ids": [1, 2]}
def test_models_data_from_appstruct(self): from organicseeds_webshop_api import models data = models.Data() appstruct = ({"title": {"default": "test", "fr": "testfr"}, "ids": [1, 2]}) data.from_appstruct(appstruct) assert data["title"]["default"] == "test"
def test_models_data_to_data(self): from organicseeds_webshop_api import models data = models.Data() appstruct = ({"title": {"default": "test", "fr": "testfr"}}) data.from_appstruct(appstruct) assert data.to_data() == appstruct