import pytest

from app import create_app
from flask import Flask
from app.config.extensions import db
from app.config.settings import TestingConfig
from mongoengine import connect,disconnect
from decouple import config
from .factory import BrandFactory,ChannelFactory

@pytest.fixture
def client():
    disconnect()
    app = Flask(__name__)
    app.config.from_object(TestingConfig)  # Use the testing configuration

    # # Establish a connection to the testing database
    connection = connect('pige_testing', host='mongo-database', port=27017)
    # db.pige_testing.create_index([('language_code', 'text')], default_language='sk')
    with app.test_client() as client:
        yield client  # The tests will run using this client fixture
    connection.drop_database("pige_testing")

@pytest.fixture
def channel_model_factory():
    return ChannelFactory.create()

@pytest.fixture()
def brand_factory():
    yield BrandFactory.create()