Skip to content

Commit

Permalink
fix: add tests for whitelist or mapping options
Browse files Browse the repository at this point in the history
  • Loading branch information
saraburns1 committed Jun 5, 2024
1 parent 01668e8 commit 5b6ea62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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.whitelist:
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.whitelist = {"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 All @@ -233,8 +239,6 @@ def test_transform_command(command_opts, mock_common_calls, caplog, capsys):
assert "Expecting ',' delimiter: line 1 column 63 (char 62)" in caplog.text

# Check the specific expected log lines for this set of options
print(caplog.text)
print(captured.out)
for line in expected_results["log_lines"]:
assert line in caplog.text or line in captured.out

Expand Down

0 comments on commit 5b6ea62

Please sign in to comment.