Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarasani-crest committed Sep 26, 2024
1 parent f4e4020 commit 55705f8
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 60 deletions.
2 changes: 1 addition & 1 deletion pytest_splunk_addon/addon_parser/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Field(object):
* name (str): name of the field
* type (str): Field type. Supported [required, conditional, optional]
* multi_value (bool): True is field is multi value field
* multi_value (bool): True if field is multi value field
* expected_values (list): The field should have this expected values
* negative_values (list): The field should not have negative values
* condition (spl): The field should only be checked if the condition satisfies
Expand Down
2 changes: 1 addition & 1 deletion pytest_splunk_addon/cim_tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def generate_recommended_fields_tests(self):
Generates the tests to check all the recommended cim fields of the mapped data model are extracted.
1. Get a list of fields defined in cim_fields and missing_recommended_fields
2. combine hte fields list with the defined exceptions
2. combine the fields list with the defined exceptions
3. yield object with datamodel, dataset, cim_version and list of fields
"""
for event in self.tokenized_events:
Expand Down
28 changes: 14 additions & 14 deletions pytest_splunk_addon/cim_tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CIMTestTemplates(object):
Test scenarios to check the CIM compatibility of an Add-on
Supported Test scenarios:
- The eventtype should exctract all required fields of data model
- The eventtype should extract all required fields of data model
- One eventtype should not be mapped with more than one data model
- Field Cluster should be verified (should be included with required field test)
- Verify if CIM installed or not
Expand Down Expand Up @@ -59,10 +59,10 @@ def test_cim_required_fields(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_cim_fields (fixture): Pytest parameter to test required cim field extraction
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
"""

