Skip to content

Commit

Permalink
FIX : Strip white spaces in Bokmål to Nynorsk macro user preferences …
Browse files Browse the repository at this point in the history
…field [SDNTB-879] (#521)

* fix : Strip white spaces in Bokmål to Nynorsk macro user preferences field [SDNTB-879]

* update tests
  • Loading branch information
devketanpro authored Jan 3, 2025
1 parent 9b28ea0 commit ed73208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/ntb/macros/nob_NO_translate_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion server/ntb/tests/macros/nob_NO_translate_macro_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 , "
}
}
}
}
Expand Down Expand Up @@ -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"])

0 comments on commit ed73208

Please sign in to comment.