-
-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from zalando/6-tests
Add unit tests and CI
- Loading branch information
Showing
13 changed files
with
292 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: python | ||
python: | ||
- "3.4" | ||
install: | ||
- pip install -e . | ||
- pip install coveralls | ||
- pip install flake8 | ||
script: | ||
- python setup.py test | ||
- python setup.py flake8 | ||
after_success: | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
swagger: "2.0" | ||
|
||
info: | ||
title: {{title}} | ||
title: "{{title}}" | ||
version: "1.0" | ||
|
||
basePath: /v1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__author__ = 'jmcs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
swagger: "2.0" | ||
|
||
info: | ||
title: "{{title}}" | ||
version: "1.0" | ||
|
||
basePath: /v1.0 | ||
|
||
securityDefinitions: | ||
oauth: | ||
type: oauth2 | ||
flow: password | ||
tokenUrl: https://ouath.example/token | ||
x-tokenInfoUrl: https://ouath.example/token_info | ||
scopes: | ||
myscope: can do stuff | ||
|
||
paths: | ||
/greeting/{name}: | ||
post: | ||
summary: Generate greeting | ||
description: Generates a greeting message. | ||
operationId: fakeapi.hello.post_greeting | ||
produces: | ||
- application/json | ||
responses: | ||
200: | ||
description: greeting response | ||
schema: | ||
type: string | ||
parameters: | ||
- name: name | ||
in: path | ||
description: Name of the person to greet. | ||
required: true | ||
type: string | ||
/bye/{name}: | ||
get: | ||
summary: Generate goodbye | ||
description: Generates a goobye message. | ||
operationId: fakeapi.hello.get_bye | ||
produces: | ||
- text/plain | ||
responses: | ||
200: | ||
description: goodbye response | ||
schema: | ||
type: string | ||
parameters: | ||
- name: name | ||
in: path | ||
description: Name of the person to say bye. | ||
required: true | ||
type: string | ||
/byesecure/{name}: | ||
get: | ||
summary: Generate goodbye | ||
description: Generates a goobye message. | ||
operationId: fakeapi.hello.get_bye_secure | ||
security: | ||
- oauth: | ||
- myscope | ||
produces: | ||
- text/plain | ||
responses: | ||
200: | ||
description: goodbye response | ||
schema: | ||
type: string | ||
parameters: | ||
- name: name | ||
in: path | ||
description: Name of the person to say bye. | ||
required: true | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
def post_greeting(name: str) -> dict: | ||
data = {'greeting': 'Hello {name}'.format(name=name)} | ||
return data | ||
|
||
def get_bye(name: str) -> dict: | ||
return 'Goodbye {name}'.format(name=name) | ||
|
||
def get_bye_secure(name: str) -> dict: | ||
return 'Goodbye {name} (Secure)'.format(name=name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import pathlib | ||
|
||
from connexion.api import Api | ||
|
||
TEST_FOLDER = pathlib.Path(__file__).parent | ||
|
||
|
||
def test_api(): | ||
api = Api(TEST_FOLDER / "fakeapi/api.yaml", "/api/v1.0", {}) | ||
assert api.blueprint.name == '/api/v1_0' | ||
assert api.blueprint.url_prefix == '/api/v1.0' | ||
# TODO test base_url in spec | ||
|
||
api2 = Api(TEST_FOLDER / "fakeapi/api.yaml") | ||
assert api2.blueprint.name == '/v1_0' | ||
assert api2.blueprint.url_prefix == '/v1.0' | ||
|
||
|
||
def test_template(): | ||
api1 = Api(TEST_FOLDER / "fakeapi/api.yaml", "/api/v1.0", {'title': 'test'}) | ||
assert api1.specification['info']['title'] == 'test' | ||
|
||
api2 = Api(TEST_FOLDER / "fakeapi/api.yaml", "/api/v1.0", {'title': 'other test'}) | ||
assert api2.specification['info']['title'] == 'other test' |
Oops, something went wrong.