Skip to content

Commit

Permalink
move the tests_events folder to tests (#3185)
Browse files Browse the repository at this point in the history
* move the tests_events folder to tests

* fix links in tests for the new location

* fix unit tests
  • Loading branch information
jaegeral authored Sep 20, 2024
1 parent 9f98556 commit 84980fb
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion end_to_end_tests/upload_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_datetime_out_of_normal_range_in_csv(self):
name=f"datetime_out_of_normal_range_in_csv_{rand}"
)
self.sketch = sketch
file_path = "/usr/local/src/timesketch/test_tools/test_events/validate_time_out_of_range.csv" # pylint: disable=line-too-long
file_path = "/usr/local/src/timesketch/tests/test_events/validate_time_out_of_range.csv" # pylint: disable=line-too-long
self.import_timeline(file_path, index_name=rand, sketch=sketch)
timeline = sketch.list_timelines()[0]
# check that timeline was uploaded correctly
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/test_events/validate_time_precision_datetime.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"message","timestamp","datetime","timestamp_desc","data_type"
"csv total precision in datetime","123456789","2024-07-24T10:57:02.877297Z","Write time","timestamptest1"
2 changes: 2 additions & 0 deletions tests/test_events/validate_time_precision_jsonl.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"message": "total precision in datetime jsonl","timestamp": 123456789,"datetime": "2024-07-24T10:57:02.877297Z","timestamp_desc": "Write time","data_type": "timestamptest1"}
{"message": "precision in timestamp jsonl","timestamp": 1331698658276340,"datetime": "2015-07-24T19:01:01+00:00","timestamp_desc": "Write time","data_type": "timestamptest2"}
2 changes: 1 addition & 1 deletion timesketch/lib/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class TestConfig(object):
SIMILARITY_DATA_TYPES = []
SIGMA_RULES_FOLDERS = ["./data/sigma/rules/"]
INTELLIGENCE_TAG_METADATA = "./data/intelligence_tag_metadata.yaml"
CONTEXT_LINKS_CONFIG_PATH = "./test_tools/test_events/mock_context_links.yaml"
CONTEXT_LINKS_CONFIG_PATH = "./tests/test_events/mock_context_links.yaml"
LLM_PROVIDER = "test"
DFIQ_ENABLED = False
DATA_TYPES_PATH = "./test_data/nl2q/test_data_types.csv"
Expand Down
20 changes: 7 additions & 13 deletions timesketch/lib/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from timesketch.lib.utils import rename_jsonl_headers


TEST_CSV = "test_tools/test_events/sigma_events.csv"
TEST_CSV = "tests/test_events/sigma_events.csv"
ISO8601_REGEX = (
r"^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0["
r"1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5]["
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_missing_timestamp_csv_file(self):
self.assertDictEqual(
next(
read_and_validate_csv(
"test_tools/test_events/validate_date_events_missing_timestamp.csv"
"tests/test_events/validate_date_events_missing_timestamp.csv"
)
),
expected_output,
Expand Down Expand Up @@ -225,9 +225,7 @@ def test_timestamp_is_ISOformat(self):
},
]
results = iter(
read_and_validate_csv(
"test_tools/test_events/validate_timestamp_conversion.csv"
)
read_and_validate_csv("tests/test_events/validate_timestamp_conversion.csv")
)
for output in expected_outputs:
self.assertDictEqual(next(results), output)
Expand All @@ -237,7 +235,7 @@ def test_missing_datetime_in_CSV(self):
to get it from timestamp or fail"""
results = iter(
read_and_validate_csv(
"test_tools/test_events/validate_no_datetime_timestamps.csv"
"tests/test_events/validate_no_datetime_timestamps.csv"
)
)

Expand Down Expand Up @@ -281,9 +279,7 @@ def test_time_datetime_valueerror(self):
"""

results = iter(
read_and_validate_csv("test_tools/test_events/invalid_datetime.csv")
)
results = iter(read_and_validate_csv("tests/test_events/invalid_datetime.csv"))
results_list = []
for item in results:
results_list.append(item)
Expand All @@ -303,9 +299,7 @@ def test_datetime_out_of_normal_range_in_csv(self):
https://github.com/google/timesketch/issues/1617
"""
results = iter(
read_and_validate_csv(
"test_tools/test_events/validate_time_out_of_range.csv"
)
read_and_validate_csv("tests/test_events/validate_time_out_of_range.csv")
)
results_list = []
for item in results:
Expand All @@ -319,7 +313,7 @@ def test_datetime_out_of_normal_range_in_csv(self):
def test_time_precision_in_csv(self):
"""Test for parsing a file with time precision"""
results = iter(
read_and_validate_csv("test_tools/test_events/validate_time_precision.csv")
read_and_validate_csv("tests/test_events/validate_time_precision.csv")
)
results_list = []
for item in results:
Expand Down

0 comments on commit 84980fb

Please sign in to comment.