Update CI workflow, app initialization, quotes route, and test files

This commit is contained in:
Dries Peeters
2025-11-29 07:39:29 +01:00
parent 0094428b72
commit 149a4bb4c8
6 changed files with 25 additions and 15 deletions

View File

@@ -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

View File

@@ -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 = {

View File

@@ -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,

View File

@@ -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

View File

@@ -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)

View File

@@ -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