|
7 | 7 | import ddt |
8 | 8 | import pytest |
9 | 9 |
|
10 | | -from enterprise.settings.common import _merge_filters_config, plugin_settings |
| 10 | +from enterprise.settings.common import ENTERPRISE_FILTERS_CONFIG, _merge_filters_config, plugin_settings |
11 | 11 |
|
12 | 12 |
|
13 | 13 | class TestPluginSettingsPipelineInjection(unittest.TestCase): |
@@ -212,3 +212,29 @@ def test_additions_dict_isolated_from_subsequent_mutation(self): |
212 | 212 | existing[FILTER_A]['pipeline'].append(STEP_Y) |
213 | 213 |
|
214 | 214 | assert additions[FILTER_A]['pipeline'] == [STEP_X] |
| 215 | + |
| 216 | + |
| 217 | +class TestEnterpriseFiltersConfig(unittest.TestCase): |
| 218 | + """ |
| 219 | + Smoke tests asserting that ``ENTERPRISE_FILTERS_CONFIG`` contains the expected |
| 220 | + filter registrations. These tests catch omissions when a new pipeline step is |
| 221 | + added to ``enterprise/filters/`` but its filter-type key is never registered. |
| 222 | + """ |
| 223 | + |
| 224 | + def test_plugin_settings_injects_all_enterprise_filters(self): |
| 225 | + """ |
| 226 | + plugin_settings() should inject every filter key and pipeline step from |
| 227 | + ENTERPRISE_FILTERS_CONFIG into OPEN_EDX_FILTERS_CONFIG. |
| 228 | + """ |
| 229 | + settings = SimpleNamespace( |
| 230 | + ENABLE_ENTERPRISE_INTEGRATION=True, |
| 231 | + OPEN_EDX_FILTERS_CONFIG={}, |
| 232 | + ) |
| 233 | + plugin_settings(settings) |
| 234 | + |
| 235 | + for filter_key, expected_filter_config in ENTERPRISE_FILTERS_CONFIG.items(): |
| 236 | + assert filter_key in settings.OPEN_EDX_FILTERS_CONFIG |
| 237 | + actual_filter_config = settings.OPEN_EDX_FILTERS_CONFIG[filter_key] |
| 238 | + assert actual_filter_config.get("fail_silently") == expected_filter_config.get("fail_silently") |
| 239 | + for expected_step in expected_filter_config.get("pipeline", []): |
| 240 | + assert expected_step in actual_filter_config.get("pipeline", []) |
0 commit comments