Skip to content

Commit

Permalink
Populated packages based on destination desk language (#426)
Browse files Browse the repository at this point in the history
* Populated packages based on destination desk language

* update testcases
  • Loading branch information
devketanpro authored and petrjasek committed Mar 16, 2023
1 parent a4bb8ba commit b2cecb6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 4 additions & 3 deletions server/belga/macros/add_specific_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
):
Expand All @@ -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",
Expand Down
17 changes: 13 additions & 4 deletions server/tests/macros/add_specific_package_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
)
Expand Down

0 comments on commit b2cecb6

Please sign in to comment.