Skip to content

Commit

Permalink
Add suport for testing (#136)
Browse files Browse the repository at this point in the history
Add support (python lib, docker-compose config) to enable server testing

Related: #110
  • Loading branch information
eveninglily authored Oct 4, 2019
1 parent 41218bd commit a92a5cb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ api/env/
api/analytics.log
nginx/certbot/
!nginx/certbot/.gitkeep
api/.mypy_cache/
api/.mypy_cache/
.pytest_cache
pyvenv.cfg
8 changes: 6 additions & 2 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ If you want to deploy to AWS you can follow these steps.
1. Start a new EC2 instance. When choosing an image we recommend Ubuntu Server 18.04.
2. Choose what size instance you want.
3. Most of the other defaults will be ok to keep, however you will want to configure your security group to have port 80 and 443 open. SSH port should already be configured.

| Type | Protocol | Port Range | Source |
| --- | --- | --- | --- |
| HTTPS | TCP | 443 | Anywhere |
Expand All @@ -105,4 +105,8 @@ If you want to deploy to AWS you can follow these steps.
---

# Testing
[Coming soon]
We use Pytest. From the root directory (one up from here), you can run

`sudo docker-compose -f docker-compose-test.yml up --abort-on-container-exit`

To run all the tests in a docker image.
1 change: 1 addition & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ urllib3==1.23
Werkzeug==0.14.1
mypy==0.720
mypy-extensions==0.4.1
pytest==5.2.0
5 changes: 5 additions & 0 deletions api/server_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import pytest
from server import app

def test_empty():
return True
24 changes: 24 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'

services:
db:
image: mongo
command: [--auth]
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: expo-testing
ports:
- "27017:27017"
test:
build:
context: ./api
volumes:
- .:/var/www/webapps/hackathon-expo-app/api
depends_on:
- db
ports:
- "8000:8000"
links:
- db:db
command: pytest

0 comments on commit a92a5cb

Please sign in to comment.