Testing that api can start.

This commit is contained in:
Roland 2024-05-07 10:09:56 -06:00
parent a65fa1c6fb
commit 8ad653fc40
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
4 changed files with 38 additions and 7 deletions

View file

@ -83,7 +83,7 @@ jobs:
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}
key: deps-3.11-{{ checksum "requirements.txt" }}-2
paths:
- "venv"
- run:
@ -110,13 +110,44 @@ jobs:
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.12-{{ checksum "requirements.txt" }}
key: deps-3.12-{{ checksum "requirements.txt" }}-2
paths:
- "venv"
- run:
command: './venv/bin/pytest -svv'
sanic-api-start:
docker:
- image: cimg/python:3.11
steps:
- checkout
- restore_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-2
- run:
name: Install dependencies
command: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
sudo mkdir -p /media/wrolpi
- run:
name: Start Sanic API
command: |
. venv/bin/activate
sanic main:api_app -H 0.0.0.0 -p 8081
background: true
- run:
name: Test Sanic API
command: |
sleep 20
curl http://0.0.0.0:8081/api/echo
- run:
name: Stop Sanic API
command: pkill -f sanic
workflows:
wrolpi-sanic-tests:
jobs:
- sanic-api-start
wrolpi-api-tests:
jobs:
- api-tests-3-11

View file

@ -17,7 +17,7 @@ from wrolpi.contexts import attach_shared_contexts, reset_shared_contexts, initi
from wrolpi.dates import Seconds
from wrolpi.downloader import import_downloads_config, download_manager, \
perpetual_download_worker
from wrolpi.vars import PROJECT_DIR, DOCKERIZED
from wrolpi.vars import PROJECT_DIR, DOCKERIZED, CIRCLECI
from wrolpi.version import get_version_string
logger = logger.getChild('wrolpi-main')

View file

@ -1,4 +1,3 @@
import os
import pathlib
import tempfile
from contextlib import contextmanager
@ -12,12 +11,11 @@ import pytest
from wrolpi.common import get_media_directory
from wrolpi.conftest import test_db, test_client # noqa
from wrolpi.db import postgres_engine
from wrolpi.vars import CIRCLECI
TEST_CONFIG_PATH = tempfile.NamedTemporaryFile(mode='rt', delete=False)
skip_circleci = pytest.mark.skipif(
os.environ.get('CIRCLECI', '').strip().lower() == 'true',
reason='This test is not supported in Circle CI')
skip_circleci = pytest.mark.skipif(CIRCLECI, reason='This test is not supported in Circle CI')
def wrap_test_db(func):

View file

@ -16,6 +16,8 @@ load_dotenv(PROJECT_DIR / '.env')
DOCKERIZED = True if os.environ.get('DOCKER', '').lower().startswith('t') else False
# tests are running
PYTEST = 'pytest' in sys.modules
# running on circlci
CIRCLECI = os.environ.get('CIRCLECI', '').strip().lower() == 'true'
def truthy_arg(value: str) -> bool: