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

Rename endpoints to use hyphens not underscores #1891

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: major
changes:
changed:
- Renamed endpoints containing underscores (user_policy, user_profile, liveness_check & readiness_check) to use hyphens; updated tests
16 changes: 8 additions & 8 deletions policyengine_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@
execute_simulation_analysis
)

app.route("/<country_id>/user_policy", methods=["POST"])(set_user_policy)
app.route("/<country_id>/user-policy", methods=["POST"])(set_user_policy)

app.route("/<country_id>/user_policy", methods=["PUT"])(update_user_policy)
app.route("/<country_id>/user-policy", methods=["PUT"])(update_user_policy)

app.route("/<country_id>/user_policy/<user_id>", methods=["GET"])(
app.route("/<country_id>/user-policy/<user_id>", methods=["GET"])(
get_user_policy
)

app.route("/<country_id>/user_profile", methods=["POST"])(set_user_profile)
app.route("/<country_id>/user-profile", methods=["POST"])(set_user_profile)

app.route("/<country_id>/user_profile", methods=["GET"])(get_user_profile)
app.route("/<country_id>/user-profile", methods=["GET"])(get_user_profile)

app.route("/<country_id>/user_profile", methods=["PUT"])(update_user_profile)
app.route("/<country_id>/user-profile", methods=["PUT"])(update_user_profile)

app.route("/simulations", methods=["GET"])(get_simulations)

Expand All @@ -123,14 +123,14 @@
)


@app.route("/liveness_check", methods=["GET"])
@app.route("/liveness-check", methods=["GET"])
def liveness_check():
return flask.Response(
"OK", status=200, headers={"Content-Type": "text/plain"}
)


@app.route("/readiness_check", methods=["GET"])
@app.route("/readiness-check", methods=["GET"])
def readiness_check():
return flask.Response(
"OK", status=200, headers={"Content-Type": "text/plain"}
Expand Down
4 changes: 2 additions & 2 deletions policyengine_api/openapi_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ paths:
schema:
type: string

/liveness_check:
/liveness-check:
get:
summary: Test for server liveness.
operationId: liveness_check
Expand All @@ -753,7 +753,7 @@ paths:
text/plain:
schema:
type: string
/readiness_check:
/readiness-check:
get:
summary: Test for server readiness.
operationId: readiness_check
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_liveness.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Liveness
endpoint: /liveness_check
endpoint: /liveness-check
response:
status: 200
2 changes: 1 addition & 1 deletion tests/api/test_readiness.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Readiness
endpoint: /readiness_check
endpoint: /readiness-check
response:
status: 200
12 changes: 6 additions & 6 deletions tests/python/test_user_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ def test_set_and_get_record(self, rest_client):
),
)

res = rest_client.post("/us/user_policy", json=self.test_policy)
res = rest_client.post("/us/user-policy", json=self.test_policy)
return_object = json.loads(res.text)
print(return_object)

assert return_object["status"] == "ok"
assert res.status_code == 201

res = rest_client.get(f"/us/user_policy/{self.user_id}")
res = rest_client.get(f"/us/user-policy/{self.user_id}")
return_object = json.loads(res.text)
print(return_object)

assert return_object["status"] == "ok"
assert return_object["result"][0]["reform_id"] == self.reform_id
assert return_object["result"][0]["baseline_id"] == self.baseline_id

res = rest_client.post("/us/user_policy", json=self.test_policy)
res = rest_client.post("/us/user-policy", json=self.test_policy)
return_object = json.loads(res.text)
print(return_object)

Expand All @@ -90,7 +90,7 @@ def test_set_and_get_record(self, rest_client):
"id": user_policy_id,
}

res = rest_client.put("/us/user_policy", json=updated_test_policy)
res = rest_client.put("/us/user-policy", json=updated_test_policy)
return_object = json.loads(res.text)
print(return_object)

Expand Down Expand Up @@ -142,14 +142,14 @@ def test_nulls(self, rest_client):
),
)

res = rest_client.post("/us/user_policy", json=nulled_test_policy)
res = rest_client.post("/us/user-policy", json=nulled_test_policy)
return_object = json.loads(res.text)
print(return_object)

assert return_object["status"] == "ok"
assert res.status_code == 201

res = rest_client.post("/us/user_policy", json=nulled_test_policy)
res = rest_client.post("/us/user-policy", json=nulled_test_policy)
return_object = json.loads(res.text)
print(return_object)

Expand Down
12 changes: 6 additions & 6 deletions tests/python/test_user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def test_set_and_get_record(self, rest_client):
),
)

res = rest_client.post("/us/user_profile", json=self.test_profile)
res = rest_client.post("/us/user-profile", json=self.test_profile)
return_object = json.loads(res.text)

assert return_object["status"] == "ok"
assert res.status_code == 201

res = rest_client.get(f"/us/user_profile?auth0_id={self.auth0_id}")
res = rest_client.get(f"/us/user-profile?auth0_id={self.auth0_id}")
return_object = json.loads(res.text)
print(return_object)

Expand All @@ -50,7 +50,7 @@ def test_set_and_get_record(self, rest_client):

user_id = return_object["result"]["user_id"]

res = rest_client.get(f"/us/user_profile?user_id={user_id}")
res = rest_client.get(f"/us/user-profile?user_id={user_id}")
return_object = json.loads(res.text)

assert res.status_code == 200
Expand All @@ -64,7 +64,7 @@ def test_set_and_get_record(self, rest_client):
test_username = "maxwell"
updated_profile = {"user_id": user_id, "username": test_username}

res = rest_client.put("/us/user_profile", json=updated_profile)
res = rest_client.put("/us/user-profile", json=updated_profile)
return_object = json.loads(res.text)

assert return_object["status"] == "ok"
Expand All @@ -82,7 +82,7 @@ def test_set_and_get_record(self, rest_client):
}

res = rest_client.put(
"/us/user_profile", json=malicious_updated_profile
"/us/user-profile", json=malicious_updated_profile
)
return_object = json.loads(res.text)

Expand All @@ -97,7 +97,7 @@ def test_non_existent_record(self, rest_client):
non_existent_auth0_id = 15303

res = rest_client.get(
f"/us/user_profile?auth0_id={non_existent_auth0_id}"
f"/us/user-profile?auth0_id={non_existent_auth0_id}"
)
return_object = json.loads(res.text)
print(return_object)
Expand Down
Loading