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
16 changes: 8 additions & 8 deletions tests/unit/quota/test_cluster_quota_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_quota_limiter(
return quota_limiter


def test_connected():
def test_connected() -> None:
"""Test the connected method."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -44,7 +44,7 @@ def test_connected():
assert quota_limiter.connected()


def test_init_quota():
def test_init_quota() -> None:
"""Test the init quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -59,7 +59,7 @@ def test_init_quota():
)


def test_available_quota():
def test_available_quota() -> None:
"""Test the available quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -73,7 +73,7 @@ def test_available_quota():
assert available_quota == initial_quota


def test_consume_tokens():
def test_consume_tokens() -> None:
"""Test the consume tokens operation."""
initial_quota = 1000
quota_limit = 100
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_consume_tokens():
assert available_quota == initial_quota - 4


def test_increase_quota():
def test_increase_quota() -> None:
"""Test the increase_quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -124,7 +124,7 @@ def test_increase_quota():
assert available_quota == initial_quota - 1


def test_ensure_available_quota():
def test_ensure_available_quota() -> None:
"""Test the ensure_available_quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -137,7 +137,7 @@ def test_ensure_available_quota():
quota_limiter.ensure_available_quota("foo")


def test_ensure_available_quota_no_quota():
def test_ensure_available_quota_no_quota() -> None:
"""Test the ensure_available_quota operation."""
initial_quota = 0
quota_limit = 100
Expand All @@ -151,7 +151,7 @@ def test_ensure_available_quota_no_quota():
quota_limiter.ensure_available_quota("foo")


def test_revoke_quota():
def test_revoke_quota() -> None:
"""Test the revoke_quota operation."""
initial_quota = 1000
quota_limit = 100
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/quota/test_connect_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from models.config import PostgreSQLDatabaseConfiguration


def test_connect_pg_when_connection_established(mocker: MockerFixture):
def test_connect_pg_when_connection_established(mocker: MockerFixture) -> None:
"""Test the connection to PostgreSQL database."""
# any correct PostgreSQL configuration can be used
configuration = PostgreSQLDatabaseConfiguration(
Expand All @@ -24,7 +24,7 @@ def test_connect_pg_when_connection_established(mocker: MockerFixture):
assert connection is not None


def test_connect_pg_when_connection_error(mocker: MockerFixture):
def test_connect_pg_when_connection_error(mocker: MockerFixture) -> None:
"""Test the connection to PostgreSQL database."""
# any correct PostgreSQL configuration can be used
configuration = PostgreSQLDatabaseConfiguration(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/quota/test_connect_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from models.config import SQLiteDatabaseConfiguration


def test_connect_sqlite_when_connection_established():
def test_connect_sqlite_when_connection_established() -> None:
"""Test the connection to SQLite database residing in memory."""
configuration = SQLiteDatabaseConfiguration(db_path=":memory:")

Expand All @@ -17,7 +17,7 @@ def test_connect_sqlite_when_connection_established():
assert connection is not None


def test_connect_sqlite_when_connection_error():
def test_connect_sqlite_when_connection_error() -> None:
"""Test the connection to SQLite database."""
configuration = SQLiteDatabaseConfiguration(db_path="/")

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/quota/test_quota_exceed_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from quota.quota_exceed_error import QuotaExceedError


def test_quota_exceed_error_constructor():
def test_quota_exceed_error_constructor() -> None:
"""Test the QuotaExceedError constructor."""
expected = "User 1234 has 100 tokens, but 1000 tokens are needed"
with pytest.raises(QuotaExceedError, match=expected):
Expand Down
26 changes: 15 additions & 11 deletions tests/unit/quota/test_quota_limiter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from quota.user_quota_limiter import UserQuotaLimiter


def test_quota_limiters_no_storage():
def test_quota_limiters_no_storage() -> None:
"""Test the quota limiters creating when no storage is configured."""
configuration = QuotaHandlersConfiguration()
configuration.sqlite = None
Expand All @@ -24,7 +24,7 @@ def test_quota_limiters_no_storage():
assert not limiters


def test_quota_limiters_no_limiters_pg_storage():
def test_quota_limiters_no_limiters_pg_storage() -> None:
"""Test the quota limiters creating when no limiters are specified."""
configuration = QuotaHandlersConfiguration()
configuration.postgres = PostgreSQLDatabaseConfiguration(
Expand All @@ -35,7 +35,7 @@ def test_quota_limiters_no_limiters_pg_storage():
assert not limiters


def test_quota_limiters_no_limiters_sqlite_storage():
def test_quota_limiters_no_limiters_sqlite_storage() -> None:
"""Test the quota limiters creating when no limiters are specified."""
configuration = QuotaHandlersConfiguration()
configuration.sqlite = SQLiteDatabaseConfiguration(
Expand All @@ -46,7 +46,7 @@ def test_quota_limiters_no_limiters_sqlite_storage():
assert not limiters


def test_quota_limiters_empty_limiters_pg_storage():
def test_quota_limiters_empty_limiters_pg_storage() -> None:
"""Test the quota limiters creating when no limiters are specified."""
configuration = QuotaHandlersConfiguration()
configuration.postgres = PostgreSQLDatabaseConfiguration(
Expand All @@ -57,7 +57,7 @@ def test_quota_limiters_empty_limiters_pg_storage():
assert not limiters


def test_quota_limiters_empty_limiters_sqlite_storage():
def test_quota_limiters_empty_limiters_sqlite_storage() -> None:
"""Test the quota limiters creating when no limiters are specified."""
configuration = QuotaHandlersConfiguration()
configuration.sqlite = SQLiteDatabaseConfiguration(
Expand All @@ -68,7 +68,9 @@ def test_quota_limiters_empty_limiters_sqlite_storage():
assert not limiters


def test_quota_limiters_user_quota_limiter_postgres_storage(mocker: MockerFixture):
def test_quota_limiters_user_quota_limiter_postgres_storage(
mocker: MockerFixture,
) -> None:
"""Test the quota limiters creating when one limiter is specified."""
configuration = QuotaHandlersConfiguration()
configuration.postgres = PostgreSQLDatabaseConfiguration(
Expand All @@ -90,7 +92,7 @@ def test_quota_limiters_user_quota_limiter_postgres_storage(mocker: MockerFixtur
assert isinstance(limiters[0], UserQuotaLimiter)


def test_quota_limiters_user_quota_limiter_sqlite_storage():
def test_quota_limiters_user_quota_limiter_sqlite_storage() -> None:
"""Test the quota limiters creating when one limiter is specified."""
configuration = QuotaHandlersConfiguration()
configuration.sqlite = SQLiteDatabaseConfiguration(
Expand All @@ -110,7 +112,9 @@ def test_quota_limiters_user_quota_limiter_sqlite_storage():
assert isinstance(limiters[0], UserQuotaLimiter)


def test_quota_limiters_cluster_quota_limiter_postgres_storage(mocker: MockerFixture):
def test_quota_limiters_cluster_quota_limiter_postgres_storage(
mocker: MockerFixture,
) -> None:
"""Test the quota limiters creating when one limiter is specified."""
configuration = QuotaHandlersConfiguration()
configuration.postgres = PostgreSQLDatabaseConfiguration(
Expand All @@ -132,7 +136,7 @@ def test_quota_limiters_cluster_quota_limiter_postgres_storage(mocker: MockerFix
assert isinstance(limiters[0], ClusterQuotaLimiter)


def test_quota_limiters_cluster_quota_limiter_sqlite_storage():
def test_quota_limiters_cluster_quota_limiter_sqlite_storage() -> None:
"""Test the quota limiters creating when one limiter is specified."""
configuration = QuotaHandlersConfiguration()
configuration.sqlite = SQLiteDatabaseConfiguration(
Expand All @@ -152,7 +156,7 @@ def test_quota_limiters_cluster_quota_limiter_sqlite_storage():
assert isinstance(limiters[0], ClusterQuotaLimiter)


def test_quota_limiters_two_limiters(mocker: MockerFixture):
def test_quota_limiters_two_limiters(mocker: MockerFixture) -> None:
"""Test the quota limiters creating when two limiters are specified."""
configuration = QuotaHandlersConfiguration()
configuration.postgres = PostgreSQLDatabaseConfiguration(
Expand Down Expand Up @@ -182,7 +186,7 @@ def test_quota_limiters_two_limiters(mocker: MockerFixture):
assert isinstance(limiters[1], ClusterQuotaLimiter)


def test_quota_limiters_invalid_limiter_type(mocker: MockerFixture):
def test_quota_limiters_invalid_limiter_type(mocker: MockerFixture) -> None:
"""Test the quota limiters creating when invalid limiter type is specified."""
configuration = QuotaHandlersConfiguration()
configuration.postgres = PostgreSQLDatabaseConfiguration(
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/quota/test_user_quota_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_quota_limiter(
return quota_limiter


def test_connected():
def test_connected() -> None:
"""Test the connected method."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -44,7 +44,7 @@ def test_connected():
assert quota_limiter.connected()


