Skip to content

Commit

Permalink
API for creating publish objects - initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lmilbaum committed Sep 7, 2020
1 parent cf7ebb8 commit 9469006
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 2 deletions.
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"""
if env not in ["dev", "qa", "stage", "prod"]:
return {"error": "environment {0} not found".format(env)}
create_publish_id()
return {"detail": "Created Publish Id"}
9 changes: 9 additions & 0 deletions exodus_gw/publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import uuid


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

publish_id = uuid.uuid4()

return {"detail": publish_id}
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

6 changes: 5 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ 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==5.4.3 \
--hash=sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1 \
# via -r test-requirements.in, pytest-asyncio
# via -r test-requirements.in, pytest-asyncio, pytest-mock
six==1.15.0 \
--hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced \
# via -r test-requirements.in, packaging
Expand Down
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() == {
"detail": "f6486570-ed20-11ea-9114-94b86d596988"
}

0 comments on commit 9469006

Please sign in to comment.