Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ and this project adheres to
([1dcfbef], [#21])
- Tests now import from `l9format` package directly instead of
`l9format.l9format` ([e8aef2e], [#21])
- Use `pytest.mark.parametrize` for ip4scout tests so each file is a distinct
test case ([ac4744e], [#32])

### Fixed

Expand Down Expand Up @@ -160,6 +162,7 @@ and this project adheres to

<!-- Commit links -->

[ac4744e]: https://github.com/LeakIX/l9format-python/commit/ac4744e
[d554f1e]: https://github.com/LeakIX/l9format-python/commit/d554f1e
[7f49ff5]: https://github.com/LeakIX/l9format-python/commit/7f49ff5
[cd74b55]: https://github.com/LeakIX/l9format-python/commit/cd74b55
Expand Down Expand Up @@ -241,4 +244,5 @@ and this project adheres to
[#35]: https://github.com/LeakIX/l9format-python/issues/35
[#24]: https://github.com/LeakIX/l9format-python/issues/24
[#31]: https://github.com/LeakIX/l9format-python/issues/31
[#32]: https://github.com/LeakIX/l9format-python/issues/32
[#43]: https://github.com/LeakIX/l9format-python/issues/43
32 changes: 16 additions & 16 deletions tests/test_l9format.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import json
from pathlib import Path

import pytest

from l9format import L9Event

TESTS_DIR = Path(__file__).parent

IP4SCOUT_FILES = [
f
for f in Path.iterdir(TESTS_DIR)
if Path.is_file(f) and "ip4scout" in f.name
]
IP4SCOUT_FILES = sorted(
f for f in TESTS_DIR.iterdir() if f.is_file() and "ip4scout" in f.name
)


def test_l9event_json_from_reference_repository() -> None:
Expand Down Expand Up @@ -55,17 +55,17 @@ def test_l9event_json_from_reference_repository() -> None:
]


def test_l9events_from_ip4scout() -> None:
for path in IP4SCOUT_FILES:
with open(path) as f:
c = json.load(f)
event = L9Event.from_dict(c)
assert event.event_source == "ip4scout"
assert event.event_type == "synack"
assert isinstance(event.ip, str)
assert len(event.ip) > 0
assert isinstance(event.port, str)
assert len(event.port) > 0
@pytest.mark.parametrize("path", IP4SCOUT_FILES, ids=lambda p: p.name)
def test_l9events_from_ip4scout(path: Path) -> None:
with open(path) as f:
c = json.load(f)
event = L9Event.from_dict(c)
assert event.event_source == "ip4scout"
assert event.event_type == "synack"
assert isinstance(event.ip, str)
assert len(event.ip) > 0
assert isinstance(event.port, str)
assert len(event.port) > 0


def test_iso8601_nanosecond_parsing() -> None:
Expand Down