Skip to content
This repository was archived by the owner on Oct 31, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[run]
omit =
*tests/*
*conftest.py
*tests*
*.html
8 changes: 2 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ charset = utf-8
[*.py]
max_line_length = 119

# Use 2 spaces for the HTML files
[*{.css,.js,.html,.tpl}]
indent_size = 2

# The JSON files contain newlines inconsistently
[*.json]
# Use 2 spaces for most of the assets
[*{.css,.js,.json,.html,.tpl,.yaml}]
indent_size = 2

# Makefiles always use tabs for indentation
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ help:
@echo "migrate-down .............................. Run the database migration (downgrade)"
@echo "migrate-up................................. Run the database migration (upgrade)"
@echo "test ...................................... Run frontend and backend tests"
@echo "test-it ................................... Run integration tests"
@echo "test-javascript ........................... Run the frontend tests"
@echo "test-python ............................... Run the backend tests"
@echo
Expand Down Expand Up @@ -95,3 +96,5 @@ test-javascript:
test-python:
pipenv run test

test-it:
pipenv run test_integration
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pytest-flask = "*"
pytest-cov = "==2.7.1"
python-coveralls = "==2.9.2"
pytest-mock = "*"
requests = "*"

[packages]
gunicorn = "*"
Expand All @@ -42,3 +43,4 @@ run = "flask run --host=0.0.0.0 --port=8080"
security = "bandit -r ."
test = "pytest ."
test_coverage = "pytest --cov=tomaco --cov-report term-missing tomaco"
test_integration = "pytest . -m 'integration'"
118 changes: 59 additions & 59 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ Or using docker:
$ make test-docker
```

### Integration tests

In order to execute the IT tests, first you need to start the Docker containers:

```
$ docker-compose up
```

After that, you are now able to run the integration tests:

```
$ make test-it
```

### Linting

Linting is a good way of keeping the code quality high. You can have everything you want (Python, Javascript and security checks) in a single task:

```
Expand Down
5 changes: 5 additions & 0 deletions bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

./bin/wait-for-it.sh -t 60 postgres:5432
flask db upgrade --directory tomaco/migrations
npm run run & flask run --host=0.0.0.0 --port=8080
4 changes: 1 addition & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ services:
- "./data/postgres:/var/lib/postgresql/data"
ports:
- 5432:5432

tomaco:
build: .
container_name: tomaco
command: >
sh -c "npm run run & flask run --host=0.0.0.0 --port=8080"
volumes:
- ./:/app
ports:
Expand All @@ -28,6 +25,7 @@ services:
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
DATABASE_URL: "postgresql://root@postgres/tomaco_dev"
entrypoint: bin/docker-entrypoint.sh
stdin_open: true
tty: true
depends_on:
Expand Down
4 changes: 3 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[pytest]
addopts = -s
addopts = -s -m 'not integration'
filterwarnings =
ignore::DeprecationWarning
markers =
integration: marks tests as integration tests
Empty file.
18 changes: 18 additions & 0 deletions tomaco/auth/tests/integration/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest

from ...models import User


@pytest.mark.integration
class TestLogin:
def teardown_method(self, method):
User.query.delete()
User.query.session.commit()

def test_should_access_login_page_when_not_logged_in(self, it_client):
result = it_client.get("http://0.0.0.0:8080/login")
assert result.status_code == 200

def test_should_create_user_after_login(self, it_client):
it_client.get("http://0.0.0.0:8080/login/start")
assert User.query.filter_by(username="gandalf").count() == 1
Loading