mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 02:48:38 -04:00
Testing that api can start.
This commit is contained in:
parent
a65fa1c6fb
commit
8ad653fc40
4 changed files with 38 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
2
main.py
2
main.py
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue