Skip to content

Commit

Permalink
fix: toggle report missing settings (#337)
Browse files Browse the repository at this point in the history
Adds missing settings to the toggle report.

#310
  • Loading branch information
robrap authored Jan 31, 2024
1 parent c9ed5b0 commit 94619c2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Change Log
Unreleased
~~~~~~~~~~

[5.1.1] - 2024-01-31
--------------------

* Fix toggle report to output all settings.

[5.1.0] - 2023-08-02
--------------------

Expand Down
20 changes: 20 additions & 0 deletions edx_toggles/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ def test_response_with_waffle_switch(self):
waffle_names = [waffle["name"] for waffle in report["waffle_switches"]]
self.assertIn("test.switch", waffle_names)

def test_response_with_simple_setting(self):
with override_settings(MYSETTING=True):
report = ToggleStateReport().as_dict()

self.assertIn(
{
"name": "MYSETTING",
"is_active": True,
},
report["django_settings"],
)

self.assertNotIn(
{
"name": "__dict__['MYSETTING']",
"is_active": True,
},
report["django_settings"],
)

def test_response_with_setting_toggle(self):
_toggle = SettingToggle("MYSETTING", default=False, module_name="module1")
with override_settings(MYSETTING=True):
Expand Down
9 changes: 8 additions & 1 deletion edx_toggles/toggles/state/internal/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ def _add_settings(settings_dict):
"""
Fill the `settings_dict`: will only include values that are set to true or false.
"""
for setting_name, setting_value in vars(settings).items():
settings_dict_copy = {}
default_attribute_value = object() # default is not a bool, so won't be included
for attr in dir(settings):
if not attr.startswith('__'):
value = getattr(settings, attr, default_attribute_value)
settings_dict_copy[attr] = value

for setting_name, setting_value in settings_dict_copy.items():
if isinstance(setting_value, dict):
for dict_name, dict_value in setting_value.items():
if isinstance(dict_value, bool):
Expand Down

0 comments on commit 94619c2

Please sign in to comment.