From aceb99edfcd3834ce585f90f2d3859bbe5bfa323 Mon Sep 17 00:00:00 2001 From: Cristian Pufu Date: Fri, 12 Dec 2025 15:17:40 +0200 Subject: [PATCH] fix: test ci/cd --- pyproject.toml | 8 +------- src/aptabase/client.py | 10 +++++----- src/aptabase/exceptions.py | 3 ++- src/aptabase/models.py | 4 ++-- tests/__init__.py | 3 +++ tests/conftest.py | 1 + tests/test_dummy.py | 2 ++ 7 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_dummy.py diff --git a/pyproject.toml b/pyproject.toml index 64c8534..94a3a6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,6 @@ skip-magic-trailing-comma = false line-ending = "auto" [tool.mypy] -plugins = ["pydantic.mypy"] mypy_path = "src" explicit_package_bases = true namespace_packages = true @@ -82,15 +81,10 @@ check_untyped_defs = true no_implicit_reexport = true disallow_untyped_defs = false -[tool.pydantic-mypy] -init_forbid_extra = true -init_typed = true -warn_required_dynamic_aliases = true - [tool.pytest.ini_options] testpaths = ["tests"] python_files = "test_*.py" -addopts = "-ra -q --cov=src/uipath --cov-report=term-missing" +addopts = "-ra -q --cov=src/aptabase --cov-report=term-missing" asyncio_default_fixture_loop_scope = "function" asyncio_mode = "auto" diff --git a/src/aptabase/client.py b/src/aptabase/client.py index c8d931a..3ccf63e 100644 --- a/src/aptabase/client.py +++ b/src/aptabase/client.py @@ -28,8 +28,7 @@ def __init__( flush_interval: float = 10.0, timeout: float = 30.0, ) -> None: - """ - Initialize the Aptabase client. + """Initialize the Aptabase client. Args: app_key: Your Aptabase app key (format: A-{REGION}-{ID}) @@ -63,7 +62,7 @@ def __init__( self._event_queue: list[Event] = [] self._queue_lock = asyncio.Lock() self._client: httpx.AsyncClient | None = None - self._flush_task: asyncio.Task | None = None + self._flush_task: asyncio.Task[Any] | None = None self._session_id: str | None = None def _get_base_url(self, app_key: str) -> str: @@ -123,8 +122,7 @@ async def track( *, session_id: str | None = None, ) -> None: - """ - Track an analytics event. + """Track an analytics event. Args: event_name: Name of the event to track @@ -172,6 +170,8 @@ async def _flush_events(self) -> None: async def _send_events(self, events: list[Event]) -> None: """Send events to the Aptabase API.""" + assert self._client is not None, "HTTP client is not initialized" + if not events: return diff --git a/src/aptabase/exceptions.py b/src/aptabase/exceptions.py index b2c249e..094c18b 100644 --- a/src/aptabase/exceptions.py +++ b/src/aptabase/exceptions.py @@ -16,7 +16,8 @@ class ConfigurationError(AptabaseError): class NetworkError(AptabaseError): """Raised when network requests fail.""" - def __init__(self, message: str, status_code: int = None) -> None: + def __init__(self, message: str, status_code: int | None = None) -> None: + """Initialize the NetworkError exception.""" super().__init__(message) self.status_code = status_code diff --git a/src/aptabase/models.py b/src/aptabase/models.py index c8050fa..a324398 100644 --- a/src/aptabase/models.py +++ b/src/aptabase/models.py @@ -39,9 +39,9 @@ class Event: """Represents an analytics event to be sent to Aptabase.""" name: str - props: dict[str, Any] | None = None timestamp: datetime | None = None session_id: str | None = None + props: dict[str, Any] | None = None def __post_init__(self) -> None: """Set default values after initialization.""" @@ -55,7 +55,7 @@ def __post_init__(self) -> None: def to_dict(self, system_props: SystemProperties) -> dict[str, Any]: """Convert to dictionary format for API requests.""" return { - "timestamp": self.timestamp.isoformat() + "Z", + "timestamp": self.timestamp.isoformat() + "Z" if self.timestamp else None, "sessionId": self.session_id, "eventName": self.name, "systemProps": system_props.to_dict(), diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..4621060 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +""" +Test suite for Aptabase Python SDK. +""" diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..43580d0 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1 @@ +"""Shared pytest fixtures for all tests.""" diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..f4f5361 --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,2 @@ +def test_dummy(): + assert True