Skip to content

Commit

Permalink
feat!: feature add test name in test_string
Browse files Browse the repository at this point in the history
pytest.expect files containing requirement tests needs update
  • Loading branch information
nandinivij committed Jan 21, 2022
1 parent f6ecef4 commit f9020f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def generate_cim_req_params(self):
for event_tag in root.iter("event"):
event_no += 1
unescaped_event = self.get_event(event_tag)
event_name = self.get_event_name(event_tag)
transport_type = self.extract_transport_tag(event_tag)
if transport_type.lower() == "syslog":
stripped_event = self.strip_syslog_header(unescaped_event)
Expand Down Expand Up @@ -200,9 +201,16 @@ def generate_cim_req_params(self):
"transport_type": transport_type,
"exceptions_dict": exceptions_dict,
},
id=f"{(' '.join(model_list))}::{filename}::event_no::{event_no}",
id=f"{(' '.join(model_list))}::{filename}::event_no::{event_no}::event_name::{event_name}",
)

def get_event_name(self, event_tag):
"""
Input: Event tag
Function to return event name
"""
return event_tag.get("name")

def get_models(self, root):
"""
Input: Root of the xml file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_extract_params():
"extract_transport_tag_return_value, "
"root_events, "
"get_models_return_value, "
"get_event_name_return_value, "
"extract_key_value_xml_return_value, "
"expected_output",
[
Expand All @@ -108,6 +109,7 @@ def test_extract_params():
["syslog"],
{"event": ["<34>Oct 11 22:14:15 machine1 pr1:event_1"]},
[["model_1:dataset_1", "model_2:dataset_2"]],
["event_name_1"],
[{"field1": "value1", "field2": "value2"}, {"field3": "value3"}],
[
(
Expand All @@ -123,7 +125,7 @@ def test_extract_params():
"transport_type": "syslog",
},
"model_1:dataset_1 "
"model_2:dataset_2::fake_path/requirement.log::event_no::1",
"model_2:dataset_2::fake_path/requirement.log::event_no::1::event_name::event_name_1",
),
],
),
Expand All @@ -133,6 +135,7 @@ def test_extract_params():
["syslog"],
{"event": ["event_1", "event_2"]},
[["model_1:dataset_1", "model_2:dataset_2"], ["model_3:dataset_3"]],
["event_name_2"],
[{"field1": "value1", "field2": "value2"}, {"field3": "value3"}],
[],
),
Expand All @@ -142,6 +145,7 @@ def test_extract_params():
["syslog"],
{"event": ["event_1"]},
[[]],
["event_name_3"],
[{"field1": "value1", "field2": "value2"}, {"field3": "value3"}],
[],
),
Expand All @@ -155,6 +159,7 @@ def test_generate_cim_req_params(
extract_transport_tag_return_value,
root_events,
get_models_return_value,
get_event_name_return_value,
extract_key_value_xml_return_value,
expected_output,
):
Expand All @@ -177,6 +182,8 @@ def test_generate_cim_req_params(
ReqsTestGenerator, "escape_char_event", side_effect=lambda x: x
), patch.object(
ReqsTestGenerator, "get_models", side_effect=get_models_return_value
), patch.object(
ReqsTestGenerator, "get_event_name", side_effect=get_event_name_return_value
), patch.object(
ReqsTestGenerator,
"extract_key_value_xml",
Expand Down

0 comments on commit f9020f4

Please sign in to comment.