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

Adding unit tests for the Database #16

Merged
merged 2 commits into from
Nov 7, 2023
Merged

Adding unit tests for the Database #16

merged 2 commits into from
Nov 7, 2023

Conversation

jhimanish
Copy link
Contributor

List of Unit Tests:

  • check database file exists (test.db)
  • check that the database is empty at start and has no users or events inside
  • test to ensure that a new user can be added into the database and also retrieved using the email as a query
  • test to ensure that a new event can be added into the database and also retrieved using the event name as a query
  • testing if users can be added to event_attendance table when they register for events. This checks the many-to-many relationship between the Users and Events database.

To run these tests on your end, use the following code:

  1. cd api
  2. python -m pytest utils/unit_tests/database_test

Note: Without changing your directory to api/, the test does not run correctly because it can't resolve imports in the api.py file. I think this could be due to how we've setup our testing infrastructure. We may want to create a separate folder (outside of api/) for our unit tests (similar to the lab5 directory setup).

Note: This branch merges into feat/db_models as I branched off feat/db_models to create this branch. We should first merge #7 into main which will allow this PR to merge into main normally as well.

@jhimanish jhimanish added the enhancement New feature or request label Oct 30, 2023
Base automatically changed from feat/db_models to main October 30, 2023 19:09
Copy link
Contributor

@coskos-ops coskos-ops left a comment

Choose a reason for hiding this comment

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

LGTM

@zhast zhast self-requested a review November 7, 2023 00:18
Copy link
Collaborator

@zhast zhast left a comment

Choose a reason for hiding this comment

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

Looks good, although will need to be adapted to Heroku Postgres once we fully migrate.

@JuliaLWang8 JuliaLWang8 merged commit b997b1b into main Nov 7, 2023
@jhimanish jhimanish deleted the feat/database_test branch November 7, 2023 01:16
ChNgineer pushed a commit that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants