Add test files (unit and integration tests)
Some checks failed
Some checks failed
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
"""Unit tests for log parsers."""
|
"""Unit tests for log parsers."""
|
||||||
|
|
||||||
import pytest
|
from loglens.parsers.apache_parser import ApacheParser
|
||||||
from loglens.parsers.base import LogFormat, ParsedLogEntry
|
from loglens.parsers.base import LogFormat
|
||||||
|
from loglens.parsers.factory import ParserFactory
|
||||||
from loglens.parsers.json_parser import JSONParser
|
from loglens.parsers.json_parser import JSONParser
|
||||||
from loglens.parsers.syslog_parser import SyslogParser
|
from loglens.parsers.syslog_parser import SyslogParser
|
||||||
from loglens.parsers.apache_parser import ApacheParser
|
|
||||||
from loglens.parsers.factory import ParserFactory
|
|
||||||
|
|
||||||
|
|
||||||
class TestJSONParser:
|
class TestJSONParser:
|
||||||
@@ -29,7 +28,7 @@ class TestJSONParser:
|
|||||||
parser = JSONParser()
|
parser = JSONParser()
|
||||||
|
|
||||||
assert parser.can_parse('{"key": "value"}')
|
assert parser.can_parse('{"key": "value"}')
|
||||||
assert parser.can_parse('[1, 2, 3]')
|
assert parser.can_parse("[1, 2, 3]")
|
||||||
assert not parser.can_parse("not json")
|
assert not parser.can_parse("not json")
|
||||||
assert not parser.can_parse("")
|
assert not parser.can_parse("")
|
||||||
|
|
||||||
@@ -120,7 +119,7 @@ class TestApacheParser:
|
|||||||
def test_error_log(self):
|
def test_error_log(self):
|
||||||
"""Test parsing Apache error log."""
|
"""Test parsing Apache error log."""
|
||||||
parser = ApacheParser()
|
parser = ApacheParser()
|
||||||
line = '[Sat Jan 15 10:30:00.123456 2024] [mpm_prefork:notice] [pid 1234] AH00163: Apache configured'
|
line = "[Sat Jan 15 10:30:00.123456 2024] [mpm_prefork:notice] [pid 1234] AH00163: Apache configured"
|
||||||
|
|
||||||
entry = parser.parse(line, 1)
|
entry = parser.parse(line, 1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user