fixed testing script
This commit is contained in:
24
tests.py
Normal file
24
tests.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import pytest
|
||||
from app import app, db
|
||||
from models import Feature
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
app.config['TESTING'] = True
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' # In-memory DB for tests
|
||||
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):
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
Feature.seed_db()
|
||||
assert Feature.query.count() == 3
|
||||
Reference in New Issue
Block a user