From 149a4bb4c820b4a8f14e7fdec66b0e9c059f6dc0 Mon Sep 17 00:00:00 2001 From: Dries Peeters Date: Sat, 29 Nov 2025 07:39:29 +0100 Subject: [PATCH] Update CI workflow, app initialization, quotes route, and test files --- .github/workflows/ci.yml | 21 ++++++++++++++------- app/__init__.py | 2 +- app/routes/quotes.py | 4 ++-- tests/test_admin_settings_logo.py | 5 +++-- tests/test_time_entry_duplication.py | 3 ++- tests/test_uploads_persistence.py | 5 +++-- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf5505a..9740409 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,12 @@ name: CI/CD Pipeline +# DISABLED: This workflow is disabled in favor of the Comprehensive CI Pipeline (ci-comprehensive.yml) +# Only the Comprehensive CI Pipeline should run for all CI/CD operations on: - pull_request: - branches: [ main ] - types: [ opened, synchronize, reopened, ready_for_review ] + workflow_dispatch: # Only allows manual trigger, effectively disabling automatic runs + # pull_request: + # branches: [ main ] + # types: [ opened, synchronize, reopened, ready_for_review ] env: PYTHON_VERSION: '3.11' @@ -13,7 +16,8 @@ jobs: lint: name: Lint and Code Quality runs-on: ubuntu-latest - if: github.event.pull_request.head.ref == 'rc' || startsWith(github.event.pull_request.head.ref, 'rc/') + if: false # DISABLED: This workflow is disabled in favor of ci-comprehensive.yml + # if: github.event.pull_request.head.ref == 'rc' || startsWith(github.event.pull_request.head.ref, 'rc/') steps: - uses: actions/checkout@v4 @@ -49,7 +53,8 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - if: github.event.pull_request.head.ref == 'rc' || startsWith(github.event.pull_request.head.ref, 'rc/') + if: false # DISABLED: This workflow is disabled in favor of ci-comprehensive.yml + # if: github.event.pull_request.head.ref == 'rc' || startsWith(github.event.pull_request.head.ref, 'rc/') services: postgres: @@ -105,7 +110,8 @@ jobs: security: name: Security Scan runs-on: ubuntu-latest - if: github.event.pull_request.head.ref == 'rc' || startsWith(github.event.pull_request.head.ref, 'rc/') + if: false # DISABLED: This workflow is disabled in favor of ci-comprehensive.yml + # if: github.event.pull_request.head.ref == 'rc' || startsWith(github.event.pull_request.head.ref, 'rc/') steps: - uses: actions/checkout@v4 @@ -135,7 +141,8 @@ jobs: name: Docker Build runs-on: ubuntu-latest needs: [lint, test] - if: github.event_name == 'push' + if: false # DISABLED: This workflow is disabled in favor of ci-comprehensive.yml + # if: github.event_name == 'push' steps: - uses: actions/checkout@v4 diff --git a/app/__init__.py b/app/__init__.py index cad181a..fa0410b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -639,7 +639,7 @@ def create_app(config=None): flask_env_env = os.getenv("FLASK_ENV", "production") flask_env = flask_env_config if flask_env_config else flask_env_env is_production_env = flask_env == "production" and not is_testing - + if not app.debug and is_production_env: secret = app.config.get("SECRET_KEY") placeholder_values = { diff --git a/app/routes/quotes.py b/app/routes/quotes.py index 2031f9d..82373f8 100644 --- a/app/routes/quotes.py +++ b/app/routes/quotes.py @@ -7,7 +7,7 @@ from datetime import datetime from decimal import Decimal, InvalidOperation from app.utils.db import safe_commit from app.utils.permissions import admin_or_permission_required, permission_required -from app.utils.config_manager import get_setting +from app.utils.config_manager import ConfigManager quotes_bp = Blueprint("quotes", __name__) @@ -486,7 +486,7 @@ def send_quote(quote_id): for item in quote.items: if item.is_stock_item and item.stock_item_id and item.warehouse_id: try: - expires_in_days = get_setting("INVENTORY_QUOTE_RESERVATION_EXPIRY_DAYS", 30) + expires_in_days = ConfigManager.get_setting("INVENTORY_QUOTE_RESERVATION_EXPIRY_DAYS", 30) StockReservation.create_reservation( stock_item_id=item.stock_item_id, warehouse_id=item.warehouse_id, diff --git a/tests/test_admin_settings_logo.py b/tests/test_admin_settings_logo.py index b5dcbb7..7ca5d58 100644 --- a/tests/test_admin_settings_logo.py +++ b/tests/test_admin_settings_logo.py @@ -14,6 +14,7 @@ def admin_user(app): """Create an admin user for testing.""" user = User(username="admintest", role="admin") user.is_active = True + user.set_password("testpass123") # Set password for login endpoint db.session.add(user) db.session.commit() db.session.refresh(user) @@ -24,9 +25,9 @@ def admin_user(app): def authenticated_admin_client(client, admin_user): """Create an authenticated admin client.""" from flask_login import login_user - + + # Use login_user directly like admin_authenticated_client in conftest with client.session_transaction() as sess: - # Use Flask-Login's login_user directly for tests login_user(admin_user) return client diff --git a/tests/test_time_entry_duplication.py b/tests/test_time_entry_duplication.py index 2c41480..24bf7a9 100644 --- a/tests/test_time_entry_duplication.py +++ b/tests/test_time_entry_duplication.py @@ -275,9 +275,10 @@ def test_duplicate_button_on_dashboard(authenticated_client, time_entry_with_all with app.app_context(): # Clear any cache that might affect the dashboard from app.utils.cache import get_cache + cache = get_cache() cache.delete(f"dashboard:{time_entry_with_all_fields.user_id}") - + response = authenticated_client.get("/dashboard") assert response.status_code == 200 html = response.get_data(as_text=True) diff --git a/tests/test_uploads_persistence.py b/tests/test_uploads_persistence.py index cab1d8e..4d2aaa0 100644 --- a/tests/test_uploads_persistence.py +++ b/tests/test_uploads_persistence.py @@ -25,6 +25,7 @@ from PIL import Image def admin_user(app): """Create an admin user for testing.""" user = User(username="admintest", role="admin") + user.set_password("testpass123") # Set password for login endpoint db.session.add(user) db.session.commit() db.session.refresh(user) @@ -35,9 +36,9 @@ def admin_user(app): def authenticated_admin_client(client, admin_user): """Create an authenticated admin client.""" from flask_login import login_user - + + # Use login_user directly like admin_authenticated_client in conftest with client.session_transaction() as sess: - # Use Flask-Login's login_user directly for tests login_user(admin_user) return client