Closed stevejalim closed 1 month ago
I did struggle with
@override_settings
too when doing the locale mapping callback in the first place. pytest is cool, and also a steeper learning curve than I thought it be in some places
Well I need to get better at dataclasses
usage, because this caught me by surprise and stopped me using with mock.patch.object(smartling_settings, REFORMAT_LANGUAGE_CODES, some_var):
dataclasses.FrozenInstanceError: cannot assign to field 'REFORMAT_LANGUAGE_CODES'
This changeset adds a new setting -
REFORMAT_LANGUAGE_CODES
, defaultTrue
, which we can use to control whether w-l-s will reformat lang codes as part of the Smartling sync.By default w-l-s assumes the Django project will be using Django's core default of all-lowercase language codes (compared to Smartling's mixed-case approach) and forces all lang codes to the relevant style depending on the direction of travel. This change allows us to skip that step when importing strings back into Wagtail, (and the equivalent step when sending lang codes to Smartling, too, just for consistency and no surprise).
Testing
Manually tested locally. I have a stash locally with some tests for test_utils.py but neither
@override_settings
normock.patch.object
seem to work for setting fake settings during a test - the former gets ignored and the latter blows up because the patched attribute can't be deleted/changed. If anyone has a tip about that, I'd welcome itResolves #17