TP_JO2024/athlete/conftest.py

27 lines
720 B
Python
Raw Normal View History

2024-03-27 10:18:57 +00:00
import pytest
2024-03-27 13:17:05 +00:00
import shutil
from pathlib import Path
from app import create_app
2024-03-27 14:20:10 +00:00
from flask import request
2024-03-27 10:18:57 +00:00
@pytest.fixture()
def app():
app = create_app()
2024-03-27 13:17:05 +00:00
# Copy the sample to the test folder using python
shutil.copy(Path(__file__).parent.parent / 'sample' / 'athletes.json', Path(__file__).parent / 'tests' / 'athletes.json')
2024-03-27 10:18:57 +00:00
app.config.update({
"TESTING": True,
2024-03-27 13:17:05 +00:00
"ATHLETE_FILE": Path(__file__).parent / 'tests' / 'athletes.json'
2024-03-27 10:18:57 +00:00
})
yield app
2024-03-27 13:17:05 +00:00
# Remove the file after the test
(Path(__file__).parent / 'tests' / 'athletes.json').unlink()
2024-03-27 10:18:57 +00:00
@pytest.fixture()
def client(app):
return app.test_client()
@pytest.fixture()
def runner(app):
return app.test_cli_runner()