diff --git a/server/belga/macros/add_specific_package.py b/server/belga/macros/add_specific_package.py index a7e65e3e..bbe8580e 100644 --- a/server/belga/macros/add_specific_package.py +++ b/server/belga/macros/add_specific_package.py @@ -8,10 +8,11 @@ def update_package(item, **kwargs): - item_language = item.get("language", "") item = set_default_metadata(item, **kwargs) - if item.get("state") == CONTENT_STATE.INGESTED and item_language in ( + language = kwargs.get("desk", {}).get("desk_language", item.get("language")) + + if item.get("state") == CONTENT_STATE.INGESTED and language in ( "fr", "nl", ): @@ -27,7 +28,7 @@ def update_package(item, **kwargs): "parent": "EXT", "scheme": "services-products", } - if item_language == "fr" + if language == "fr" else { "name": "BTL/ECO", "qcode": "BTL/ECO", diff --git a/server/tests/macros/add_specific_package_test.py b/server/tests/macros/add_specific_package_test.py index 0f8871d9..23469dd3 100644 --- a/server/tests/macros/add_specific_package_test.py +++ b/server/tests/macros/add_specific_package_test.py @@ -74,13 +74,22 @@ def test_add_specific_package_macro(self): ], } - update_package(item, dest_desk_id="desk_1") + dest_desk = { + "_id": "desk_2", + "name": "Politic Desk", + "default_content_profile": "belga_text", + "default_content_template": "content_template_1", + "desk_language": "fr", + "source": "politic", + } + + update_package(item, desk=dest_desk) self.assertEqual( item.get("subject")[2], { - "name": "BTL/ECO", - "qcode": "BTL/ECO", - "parent": "BTL", + "name": "EXT/ECO", + "qcode": "EXT/ECO", + "parent": "EXT", "scheme": "services-products", }, )