import pytest
import shutil
from pathlib import Path
from app import create_app

@pytest.fixture()
def app():
    app = create_app()
    # Copy the sample to the test folder using python
    shutil.copy(Path(__file__).parent.parent / 'sample' / 'disciplines.json', Path(__file__).parent / 'tests' / 'disciplines.json')
    app.config.update({
        "TESTING": True,
        "DISCIPLINE_FILE":  Path(__file__).parent / 'tests' / 'disciplines.json'
    })
    yield app

    # Remove the file after the test
    (Path(__file__).parent / 'tests' / 'disciplines.json').unlink()

@pytest.fixture()
def client(app):
    return app.test_client()

@pytest.fixture()
def runner(app):
    return app.test_cli_runner()