-
Notifications
You must be signed in to change notification settings - Fork 231
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
#533 feat: creating tests for swagger ui #534
Conversation
✅ Deploy Preview for activist-org ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thank you for the pull request!The activist team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Development rooms once you're in. It'd be great to have you! Maintainer checklist
|
@keythroy thanks for your inititive on this issue. Looks good 😃 . I only have a minor request, in our backend code base we use type hinting and enforce it with mypy. For tests this not necessary, if it gets to complicated (e.g. if there no stubs from an external library, than we can ignore it in the mypy config.). But here its still simple type hinting :) from rest_framework.test import APIClient
def test_swagger_download(api_client: APIClient) -> None:
uri = "/v1/schema/"
response = api_client.get(uri)
assert response.status_code == 200
def test_swagger_ui(api_client: APIClient) -> None:
uri = "/v1/schema/swagger-ui/"
response = api_client.get(uri)
assert response.status_code == 200 import pytest
from rest_framework.test import APIClient
@pytest.fixture
def api_client() -> APIClient:
client = APIClient()
return client |
@andrewtavis added type hinting and this ready to be merged. Thanks again for work on this @keythroy 😃 |
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.
OK ! I understood the difference. @to-sta thanks for the advice! See you soon at the sync call |
Contributor checklist
Description
I've created the folder /backend/backend/tests/unit to organize the unit tests.
I also created two files:
1. conftest.py -> to place fixtures that can be reused
2. test_swagger.py -> containing the test cases for the swagger ui endpoints:
- /v1/schema/
- /v1/schema/swagger-ui/
The tests cases verify if a http request to those endpoints returns a 200 status.
To test if it works I've changed the urls.py file and ran the tests.