fixed testing script
Some checks failed
Build and Deploy Demo App / test (push) Failing after 11s
Build and Deploy Demo App / build (push) Has been skipped
Build and Deploy Demo App / scan (push) Has been skipped
Build and Deploy Demo App / deploy (push) Has been skipped

This commit is contained in:
2025-11-26 11:23:48 +03:30
parent b3a9f19501
commit 44926969ce

27
test_app.py Normal file
View File

@@ -0,0 +1,27 @@
import pytest
import os
from app import app
from models import db, Feature
@pytest.fixture
def client():
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app) # Re-init DB with test config
with app.test_client() as client:
with app.app_context():
db.create_all()
yield client
db.drop_all()
def test_index(client):
response = client.get('/')
assert response.status_code == 200
assert b'Professional Demo Site' in response.data
def test_seed_db(client): # Add fixture here
with app.app_context():
Feature.seed_db()
assert Feature.query.count() == 3