Skip to content

Commit

Permalink
tests: add tests for records.api_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
enku committed Jun 3, 2024
1 parent 7a07f00 commit 1c21aeb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
build_records,
)
from gentoo_build_publisher.records.django_orm import RecordDB as DjangoDB
from gentoo_build_publisher.records.memory import ApiKeyDB as MemoryApiKeyDB
from gentoo_build_publisher.records.memory import RecordDB as MemoryDB
from gentoo_build_publisher.settings import Settings
from gentoo_build_publisher.types import ApiKey, Build
Expand Down Expand Up @@ -376,6 +377,28 @@ def test_delete_when_does_not_exist(self, backend: str) -> None:
records.delete("bogus")


class ApiKeysTests(TestCase):
def test_returns_requested_class(self) -> None:
settings = Settings(
RECORDS_BACKEND="memory",
STORAGE_PATH=Path("/dev/null"),
JENKINS_BASE_URL="http://jenkins.invalid/",
)
obj = api_keys(settings)

self.assertIsInstance(obj, MemoryApiKeyDB)

def test_raises_lookuperror(self) -> None:
settings = Settings(
RECORDS_BACKEND="bogus",
STORAGE_PATH=Path("/dev/null"),
JENKINS_BASE_URL="http://jenkins.invalid/",
)

with self.assertRaises(LookupError):
api_keys(settings)


class RepoTests(TestCase):
@parametrized(BACKENDS)
def test_from_settings(self, backend: str) -> None:
Expand Down

0 comments on commit 1c21aeb

Please sign in to comment.