Skip to content

Commit

Permalink
fix: Add support for whitelist and legacy registry options (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
saraburns1 authored Jun 10, 2024
1 parent 2db667f commit 980b2aa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Change Log
Unreleased
~~~~~~~~~~
[9.2.1]

* Add support for either 'whitelist' or 'registry.mapping' options (whitelist introduced in v9.0.0)

[9.2.0]

Expand Down
2 changes: 1 addition & 1 deletion event_routing_backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Various backends for receiving edX LMS events..
"""

__version__ = '9.2.0'
__version__ = '9.2.1'
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def is_known_event(self, event):
"""
if "name" in event:
for processor in self.engine.processors:
if event["name"] in processor.registry.mapping:
if hasattr(processor, 'whitelist') and event["name"] in processor.whitelist:
return True
elif hasattr(processor, 'registry') and event["name"] in processor.registry.mapping:
return True
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def command_options():
"Sending to LRS!"
]
},
"registry_mapping": {"problem_check": 1},
},
# Remote file to LRS dry run no batch size
{
Expand All @@ -94,6 +95,7 @@ def command_options():
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 0 batches.",
]
},
"registry_mapping": {"problem_check": 1},
},
# Remote file to LRS, default batch size
{
Expand All @@ -112,6 +114,7 @@ def command_options():
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 1 batches.",
]
},
"whitelist": ["problem_check"]
},
# Local file to remote file
{
Expand All @@ -135,6 +138,7 @@ def command_options():
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 2 batches.",
]
},
"whitelist": ["problem_check"]
},
# Remote file dry run
{
Expand All @@ -157,6 +161,7 @@ def command_options():
"Queued 2 log lines, could not parse 2 log lines, skipped 8 log lines, sent 0 batches.",
]
},
"whitelist": ["problem_check"]
},
]

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

mm2 = MagicMock()
# Fake a router mapping so some events in the log are actually processed
mm2.registry.mapping = {"problem_check": 1}
if command_opts.get("registry_mapping"):
mm2.registry.mapping = command_opts.pop("registry_mapping")
if command_opts.get("whitelist"):
mm2.whitelist = command_opts.pop("whitelist")
# Fake a process response that can be serialized to json
mm2.return_value = {"foo": "bar"}
tracker.backends["event_transformer"].processors = [mm2]
Expand Down

0 comments on commit 980b2aa

Please sign in to comment.