Skip to content

Commit 980b2aa

Browse files
authored
fix: Add support for whitelist and legacy registry options (#429)
1 parent 2db667f commit 980b2aa

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Change Log
1313
1414
Unreleased
1515
~~~~~~~~~~
16+
[9.2.1]
17+
18+
* Add support for either 'whitelist' or 'registry.mapping' options (whitelist introduced in v9.0.0)
1619

1720
[9.2.0]
1821

event_routing_backends/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Various backends for receiving edX LMS events..
33
"""
44

5-
__version__ = '9.2.0'
5+
__version__ = '9.2.1'

event_routing_backends/management/commands/helpers/queued_sender.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def is_known_event(self, event):
5151
"""
5252
if "name" in event:
5353
for processor in self.engine.processors:
54-
if event["name"] in processor.registry.mapping:
54+
if hasattr(processor, 'whitelist') and event["name"] in processor.whitelist:
55+
return True
56+
elif hasattr(processor, 'registry') and event["name"] in processor.registry.mapping:
5557
return True
5658
return False
5759

event_routing_backends/management/commands/tests/test_transform_tracking_logs.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def command_options():
7676
"Sending to LRS!"
7777
]
7878
},
79+
"registry_mapping": {"problem_check": 1},
7980
},
8081
# Remote file to LRS dry run no batch size
8182
{
@@ -94,6 +95,7 @@ def command_options():
9495
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 0 batches.",
9596
]
9697
},
98+
"registry_mapping": {"problem_check": 1},
9799
},
98100
# Remote file to LRS, default batch size
99101
{
@@ -112,6 +114,7 @@ def command_options():
112114
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 1 batches.",
113115
]
114116
},
117+
"whitelist": ["problem_check"]
115118
},
116119
# Local file to remote file
117120
{
@@ -135,6 +138,7 @@ def command_options():
135138
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 2 batches.",
136139
]
137140
},
141+
"whitelist": ["problem_check"]
138142
},
139143
# Remote file dry run
140144
{
@@ -157,6 +161,7 @@ def command_options():
157161
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 0 batches.",
158162
]
159163
},
164+
"whitelist": ["problem_check"]
160165
},
161166
]
162167

@@ -208,7 +213,10 @@ def test_transform_command(command_opts, mock_common_calls, caplog, capsys):
208213

209214
mm2 = MagicMock()
210215
# Fake a router mapping so some events in the log are actually processed
211-
mm2.registry.mapping = {"problem_check": 1}
216+
if command_opts.get("registry_mapping"):
217+
mm2.registry.mapping = command_opts.pop("registry_mapping")
218+
if command_opts.get("whitelist"):
219+
mm2.whitelist = command_opts.pop("whitelist")
212220
# Fake a process response that can be serialized to json
213221
mm2.return_value = {"foo": "bar"}
214222
tracker.backends["event_transformer"].processors = [mm2]

0 commit comments

Comments
 (0)