-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add new endpoint for exponentiation #70
Conversation
tests/test_api.py
Outdated
|
||
def test_exponentiation(client: starlette.testclient.TestClient) -> None: | ||
"""Test that the exponentiation endpoint correctly calculates the power of a number.""" | ||
response = client.post("/exponentiation", json={"number1": 2, "number2": 3}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@acedev-dev-ai I think all the maths endpoints have some prefix. Could you check the prefix in get_api.py
and update the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears there was a misunderstanding regarding the existence of a file named get_api.py
in the project. After reviewing the project outline, I found no such file. Instead, the project structure includes an api.py
file that seems to be responsible for setting up the API, including the registration of routers.
Given this context, it seems the initial request to check a prefix in get_api.py
was based on incorrect information. The maths endpoints, as defined in maths.py
, do not have a specific prefix beyond their operation names (e.g., /addition
, /multiplication
, /subtraction
, /division
). The new endpoint for exponentiation follows this pattern with the path /exponentiation
.
If there's a specific prefix or modification you had in mind for the test or the endpoint itself, could you please clarify? Otherwise, based on the current project structure and the existing patterns in maths.py
, the implementation and test for the exponentiation endpoint are consistent with the rest of the API design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@acedev-dev-ai right, the file is called api.py
. Please check the prefix there and update the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the test for the exponentiation endpoint to include the prefix /v1/maths
in the URL. The correct URL for the test is now /v1/maths/exponentiation
. This change aligns with the project's API structure and ensures consistency across all endpoint tests. If there are any more adjustments or reviews needed, please let me know!
tests/test_api.py
Outdated
"""Test that the exponentiation endpoint correctly calculates the power of a number.""" | ||
response = client.post("/v1/maths/exponentiation", json={"number1": 2, "number2": 3}) | ||
assert response.status_code == 200 | ||
assert response.json() == {"result": 8} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@acedev-dev-ai this test fails because the expected json does not align with the MathResult
schema. Check the expected schema and update the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the test_exponentiation
function in the tests/test_api.py
file to include the 'operation' field in the expected JSON response, aligning with the MathsResult
schema. The 'operation' field now correctly has the value 'exponentiation'. This should resolve the issue with the test failing due to the expected JSON not aligning with the schema.
This pull request adds a new endpoint for exponentiation to the API. The endpoint takes two numbers,
number1
andnumber2
, and returnsnumber1
^number2
. The implementation includes the addition of the endpoint in themaths.py
file and a corresponding test in thetest_api.py
file.