diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b76c02..ea92566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ and this project adheres to ## [Unreleased] +### Changed + +- Re-export all public models from `__init__.py` and define `__all__` + ([1dcfbef], [#21]) +- Tests now import from `l9format` package directly instead of + `l9format.l9format` ([e8aef2e], [#21]) + ## [1.4.0] - 2026-02-07 ### Added @@ -125,6 +132,8 @@ and this project adheres to +[1dcfbef]: https://github.com/LeakIX/l9format-python/commit/1dcfbef +[e8aef2e]: https://github.com/LeakIX/l9format-python/commit/e8aef2e [8f45e82]: https://github.com/LeakIX/l9format-python/commit/8f45e82 [82245e9]: https://github.com/LeakIX/l9format-python/commit/82245e9 [fac243d]: https://github.com/LeakIX/l9format-python/commit/fac243d @@ -183,3 +192,4 @@ and this project adheres to [#15]: https://github.com/LeakIX/l9format-python/pull/15 [#16]: https://github.com/LeakIX/l9format-python/pull/16 [#18]: https://github.com/LeakIX/l9format-python/pull/18 +[#21]: https://github.com/LeakIX/l9format-python/issues/21 diff --git a/l9format/__init__.py b/l9format/__init__.py index 3e8d9f9..a2a2201 100644 --- a/l9format/__init__.py +++ b/l9format/__init__.py @@ -1 +1,67 @@ __version__ = "1.4.0" + +from l9format.l9format import ( + Certificate, + DatasetSummary, + GeoLocation, + GeoPoint, + L9Aggregation, + L9AMQPEvent, + L9DNSEvent, + L9Event, + L9FTPEvent, + L9HttpEvent, + L9LDAPEvent, + L9LeakEvent, + L9MemcachedEvent, + L9MongoDBEvent, + L9MySQLEvent, + L9PostgreSQLEvent, + L9RDPEvent, + L9RedisEvent, + L9RTSPEvent, + L9ServiceEvent, + L9SIPEvent, + L9SMTPEvent, + L9SSHEvent, + L9SSLEvent, + L9TelnetEvent, + L9VNCEvent, + Network, + ServiceCredentials, + Software, + SoftwareModule, +) + +__all__ = [ + "Certificate", + "DatasetSummary", + "GeoLocation", + "GeoPoint", + "L9Aggregation", + "L9AMQPEvent", + "L9DNSEvent", + "L9Event", + "L9FTPEvent", + "L9HttpEvent", + "L9LDAPEvent", + "L9LeakEvent", + "L9MemcachedEvent", + "L9MongoDBEvent", + "L9MySQLEvent", + "L9PostgreSQLEvent", + "L9RDPEvent", + "L9RedisEvent", + "L9RTSPEvent", + "L9ServiceEvent", + "L9SIPEvent", + "L9SMTPEvent", + "L9SSHEvent", + "L9SSLEvent", + "L9TelnetEvent", + "L9VNCEvent", + "Network", + "ServiceCredentials", + "Software", + "SoftwareModule", +] diff --git a/tests/test_l9format.py b/tests/test_l9format.py index 153d7b3..da3b924 100644 --- a/tests/test_l9format.py +++ b/tests/test_l9format.py @@ -2,7 +2,7 @@ import os from pathlib import Path -from l9format import l9format +from l9format import L9Event TESTS_DIR = Path(os.path.dirname(__file__)) @@ -16,13 +16,13 @@ def test_l9event_json_from_reference_repository(): path = TESTS_DIR / "l9event.json" c = json.load(open(str(path), "r")) - l9format.L9Event.from_dict(c) + L9Event.from_dict(c) def test_l9events_form_ip4scout(): for path in IP4SCOUT_FILES: c = json.load(open(str(path), "r")) - l9format.L9Event.from_dict(c) + L9Event.from_dict(c) def test_iso8601_nanosecond_parsing(): @@ -36,10 +36,50 @@ def test_iso8601_nanosecond_parsing(): c = json.load(open(str(path), "r")) # Use a timestamp with nanosecond precision (9 decimal places) c["time"] = "2023-10-05T23:30:36.823867784Z" - event = l9format.L9Event.from_dict(c) + event = L9Event.from_dict(c) assert event.time.year == 2023 assert event.time.month == 10 assert event.time.day == 5 assert event.time.hour == 23 assert event.time.minute == 30 assert event.time.second == 36 + + +def test_all_models_importable_from_package(): + """Verify all public models are importable from the l9format package.""" + import l9format + + expected_models = [ + "Certificate", + "DatasetSummary", + "GeoLocation", + "GeoPoint", + "L9Aggregation", + "L9AMQPEvent", + "L9DNSEvent", + "L9Event", + "L9FTPEvent", + "L9HttpEvent", + "L9LDAPEvent", + "L9LeakEvent", + "L9MemcachedEvent", + "L9MongoDBEvent", + "L9MySQLEvent", + "L9PostgreSQLEvent", + "L9RDPEvent", + "L9RedisEvent", + "L9RTSPEvent", + "L9ServiceEvent", + "L9SIPEvent", + "L9SMTPEvent", + "L9SSHEvent", + "L9SSLEvent", + "L9TelnetEvent", + "L9VNCEvent", + "Network", + "ServiceCredentials", + "Software", + "SoftwareModule", + ] + for name in expected_models: + assert hasattr(l9format, name), f"{name} not importable from l9format"