Skip to content

Commit

Permalink
some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Apr 14, 2017
1 parent 29cc2ba commit 00cfa57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion connexion/apis/falcon_api.py
Expand Up @@ -45,7 +45,7 @@ def add_swagger_json(self):
Adds swagger json to {base_path}/swagger.json
"""
logger.debug('Adding swagger.json: %s/swagger.json', self.base_path)
self.routes['/swagger.json'] = SwaggerJsonResource(self.specification)
self.routes[self.base_path + '/swagger.json'] = SwaggerJsonResource(self.specification)

def add_swagger_ui(self):
"""
Expand Down
20 changes: 20 additions & 0 deletions tests/test_falcon.py
Expand Up @@ -11,6 +11,12 @@ def client(simple_api_spec_dir):
return testing.TestClient(app.app)


def test_swagger_json(client):
result = client.simulate_get('/v1.0/swagger.json')
assert result.status_code == 200
assert result.json['basePath'] == '/v1.0'


def test_simple(client):
result = client.simulate_get('/')
assert result.status_code == 404
Expand All @@ -31,3 +37,17 @@ def test_multiple_methods(client):
result = client.simulate_get('/v1.0/nullable-parameters', params={'time_start': 123})
assert result.status_code == 200
assert result.json == 123


def test_status_code(client):
result = client.simulate_post('/v1.0/goodday/noheader')
assert result.status_code == 201
assert result.json == {'greeting': 'Hello.'}


def test_status_code_headers(client):
result = client.simulate_post('/v1.0/goodevening/John')
assert result.status_code == 201
assert result.text == 'Good evening John'
assert result.headers['Location'] == '/my/uri'

0 comments on commit 00cfa57

Please sign in to comment.