34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import re
|
|
|
|
import pytest
|
|
|
|
from logwatcher.config import FIXTURE_PATH
|
|
from logwatcher.parser import parse_log_line
|
|
|
|
|
|
@pytest.fixture(name="log_data")
|
|
def load_logs_fixture() -> dict[str, list[str]]:
|
|
file_content_list: dict[str, list[str]] = {}
|
|
|
|
for file_path in FIXTURE_PATH.iterdir():
|
|
with open(file_path, 'r') as file:
|
|
file_content_list[file_path.name] = []
|
|
for line in file:
|
|
if re.match(r"\\\\", line):
|
|
file_content_list[file_path.name].append(line)
|
|
|
|
return file_content_list
|
|
|
|
def test_create_log_entry(log_data: dict[str, list[str]]):
|
|
for log_list in log_data.values():
|
|
for log in log_list:
|
|
log_entry = parse_log_line(log)
|
|
if log_entry:
|
|
assert log_entry.server_ip is not None
|
|
assert log_entry.mdc_server_name is not None
|
|
assert log_entry.start_time is not None
|
|
assert log_entry.store_name is not None
|
|
assert log_entry.error_time is not None
|
|
assert log_entry.error_message is not None
|
|
assert log_entry.raw_line != ''
|