Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use whitelisted events to identify known_events #426

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,7 @@ def is_known_event(self, event):
"""
if "name" in event:
for processor in self.engine.processors:
if event["name"] in processor.registry.mapping:
if event["name"] in processor.whitelist or 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,8 @@ 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}
mm2.registry.mapping = command_opts.pop("registry_mapping", {})
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