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
23 changes: 19 additions & 4 deletions tests/unit/models/config/test_a2a_state_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# pylint: disable=no-member

import pytest
from pydantic import ValidationError
from pydantic import SecretStr, ValidationError

import constants

from models.config import (
A2AStateConfiguration,
Expand Down Expand Up @@ -42,7 +44,11 @@ def test_postgres_configuration(self) -> None:
port=5432,
db="a2a_state",
user="lightspeed",
password="secret",
password=SecretStr("secret"),
namespace="namespace",
ssl_mode=constants.POSTGRES_DEFAULT_SSL_MODE,
gss_encmode=constants.POSTGRES_DEFAULT_GSS_ENCMODE,
ca_cert_path=None,
)
config = A2AStateConfiguration(postgres=postgres_config)

Expand All @@ -52,6 +58,9 @@ def test_postgres_configuration(self) -> None:
assert config.postgres.port == 5432
assert config.postgres.db == "a2a_state"
assert config.config == postgres_config
assert config.postgres.namespace == "namespace"
assert config.postgres.ssl_mode == constants.POSTGRES_DEFAULT_SSL_MODE
assert config.postgres.gss_encmode == constants.POSTGRES_DEFAULT_GSS_ENCMODE

def test_postgres_with_all_options(self) -> None:
"""Test PostgreSQL configuration with all options."""
Expand All @@ -60,14 +69,16 @@ def test_postgres_with_all_options(self) -> None:
port=5433,
db="lightspeed",
user="admin",
password="secret123",
password=SecretStr("secret123"),
namespace="a2a",
ssl_mode="require",
gss_encmode=constants.POSTGRES_DEFAULT_GSS_ENCMODE,
ca_cert_path=None,
)
config = A2AStateConfiguration(postgres=postgres_config)

assert config.storage_type == "postgres"
assert config.postgres is not None
assert config.postgres.host == "postgres.example.com"
assert config.postgres.port == 5433
assert config.postgres.namespace == "a2a"
Expand All @@ -82,7 +93,11 @@ def test_both_sqlite_and_postgres_raises_error(self, tmp_path: str) -> None:
port=5432,
db="test",
user="test",
password="test",
password=SecretStr("test"),
namespace="namespace",
ssl_mode=constants.POSTGRES_DEFAULT_SSL_MODE,
gss_encmode=constants.POSTGRES_DEFAULT_GSS_ENCMODE,
ca_cert_path=None,
)

with pytest.raises(ValidationError) as exc_info:
Expand Down
Loading
Loading