2 Commits
Author SHA1 Message Date
Brian Bjarke Jensen c3a08372a0 changed to using secret for repeated variable
Python Code Quality / python-code-quality (push) Successful in 10s
Python Test / python-test (push) Successful in 14s
Build and Push Docker Image / build-and-push (push) Successful in 25s
2025-11-06 22:15:14 +01:00
Brian Bjarke Jensen d953564986 formatting fixes
Build and Push Docker Image / build-and-push (push) Failing after 15s
Python Code Quality / python-code-quality (push) Successful in 9s
Python Test / python-test (push) Successful in 14s
2025-11-06 22:08:07 +01:00
2 changed files with 11 additions and 10 deletions
+4 -4
View File
@@ -21,7 +21,7 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
config-inline: | config-inline: |
[registry."10.0.0.2:3000"] [registry."${{ secrets.DOCKER_REGISTRY }}"]
http = true http = true
insecure = true insecure = true
@@ -31,18 +31,18 @@ jobs:
mkdir -p ~/.docker mkdir -p ~/.docker
echo '{ echo '{
"auths": {}, "auths": {},
"insecure-registries": ["10.0.0.2:3000"] "insecure-registries": ["${{ secrets.DOCKER_REGISTRY }}"]
}' > ~/.docker/config.json }' > ~/.docker/config.json
# Login using direct docker command # Login using direct docker command
echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login ${{ secrets.DOCKER_REGISTRY }} --username "${{ gitea.actor }}" --password-stdin
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: | images: |
${{ secrets.DOCKER_USERNAME }}/baby-monitor ${{ secrets.DOCKER_REGISTRY }}/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}
tags: | tags: |
type=ref,event=branch type=ref,event=branch
type=ref,event=pr type=ref,event=pr
+7 -6
View File
@@ -26,7 +26,7 @@ def test_get_db_yields_session() -> None:
def test_get_db_closes_session() -> None: def test_get_db_closes_session() -> None:
"""Test that get_db properly closes the session.""" """Test that get_db properly closes the session."""
from unittest.mock import patch from unittest.mock import patch
init_db() init_db()
db_generator = get_database() db_generator = get_database()
@@ -35,13 +35,13 @@ def test_get_db_closes_session() -> None:
assert db.is_active assert db.is_active
# Patch the close method to verify it gets called # Patch the close method to verify it gets called
with patch.object(db, 'close', wraps=db.close) as mock_close: with patch.object(db, "close", wraps=db.close) as mock_close:
# Complete the generator to trigger finally block # Complete the generator to trigger finally block
try: try:
next(db_generator) next(db_generator)
except StopIteration: except StopIteration:
pass pass
# Verify that close() was called # Verify that close() was called
mock_close.assert_called_once() mock_close.assert_called_once()
@@ -49,7 +49,7 @@ def test_get_db_closes_session() -> None:
def test_get_db_closes_on_exception() -> None: def test_get_db_closes_on_exception() -> None:
"""Test that get_db closes session when used in context manager.""" """Test that get_db closes session when used in context manager."""
from unittest.mock import patch from unittest.mock import patch
init_db() init_db()
# Simulate how FastAPI actually uses the dependency # Simulate how FastAPI actually uses the dependency
@@ -60,7 +60,7 @@ def test_get_db_closes_on_exception() -> None:
assert db.is_active assert db.is_active
# Patch close to verify it gets called even with an exception # Patch close to verify it gets called even with an exception
with patch.object(db, 'close', wraps=db.close) as mock_close: with patch.object(db, "close", wraps=db.close) as mock_close:
try: try:
# Simulate an exception occurring during request processing # Simulate an exception occurring during request processing
raise ValueError("Simulated error during request") raise ValueError("Simulated error during request")
@@ -72,7 +72,7 @@ def test_get_db_closes_on_exception() -> None:
next(db_generator) next(db_generator)
except StopIteration: except StopIteration:
pass pass
# Verify close() was called despite the exception # Verify close() was called despite the exception
mock_close.assert_called_once() mock_close.assert_called_once()
except Exception: except Exception:
@@ -82,6 +82,7 @@ def test_get_db_closes_on_exception() -> None:
# Verify db was created # Verify db was created
assert db is not None assert db is not None
# def test_init_db_creates_directory(tmp_path: Path) -> None: # def test_init_db_creates_directory(tmp_path: Path) -> None:
# """Test that init_db creates the data directory.""" # """Test that init_db creates the data directory."""
# import os # import os