cim_data_set = splunk_searchtime_cim_fields["data_set"]
Expand Down Expand Up @@ -172,11 +172,11 @@ def test_cim_fields_not_allowed_in_search(
- Expected event_count for these fields is zero.
Args:
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_cim_fields_not_allowed_in_search (fixture): Object which contain list of fields not_allowed_in_search
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
"""
cim_dataset = splunk_searchtime_cim_fields_not_allowed_in_search["data_set"]
cim_fields = splunk_searchtime_cim_fields_not_allowed_in_search["fields"]
Expand Down Expand Up @@ -274,10 +274,10 @@ def test_cim_fields_not_allowed_in_props(
This testcase checks for cim field of type ["not_allowed_in_search_and_props", "not_allowed_in_props"] if an extraction is defined in the configuration file.
Args:
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_cim_fields_not_allowed_in_props (fixture): Object which contain list of fields not allowed in props
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
"""
result_str = (
"The field extractions are not allowed in the configuration files"
Expand Down Expand Up @@ -314,10 +314,10 @@ def test_eventtype_mapped_multiple_cim_datamodel(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_cim_mapped_datamodel (fixture): Object which contain eventtype list
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""

Expand Down Expand Up @@ -514,7 +514,7 @@ def test_cim_fields_recommended(
self, splunk_dm_recommended_fields, splunk_searchtime_cim_fields_recommended
):
"""
This test case check that all the recommended cim fields of datamodel mapped with event are exracted.
This test case check that all the recommended cim fields of datamodel mapped with event are extracted.
Args:
splunk_dm_recommended_fields (fixture): function which gets recommended fields for given datamodel
Expand Down
2 changes: 1 addition & 1 deletion pytest_splunk_addon/event_ingestors/ingestor_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def ingest_events(
Args:
ingest_meta_data (dict): Dictionary of required meta_data.
addon_path (str): Path to Splunk app package.
config_path (str): Path to pytest-splunk-addon-sample-generator.conf.
config_path (str): Path to pytest-splunk-addon-data.conf
thread_count (int): number of threads to use for ingestion
store_events (bool): Boolean param for generating json files with tokenised events
"""
Expand Down
4 changes: 2 additions & 2 deletions pytest_splunk_addon/fields_tests/sample_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_sample_files(folder_path):

def parse_file(filename):
"""
Parse the xml sample file to get the lisst of events
Parse the xml sample file to get the list of events
Args:
filename (str): file name of the sample xml
Expand Down Expand Up @@ -364,7 +364,7 @@ def __init__(self, event_tag):

def get_transport_type(self):
"""
Function to get the transport type of the evnt
Function to get the transport type of the event
Raises:
ValueError: if transport type defined for the event is not supported
Expand Down
44 changes: 22 additions & 22 deletions pytest_splunk_addon/fields_tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_splunk_internal_errors(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
ignore_internal_errors (fixture): common list of errors to be ignored
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""
search = """
Expand Down Expand Up @@ -91,10 +91,10 @@ def test_props_fields(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_positive (fixture): fields data of the event to be tested
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
"""

# Search Query
Expand Down Expand Up @@ -155,10 +155,10 @@ def test_requirements_fields(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_requirements (fixture): fields data of the event to be tested
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
"""

# Search Query
Expand Down Expand Up @@ -242,10 +242,10 @@ def test_props_fields_no_dash_not_empty(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_negative (fixture): fields data of the event to be tested
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
"""

# Search Query
Expand Down Expand Up @@ -318,10 +318,10 @@ def test_tags(
Args:
splunk_search_util (splunksplwrapper.SearchUtil.SearchUtil): object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_tags (fixture): pytest parameters to test.
record_property (fixture): pytest fixture to document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""

Expand Down Expand Up @@ -386,10 +386,10 @@ def test_datamodels(
Args:
splunk_search_util (splunksplwrapper.SearchUtil.SearchUtil):
object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_datamodels (fixture): pytest parameters to test.
record_property (fixture): pytest fixture to document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""
esacaped_event = splunk_searchtime_fields_datamodels["stanza"]
Expand Down Expand Up @@ -486,10 +486,10 @@ def test_eventtype(
Args:
splunk_search_util (splunksplwrapper.SearchUtil.SearchUtil):
object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_eventtypes (fixture): Fixture containing list of eventtypes
record_property (fixture): Used to add user properties to test report
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): Access and control log capturing
Returns:
Expand Down Expand Up @@ -544,10 +544,10 @@ def test_savedsearches(
Args:
splunk_search_util (splunksplwrapper.SearchUtil.SearchUtil):
object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_searchtime_fields_savedsearches (fixture): Fixture containing list of savedsearches
record_property (fixture): Used to add user properties to test report
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): Access and control log capturing
Returns:
Expand Down
18 changes: 9 additions & 9 deletions pytest_splunk_addon/index_tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def test_indextime_key_fields(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_indextime_key_fields (fixture): Test for key fields
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""

Expand Down Expand Up @@ -194,10 +194,10 @@ def test_indextime_time(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_indextime_time (fixture): Test for _time field
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""
index_list = (
Expand Down Expand Up @@ -282,10 +282,10 @@ def test_indextime_line_breaker(
Args:
splunk_search_util (SearchUtil): Object that helps to search on Splunk.
splunk_ingest_data (fixture): Unused but required to ensure data was ingested before running test
splunk_setup (fixture): Unused but required to ensure that test environment was set up before running test
splunk_ingest_data (fixture): Ensure data was ingested before running test
splunk_setup (fixture): Ensure that test environment was set up before running test
splunk_indextime_line_breaker (fixture): Test for event count
record_property (fixture): Document facts of test cases.
record_property (fixture): Document facts of test cases to provide more info in the test failure reports.
caplog (fixture): fixture to capture logs.
"""
expected_events_count = int(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def test_unicode_char(filename):
ValueError: if file contains unicode chars
"""
invalid = False
# pattern = re.compile("[^\x00-\x7F]") #do ot want to replace printable chars like €¢ etc
pattern = re.compile(
"[\u200B-\u200E\uFEFF\u202c\u202D\u2063\u2062]"
) # zero width characters
Expand Down
8 changes: 4 additions & 4 deletions pytest_splunk_addon/sample_generation/time_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def convert_to_time(self, sign, num, unit):
Args :
sign (str): to increase or decrease time
num (num): time value
unit (str): unit of time eg: seconds,minuits etc
unit (str): unit of time eg: seconds,minutes etc
Returns :
datetime formated time
datetime formatted time
"""
num = int(num)
unittime = None
Expand Down Expand Up @@ -137,14 +137,14 @@ def convert_to_time(self, sign, num, unit):

def get_timezone_time(self, random_time, timezone_time):
"""
Converts timezone formated time into datetime object for earliest and latest
Converts timezone formatted time into datetime object for earliest and latest
Args:
random_time (datetime): datetime object
timezone_time (str): timezone time string
Returns:
datetime formated time
datetime formatted time
"""

sign, hrs, mins = re.match(r"([+-])(\d\d)(\d\d)", timezone_time).groups()
Expand Down
6 changes: 3 additions & 3 deletions pytest_splunk_addon/splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def splunk_search_util(splunk, request):
Returns:
splunksplwrapper.SearchUtil.SearchUtil: The SearchUtil object
"""
LOGGER.info("Initializing SearchUtil for the Splunk instace.")
LOGGER.info("Initializing SearchUtil for the Splunk instance.")
cloud_splunk = CloudSplunk(
splunkd_host=splunk["host"],
splunkd_port=splunk["port"],
Expand All @@ -381,7 +381,7 @@ def splunk_search_util(splunk, request):

conn = cloud_splunk.create_logged_in_connector()
jobs = Jobs(conn)
LOGGER.info("initialized SearchUtil for the Splunk instace.")
LOGGER.info("initialized SearchUtil for the Splunk instance.")
search_util = SearchUtil(jobs, LOGGER)
search_util.search_index = request.config.getoption("search_index")
search_util.search_retry = request.config.getoption("search_retry")
Expand All @@ -393,7 +393,7 @@ def splunk_search_util(splunk, request):
@pytest.fixture(scope="session")
def ignore_internal_errors(request):
"""
This fixture generates a common list of errors which are suppossed
This fixture generates a common list of errors which are supposed
to be ignored in test_splunk_internal_errors.
Returns:
Expand Down
Loading

0 comments on commit 55705f8

Please sign in to comment.