2024-03-27 11:18:57 +01:00
|
|
|
import pytest
|
2024-03-27 14:17:05 +01:00
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
|
|
|
from app import create_app
|
2024-03-27 11:18:57 +01:00
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def app():
|
|
|
|
app = create_app()
|
2024-03-27 14:17:05 +01: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 11:18:57 +01:00
|
|
|
app.config.update({
|
|
|
|
"TESTING": True,
|
2024-03-27 14:17:05 +01:00
|
|
|
"ATHLETE_FILE": Path(__file__).parent / 'tests' / 'athletes.json'
|
2024-03-27 11:18:57 +01:00
|
|
|
})
|
|
|
|
yield app
|
|
|
|
|
2024-03-27 14:17:05 +01:00
|
|
|
# Remove the file after the test
|
|
|
|
(Path(__file__).parent / 'tests' / 'athletes.json').unlink()
|
2024-03-27 11:18:57 +01:00
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def client(app):
|
|
|
|
return app.test_client()
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def runner(app):
|
|
|
|
return app.test_cli_runner()
|