-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API for creating publish objects - initial commit
/{env}/publish end point. https://projects.engineering.redhat.com/browse/RHELDST-2159
- Loading branch information
Showing
7 changed files
with
64 additions
and
2 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
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,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"} |
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,9 @@ | ||
import uuid | ||
|
||
|
||
def create_publish_id(): | ||
"""Create a new, empty publish id""" | ||
|
||
publish_id = uuid.uuid4() | ||
|
||
return {"detail": publish_id} |
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 |
---|---|---|
|
@@ -11,4 +11,5 @@ pytest | |
six | ||
wcwidth | ||
zipp | ||
pytest-mock | ||
|
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 |
---|---|---|
@@ -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 |
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 @@ | ||
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" | ||
} |