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

#533 feat: creating tests for swagger ui #534

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

keythroy
Copy link
Contributor

@keythroy keythroy commented Nov 9, 2023

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.

Copy link

netlify bot commented Nov 9, 2023

Deploy Preview for activist-org ready!

Name Link
🔨 Latest commit ace4493
🔍 Latest deploy log https://app.netlify.com/sites/activist-org/deploys/65553d312b601b0008049062
😎 Deploy Preview https://deploy-preview-534--activist-org.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Nov 9, 2023

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

  • The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution

    • The contributor's name and icon in remote commits should be the same as what appears in the PR
    • If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for git config user.email in their local activist repo
  • The TypeScript and formatting workflows within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@to-sta
Copy link
Collaborator

to-sta commented Nov 10, 2023

@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

@to-sta
Copy link
Collaborator

to-sta commented Nov 15, 2023

@andrewtavis added type hinting and this ready to be merged. Thanks again for work on this @keythroy 😃

Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work here, @keythroy! Hope you pick up another issue soon!

And thanks for the final touches, @to-sta 😊

@andrewtavis andrewtavis merged commit e67b69b into activist-org:main Nov 15, 2023
5 checks passed
@keythroy
Copy link
Contributor Author

OK ! I understood the difference. @to-sta thanks for the advice! See you soon at the sync call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants