Skip to content

Commit

Permalink
Fix: docu not reachable in api template docker (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
odulcy-mindee authored Jul 29, 2022
1 parent ada1bf2 commit 7d25563
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ jobs:

pytest-api:
runs-on: ubuntu-latest
env:
# Port for web container
# See docker-compose.yml
PORT: 8002
steps:
- uses: actions/checkout@v2
- name: Build & run docker
run: PORT=8002 docker-compose up -d --build
run: docker-compose up -d --build
- name: Ping server
run: curl http://localhost:8002/docs
run: wget --spider --tries=12 http://localhost:$PORT/docs
- name: Install dependencies in docker
run: |
PORT=8002 docker-compose exec -T web python -m pip install --upgrade pip
PORT=8002 docker-compose exec -T web pip install -r requirements-dev.txt
docker-compose exec -T web python -m pip install --upgrade pip
docker-compose exec -T web pip install -r requirements-dev.txt
- name: Run docker test
run: PORT=8002 docker-compose exec -T web pytest .
run: docker-compose exec -T web pytest .
4 changes: 3 additions & 1 deletion api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
fastapi>=0.65.2
# Fastapi: minimum version required to avoid pydantic error
# cf. https://github.com/tiangolo/fastapi/issues/4168
fastapi>=0.73.0
uvicorn>=0.11.1
python-multipart==0.0.5
python-doctr>=0.2.0
8 changes: 4 additions & 4 deletions api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
# This program is licensed under the Apache License version 2.
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details.

import pytest
import pytest_asyncio
import requests
from httpx import AsyncClient

from app.main import app


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def mock_recognition_image(tmpdir_factory):
url = 'https://user-images.githubusercontent.com/76527547/117133599-c073fa00-ada4-11eb-831b-412de4d28341.jpeg'
return requests.get(url).content


@pytest.fixture(scope="session")
@pytest_asyncio.fixture(scope="session")
def mock_detection_image(tmpdir_factory):
url = 'https://user-images.githubusercontent.com/76527547/117319856-fc35bf00-ae8b-11eb-9b51-ca5aba673466.jpg'
return requests.get(url).content


@pytest.fixture(scope="function")
@pytest_asyncio.fixture(scope="function")
async def test_app_asyncio():
# for httpx>=20, follow_redirects=True (cf. https://github.com/encode/httpx/releases/tag/0.20.0)
async with AsyncClient(app=app, base_url="http://test") as ac:
Expand Down

0 comments on commit 7d25563

Please sign in to comment.