def test_init_quota():
def test_init_quota() -> None:
"""Test the init quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -57,7 +57,7 @@ def test_init_quota():
assert str(quota_limiter) == "UserQuotaLimiter: initial quota: 1000 increase by: 1"


def test_available_quota():
def test_available_quota() -> None:
"""Test the available quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -71,7 +71,7 @@ def test_available_quota():
assert available_quota == initial_quota


def test_consume_tokens():
def test_consume_tokens() -> None:
"""Test the consume tokens operation."""
initial_quota = 1000
quota_limit = 100
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_consume_tokens():
assert available_quota == initial_quota - 4


def test_increase_quota():
def test_increase_quota() -> None:
"""Test the increase_quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -122,7 +122,7 @@ def test_increase_quota():
assert available_quota == initial_quota - 1


def test_ensure_available_quota():
def test_ensure_available_quota() -> None:
"""Test the ensure_available_quota operation."""
initial_quota = 1000
quota_limit = 100
Expand All @@ -135,7 +135,7 @@ def test_ensure_available_quota():
quota_limiter.ensure_available_quota("foo")


def test_ensure_available_quota_no_quota():
def test_ensure_available_quota_no_quota() -> None:
"""Test the ensure_available_quota operation."""
initial_quota = 0
quota_limit = 100
Expand All @@ -149,7 +149,7 @@ def test_ensure_available_quota_no_quota():
quota_limiter.ensure_available_quota("foo")


def test_revoke_quota():
def test_revoke_quota() -> None:
"""Test the revoke_quota operation."""
initial_quota = 1000
quota_limit = 100
Expand Down
Loading