Skip to content

Commit

Permalink
Use example apps for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Oct 27, 2015
1 parent 60809a4 commit 1520216
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 69 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def loop():
return loop_

@pytest.fixture()
def create_client(app):
def maker(*args, **kwargs):
def create_client():
def maker(app, *args, **kwargs):
# Set to False because we set app['aiohttp_utils'], which
# is invalid in wsgi environs
kwargs.setdefault('lint', False)
Expand Down
36 changes: 36 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""We use the apps in examples/ for integration tests."""
import pytest

from examples.kitchen_sink import app as kitchen_sink_app

class TestKitchenSinkApp:

@pytest.fixture()
def client(self, loop, create_client):
kitchen_sink_app._loop = loop
return create_client(kitchen_sink_app)

def test_index(self, client):
res = client.get('/')
assert res.status_code == 200
assert res.json == 'Welcome!'

def test_api_index(self, client):
res = client.get('/api/')
assert res.status_code == 200
assert res.json == {'message': 'Welcome to the API!'}

def test_api_index_append_slash(self, client):
res = client.get('/api')
assert res.status_code == 301
res = res.follow()
assert res.status_code == 200
assert res.request.path == '/api/'

def test_api_index_merge_slashes(self, client):
res = client.get('/api//')
assert res.status_code == 301
res = res.follow()
assert res.status_code == 200
assert res.request.path == '/api/'

67 changes: 0 additions & 67 deletions tests/test_integration.py

This file was deleted.

0 comments on commit 1520216

Please sign in to comment.