mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
🌱 Let's start with the Gitlab CI
This commit is contained in:
parent
9885a5809a
commit
a9f823fbfa
4 changed files with 27 additions and 6 deletions
15
.gitlab-ci.yml
Normal file
15
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
image: python:3.11
|
||||
|
||||
stages:
|
||||
- test
|
||||
|
||||
before_script:
|
||||
- python -V
|
||||
- python -m venv venv
|
||||
- ./venv/bin/pip install -e ".[dev]"
|
||||
|
||||
|
||||
pytest:
|
||||
stage: test
|
||||
script:
|
||||
- ./venv/bin/pytest
|
|
@ -23,7 +23,9 @@ class DevSettings(Settings):
|
|||
|
||||
|
||||
class TestSettings(Settings):
|
||||
pass
|
||||
app_env: str = "test"
|
||||
yaml_file: str = "tests/config.yaml"
|
||||
database_url: str = "sqlite:////tmp/test-argos.db"
|
||||
|
||||
|
||||
class ProdSettings(Settings):
|
||||
|
|
|
@ -63,4 +63,5 @@ testpaths = [
|
|||
"tests",
|
||||
"argos"
|
||||
]
|
||||
fixture_path = "tests/fixtures.py"
|
||||
pythonpath = "."
|
|
@ -1,17 +1,16 @@
|
|||
from datetime import datetime
|
||||
from os import environ
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from argos.server import models
|
||||
|
||||
environ["ARGOS_APP_ENV"] = "test"
|
||||
os.environ["ARGOS_APP_ENV"] = "test"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def db() -> Session:
|
||||
from argos.server import models
|
||||
|
||||
app = _create_app()
|
||||
models.Base.metadata.create_all(bind=app.state.engine)
|
||||
yield app.state.SessionLocal()
|
||||
|
@ -20,6 +19,8 @@ def db() -> Session:
|
|||
|
||||
@pytest.fixture
|
||||
def app() -> FastAPI:
|
||||
from argos.server import models
|
||||
|
||||
app = _create_app()
|
||||
models.Base.metadata.create_all(bind=app.state.engine)
|
||||
yield app
|
||||
|
@ -33,6 +34,8 @@ def _create_app() -> FastAPI:
|
|||
)
|
||||
|
||||
app = get_application()
|
||||
# Hardcode the database url and the yaml file for testing purpose
|
||||
# Otherwise, the app will try to read the .env file or the environment variables
|
||||
app.state.settings.database_url = "sqlite:////tmp/test-argos.db"
|
||||
app.state.settings.yaml_file = "tests/config.yaml"
|
||||
|
||||
|
|
Loading…
Reference in a new issue