diff --git a/server/ntb/macros/nob_NO_translate_macro.py b/server/ntb/macros/nob_NO_translate_macro.py index 823b4fae2..6af24d194 100644 --- a/server/ntb/macros/nob_NO_translate_macro.py +++ b/server/ntb/macros/nob_NO_translate_macro.py @@ -70,7 +70,7 @@ def get_user_preference_params(): user = get_user() user_macro_preferences = user.get("user_preferences", {}).get("macro_config", {}) field_param = user_macro_preferences.get("fields").get("Formval nynorskrobot", "") - return field_param.split(",") + return [field.strip() for field in field_param.split(",") if field.strip()] name = "Bokmal to Nynorsk Translate Macro" diff --git a/server/ntb/tests/macros/nob_NO_translate_macro_test.py b/server/ntb/tests/macros/nob_NO_translate_macro_test.py index d4fd8ef0d..4cc0513aa 100644 --- a/server/ntb/tests/macros/nob_NO_translate_macro_test.py +++ b/server/ntb/tests/macros/nob_NO_translate_macro_test.py @@ -25,7 +25,9 @@ class TranslateMacroTestCase(TestCase): user_preferences = { "user_preferences": { "macro_config": { - "fields": {"Formval nynorskrobot": "headline,description_text"} + "fields": { + "Formval nynorskrobot": " headline , description_text , , body_html , " + } } } } @@ -65,3 +67,8 @@ def test_associate_item_translated(self, mock_post, mock_get_user): item["associations"]["editor_1"]["description_text"], "Kva synest du om Noreg", ) + + # assert params SDNTB-879 + + params = nob_NO_translate_macro.get_user_preference_params() + self.assertEqual(params, ["headline", "description_text", "body_html"])