﻿"""Test configuration and fixtures for RateRight tests"""
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/..'))

import pytest
from app import create_app
from app.extensions import db

@pytest.fixture
def app():
    """Create application for testing"""
    app = create_app()
    app.config['TESTING'] = True
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
    app.config['WTF_CSRF_ENABLED'] = False
    return app

@pytest.fixture
def client(app):
    """Test client for the app"""
    return app.test_client()

@pytest.fixture
def runner(app):
    """Test runner for CLI commands"""
    return app.test_cli_runner()

@pytest.fixture
def init_database(app):
    """Initialize the database"""
    with app.app_context():
        db.create_all()
        yield db
        db.drop_all()
