Repository: hotosm/fAIr
Author: kshitijrajsharma
## Issue Description:
### Objective:
We are seeking an enthusiastic intern to collaborate on enhancing our Django backend project by integrating backend test cases. This issue aims to ensure the robustness and reliability of our application through systematic testing practices. Your contribution will involve writing test cases, determining code coverage, and ensuring all functionalities are tested following industry best practices.
### Responsibilities:
- Understand the current project structure and functionality by reviewing the existing models, views, and URLs. Backend is available [here](https://github.com/hotosm/fAIr/tree/master/backend). If you have trouble installing the application to do raise issue or ask for help
- Collaborate with the development team to identify critical areas lacking test coverage.
- Write comprehensive test cases for the Django backend, focusing on models, APIs, and integration points.
- Utilize Django's testing framework effectively to automate tests.
- Ensure test cases are well-documented and maintainable.
- Measure and report code coverage to identify untested code segments.
- Propose improvements or bug fixes identified during testing.
- Participate in code reviews to receive feedback and iterate on your work.
### Expected Outcomes:
- A suite of automated tests covering critical functionalities of the Django backend.
- Documentation accompanying each test case, explaining its purpose and methodology.
- A code coverage report highlighting tested vs. untested code segments.
- Recommendations for improving code quality and application performance based on test findings.
### Resources
Test Folder Structure :
```
└── backend
└── tests
├── __init__.py
├── test_worker_example.py
├── test_models_example.py
└── test_views_example.py
```
Tests should cover Any of the following :
- models
- views
- & the API. Find API swagger [here](https://fair-dev.hotosm.org/api/redoc/)
Videos and docs :
- Find begineer guide to contribute to HOTOSM Tools [here](https://www.youtube.com/watch?v=gnr7mMSDCS4)
- Know about fAIr as a project and what does is do [here](https://www.youtube.com/watch?v=N2_9Bvm05_0&t=4s)
- Django test coverage tool : https://coverage.readthedocs.io/en/latest/
- Find HOTOSM Developer guidelines [here](https://docs.hotosm.org/dev-guide/intro/)
- [factory_boy](https://github.com/rbarrois/factory_boy),[ model_backery](http://model-bakery.readthedocs.org/), and [mock](https://pypi.python.org/pypi/mock): all are used in place of [fixtures](https://docs.djangoproject.com/en/dev/howto/initial-data/) or the ORM for populating needed data for testing. Both fixtures and the ORM can be slow and need to be updated whenever your model changes.
- Documentation on getting started with django projects testing by [realpython](https://realpython.com/testing-in-django-part-1-best-practices-and-examples/)
### What should be included in PR:
- Black formatter should be used
- At least mention following section
--- What does this PR do ?
- Detail summary about the changes you have done, Which backend functionality you have worked on , Mention link of issue you have worked on
--- Consideration:
- What are the steps/alternatives you have considered while developing
--- How to test ?
- Steps to tests
### Support:
Feel free to ask questions or seek clarifications by commenting on this issue. We're excited to see your contributions.
### How to Proceed:
- Fork the repository and set up the project locally.
- Comment on this issue mentioning you will be contributing
- Familiarize yourself with the codebase and Django's testing framework.
- Start by creating new branch in your fork with functional branch name like ```tests/aoi-models```
- Write a few test cases and submit them as a pull request in your own fork
- Come back to this issue thread and drop your pull request URL for initial feedback.
- Gradually work on covering more components and functionalities. Once approved, you can raise PR to this main repo
### Issue will be completed when :
- All critical backend functionalities are covered by test cases.
- Code coverage is significantly improved, aiming at least 80%.
- Tests are well-documented and follow coding standards.