Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API end-point '/<env>/publish' created via FastAPI - request model #13

Merged
merged 1 commit into from
Sep 10, 2020
Merged
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 .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ disable=print-statement,
protected-access,
# we use black code style and don't need additional checks
bad-continuation,
line-too-long,
line-too-long,

10 changes: 10 additions & 0 deletions exodus_gw/gateway.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from .app import app
from .publish import create_publish_id


@app.get("/healthcheck")
def healthcheck():
"""Returns a successful response if the service is running."""
return {"detail": "exodus-gw is running"}


@app.post("/{env}/publish")
def publish(env: str):
"""WIP: Returns a new, empty publish id"""
lmilbaum marked this conversation as resolved.
Show resolved Hide resolved
if env not in ["dev", "qa", "stage", "prod"]:
lmilbaum marked this conversation as resolved.
Show resolved Hide resolved
return {"error": "environment {0} not found".format(env)}
lmilbaum marked this conversation as resolved.
Show resolved Hide resolved
create_publish_id()
return {"detail": "Created Publish Id"}
7 changes: 7 additions & 0 deletions exodus_gw/publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import uuid


def create_publish_id():
"""Create a new publish id"""

return uuid.uuid4()
1 change: 1 addition & 0 deletions test-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ pytest
six
wcwidth
zipp
pytest-mock

23 changes: 17 additions & 6 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ attrs==20.2.0 \
--hash=sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594 \
--hash=sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc \
# via -r test-requirements.in, pytest
importlib-metadata==1.6.1 \
--hash=sha256:15ec6c0fd909e893e3a08b3a7c76ecb149122fb14b7efe1199ddd4c7c57ea958 \
# via -r test-requirements.in
importlib-metadata==1.7.0 \
--hash=sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83 \
--hash=sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070 \
# via -r test-requirements.in, pluggy, pytest
iniconfig==1.0.1 \
--hash=sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437 \
--hash=sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69 \
Expand All @@ -24,36 +25,46 @@ more-itertools==8.5.0 \
--hash=sha256:9b30f12df9393f0d28af9210ff8efe48d10c94f73e5daf886f10c4b0b0b4f03c \
# via -r test-requirements.in, pytest
packaging==20.4 \
--hash=sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8 \
--hash=sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181 \
# via -r test-requirements.in, pytest
pluggy==0.13.1 \
--hash=sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0 \
--hash=sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d \
# via -r test-requirements.in, pytest
py==1.9.0 \
--hash=sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2 \
--hash=sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342 \
# via -r test-requirements.in, pytest
pyparsing==2.4.7 \
--hash=sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1 \
--hash=sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b \
# via -r test-requirements.in, packaging
pytest-asyncio==0.14.0 \
--hash=sha256:2eae1e34f6c68fc0a9dc12d4bea190483843ff4708d24277c41568d6b6044f1d \
--hash=sha256:9882c0c6b24429449f5f969a5158b528f39bde47dc32e85b9f0403965017e700 \
# via -r test-requirements.in
pytest-mock==3.3.1 \
--hash=sha256:024e405ad382646318c4281948aadf6fe1135632bea9cc67366ea0c4098ef5f2 \
--hash=sha256:a4d6d37329e4a893e77d9ffa89e838dd2b45d5dc099984cf03c703ac8411bb82 \
# via -r test-requirements.in
pytest==6.0.1 \
--hash=sha256:85228d75db9f45e06e57ef9bf4429267f81ac7c0d742cc9ed63d09886a9fe6f4 \
--hash=sha256:8b6007800c53fdacd5a5c192203f4e531eb2a1540ad9c752e052ec0f7143dbad \
# via -r test-requirements.in, pytest-asyncio
# via -r test-requirements.in, pytest-asyncio, pytest-mock
negillett marked this conversation as resolved.
Show resolved Hide resolved
six==1.15.0 \
--hash=sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259 \
--hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced \
# via -r test-requirements.in, packaging
toml==0.10.1 \
--hash=sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f \
--hash=sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88 \
# via pytest
wcwidth==0.2.4 \
--hash=sha256:79375666b9954d4a1a10739315816324c3e73110af9d0e102d906fdb0aec009f \
wcwidth==0.2.5 \
--hash=sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784 \
--hash=sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83 \
# via -r test-requirements.in
zipp==3.1.0 \
--hash=sha256:aa36550ff0c0b7ef7fa639055d797116ee891440eac1a56f378e2d3179e0320b \
--hash=sha256:c599e4d75c98f6798c509911d08a22e6c021d074469042177c8c86fb92eefd96 \
# via -r test-requirements.in, importlib-metadata
25 changes: 25 additions & 0 deletions tests/test_gateway.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
import pytest

from exodus_gw import gateway


def test_healthcheck():
assert gateway.healthcheck() == {"detail": "exodus-gw is running"}


@pytest.mark.parametrize(
"env,expected",
[
("dev", {"detail": "Created Publish Id"}),
("qa", {"detail": "Created Publish Id"}),
(
"stage",
{"detail": "Created Publish Id"},
),
(
"prod",
{"detail": "Created Publish Id"},
),
(
"env_doesnt_exist",
{"error": "environment env_doesnt_exist not found"},
),
],
)
def test_publish(env, expected):
assert gateway.publish(env) == expected
12 changes: 12 additions & 0 deletions tests/test_publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from exodus_gw import publish


def test_create_publish_id(mocker):
mocker.patch(
"uuid.uuid4",
return_value="f6486570-ed20-11ea-9114-94b86d596988",
)

assert (
publish.create_publish_id() == "f6486570-ed20-11ea-9114-94b86d596988"
)
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ whitelist_externals=sh

[testenv:static]
deps=
black
pylint
aioboto3
pylint==2.6.0
black==20.8b1
commands_pre=
commands=
black --check .
Expand Down