Skip to content

Commit

Permalink
Merge pull request #29 from BritishGeologicalSurvey/docker-problems2
Browse files Browse the repository at this point in the history
Docker problems2 - fixes issues running in docker
  • Loading branch information
KoalaGeo authored Aug 23, 2021
2 parents 6e77bc1 + 12f231f commit 8f50afb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
20 changes: 11 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
fastapi>=0.66
aiofiles
uvicorn
numpy
python-ags4
python-multipart
colorlog
shortuuid
jinja2
aiofiles==0.7.0
numpy==1.21.2
python-ags4==0.3.6
python-multipart==0.0.5
colorlog==5.0.1
shortuuid==1.0.1
Jinja2==3.0.1
# These libraries are already in FastAPI container but need updated
fastapi==0.68.0
uvicorn==0.15.0
h11==0.12.0
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ipython
ipdb
pytest
flake8
requests
45 changes: 45 additions & 0 deletions test/integration/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Tests for API responses."""
from pathlib import Path
import re

from fastapi.testclient import TestClient
import pytest

from app.main import app

TEST_FILE_DIR = Path(__file__).parent.parent / 'files'


def test_openapi_json(client):
"""A hello-world type test to confirm testing framework works."""
response = client.get('/openapi.json')
assert response.status_code == 200
assert '/validate' in response.text


@pytest.mark.parametrize('filename, expected', [
('example1.ags', 'All checks passed!'),
('nonsense.ags', r'7 error\(s\) found in file!'),
('empty.ags', r'4 error\(s\) found in file!'),
('real/A3040_03.ags', r'5733 error\(s\) found in file!'),
('example1.xlsx', 'ERROR: Only .ags files are accepted as input.'),
('random_binary.ags', 'ERROR: Unreadable character "á" at position 1 on line: 1\nStarting:'),
('real/CG014058_F.ags', r'ERROR: Unreadable character "æ" at position 80 on line: 263'),
('real/Blackburn Southern Bypass.ags', r'93 error\(s\) found in file!'), # this file contains BOM character
])
def test_validate(client, filename, expected):
# Arrange
filename = TEST_FILE_DIR / filename

# Act
response = client.post('/validate/?fmt=text',
files={'file': (filename.name, str(filename))})

# Assert
assert response.status_code == 200
assert re.search(expected, response.text)


@pytest.fixture(scope="function")
def client():
return TestClient(app)

0 comments on commit 8f50afb

Please sign in to comment.