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

Johnha/feature/create unavailability testing #174

Merged
merged 7 commits into from
Mar 13, 2024

Conversation

TaiHaDev
Copy link
Contributor

Describe your changes

Setting up a testing environment for the project using pytest. Creating testing folders for functional and unit testing. Needed to be further refined to have development, testing, and production configuration. Currently, testing will create and get directly from the database which is not a good practice. Creating some test cases for creating unavailability endpoint with testing criteria:

  • two consecutive create operations must output two consecutive event_id
  • Cannot create two unavailability with the same time interval
  • Cannot create availability for nonexistent user_id
  • Cannot create unavailability with an end time earlier than the start time
  • Cannot create unavailability with weird periodicity (to be discussed)
  • There cannot be two unavailability from the same user with overlapped time interval
  • Merge interval (if implemented on API)

Some significant changes:

  • Creating a tests folder that will contain all future functional and unit tests for the project
  • Refactoring application.py class to make use of factory method design pattern so that many instances of the application can be created, for now, it can be used in testing
image

Issue ticket number and link

https://fireapp-emergiq-2024.atlassian.net/jira/software/projects/FE/boards/1?selectedIssue=FE-68

Copy link
Collaborator

@emilymclean emilymclean left a comment

Choose a reason for hiding this comment

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

In the future we should be writing our repositories etc such that we can do proper unit testing, but this is a good effort considering the code you were given!

Address the minor feedback, and remove the underscores from your branch name, just use dashes "-".

@TaiHaDev
Copy link
Contributor Author

Hi @BenMMcLean , can you have a look at my comment and my changes :-) thank youu

emilymclean
emilymclean previously approved these changes Mar 12, 2024
@emilymclean
Copy link
Collaborator

emilymclean commented Mar 12, 2024

Please address the issues with the smoke test, and then this can be merged.

(The smoke test just runs your code in a docker container. You can pull it locally using the tag pr-174. It'll tell you what's wrong)

@TaiHaDev
Copy link
Contributor Author

I tried to pull request pr-174 in Git but I think you meant something else cause I didn't find anything after pulling. It would be very helpful if you can show me some resources related to this cause I have no previous knowledge about this Github ci/cd. However, I still managed to fix the error :-) It happened because I refactored application.py into using factory method. I basically reverted the changes, I don't know exactly why it happened as the logic should be the same and it didn't really break anything as far as I can see.

@TaiHaDev
Copy link
Contributor Author

TaiHaDev commented Mar 12, 2024

Some new changes:

  • adding more testing fixtures to get JWT token and append to all testing requests so that they are authorised
  • only using one application instance for all test cases
    Some drawbacks that I need to discuss with you:
  • I think we need a testing environment (using in-memory database instead of creating data in real database) but I think it maybe out of the project's scope
  • cannot create new application instance for testing can be fine for now but maybe hard to implement the above suggestion
    Thanks for your time ☺️

@emilymclean
Copy link
Collaborator

There aren't any resources AFAIK, but all you have to do to run the docker image of your code is modify the docker-compose.frontend.yml file, changing
docker pull ghcr.io/techlauncherfireapp/backend:latest to docker pull ghcr.io/techlauncherfireapp/backend:pr-<your pr number>, and running the file.

Copy link
Collaborator

@emilymclean emilymclean 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 to me!

@TaiHaDev TaiHaDev enabled auto-merge March 13, 2024 00:45
@TaiHaDev TaiHaDev added this pull request to the merge queue Mar 13, 2024
Merged via the queue into main with commit 997a2fa Mar 13, 2024
5 checks passed
fishchimp pushed a commit that referenced this pull request Mar 14, 2024
Setting up a testing environment for the project using pytest. Creating
testing folders for functional and unit testing. Needed to be further
refined to have development, testing, and production configuration.
Currently, testing will create and get directly from the database which
is not a good practice. Creating some test cases for creating
unavailability endpoint with testing criteria:
- two consecutive create operations must output two consecutive event_id
- Cannot create two unavailability with the same time interval
- Cannot create availability for nonexistent user_id
- Cannot create unavailability with an end time earlier than the start
time
- Cannot create unavailability with weird periodicity (to be discussed)
- There cannot be two unavailability from the same user with overlapped
time interval
- Merge interval (if implemented on API)

Some significant changes:
- Creating a tests folder that will contain all future functional and
unit tests for the project
- Refactoring application.py class to make use of factory method design
pattern so that many instances of the application can be created, for
now, it can be used in testing
<img width="467" alt="image"
src="https://github.com/TechlauncherFireApp/backend/assets/97883232/f9ee0b5a-ad7a-469c-8d4e-fbea15e3f0f9">

https://fireapp-emergiq-2024.atlassian.net/jira/software/projects/FE/boards/1?selectedIssue=FE-68
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.

2 participants