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

Implement Backend Test Cases for fAIr #229

Open
kshitijrajsharma opened this issue Mar 3, 2024 · 67 comments
Open

Implement Backend Test Cases for fAIr #229

kshitijrajsharma opened this issue Mar 3, 2024 · 67 comments
Labels
component : backend enhancement New feature or request good first issue Issues that welcome contributions Outreachy Project tasks for Outreachy internship - May to August 2023

Comments

@kshitijrajsharma
Copy link
Member

kshitijrajsharma commented Mar 3, 2024

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. 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

Videos and docs :

  • Find begineer guide to contribute to HOTOSM Tools here
  • Know about fAIr as a project and what does is do here
  • Django test coverage tool : https://coverage.readthedocs.io/en/latest/
  • Find HOTOSM Developer guidelines here
  • factory_boy, model_backery, and mock: all are used in place of fixtures 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

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.
@kshitijrajsharma kshitijrajsharma added enhancement New feature or request good first issue Issues that welcome contributions component : backend Outreachy Project tasks for Outreachy internship - May to August 2023 labels Mar 3, 2024
@ohthebrave
Copy link

Kindly assign this issue to me

@kshitijrajsharma
Copy link
Member Author

Sure go ahead , This issue can be worked by multiple people hence no need for assignee , You can fork the repo and start working on it ! Feel free to drop questions.

@shekinahmanyi
Copy link

I will also be working on this.

@hamzambo
Copy link

hamzambo commented Mar 5, 2024

i would like to work on this issue as well. Would like to know if the project can be run on windows.

@owolabioromidayo
Copy link
Contributor

Hello! I will also be working on this.

@angeangoh
Copy link

please @kshitijrajsharma can you assign it to me too ?

@kshitijrajsharma
Copy link
Member Author

Yes project can run on windows ! There is a windows installation doc in repo

@Payne680
Copy link

Payne680 commented Mar 5, 2024

I will be working on this too

@Munaelekwa
Copy link

Hello, I would also be working on this issue

@Munaelekwa
Copy link

@kshitijrajsharma please i'm trying to install the requirements.txt file and it throws an error concerning the tensorflow version,
ERROR: Could not find a version that satisfies the requirement tflite-runtime==2.14.0 (from versions: none)
ERROR: No matching distribution found for tflite-runtime==2.14.0
any suggestions?

@isiagi
Copy link

isiagi commented Mar 5, 2024

I will also be working on this.

@Jojowangfy
Copy link

I'd also like to work on this. Thank you.

@kshitijrajsharma
Copy link
Member Author

@kshitijrajsharma please i'm trying to install the requirements.txt file and it throws an error concerning the tensorflow version,

ERROR: Could not find a version that satisfies the requirement tflite-runtime==2.14.0 (from versions: none)

ERROR: No matching distribution found for tflite-runtime==2.14.0

any suggestions?

Are you using docker ?

@Erickkaranja
Copy link

Working on this, thank you.

@Munaelekwa
Copy link

@kshitijrajsharma please i'm trying to install the requirements.txt file and it throws an error concerning the tensorflow version,
ERROR: Could not find a version that satisfies the requirement tflite-runtime==2.14.0 (from versions: none)
ERROR: No matching distribution found for tflite-runtime==2.14.0
any suggestions?

Are you using docker ?

i have docker installed, but I'm not using it

@siva224513
Copy link

I would like to working on this issue

@Talikamuhib
Copy link

Hello World!

I would love to work on this project!

Happy contributing :)

@owolabioromidayo
Copy link
Contributor

@kshitijrajsharma I have the project running now.

There is a slight issue I ran into that might be helpful for others to note.

I was initially not able to login to OSM from the fair frontend server, as its requests to the backend kept getting bounced due to CORS errors.

Looking at the .env file for the backend, and the settings.py file, everything was already configured.
I thought it was due to some errors from the backend and database container logs but that turned out to not be the case.

All I had to do was open the frontend using "127.0.0.1:3000" instead of "localhost:3000" and that fixed everything.

I would also recommend for others to use docker and follow the instructions from https://github.com/hotosm/fAIr/blob/master/docs/Docker-installation.md.

@kshitijrajsharma
Copy link
Member Author

Lovely @owolabioromidayo !

All I had to do was open the frontend using "127.0.0.1:3000" instead of "localhost:3000" and that fixed everything.

That is fully correct ! We should mention this in .md

@owolabioromidayo
Copy link
Contributor

Thank you!
On it.

@owolabioromidayo
Copy link
Contributor

@ademolaomosanya
Copy link

@kshitijrajsharma I have the project running now.

There is a slight issue I ran into that might be helpful for others to note.

I was initially not able to login to OSM from the fair frontend server, as its requests to the backend kept getting bounced due to CORS errors.

Looking at the .env file for the backend, and the settings.py file, everything was already configured. I thought it was due to some errors from the backend and database container logs but that turned out to not be the case.

All I had to do was open the frontend using "127.0.0.1:3000" instead of "localhost:3000" and that fixed everything.

I would also recommend for others to use docker and follow the instructions from https://github.com/hotosm/fAIr/blob/master/docs/Docker-installation.md.

@owolabioromidayo thank you for this suggestion
Have been facing issues while setting up and the link you also shared would be helpful

@owolabioromidayo
Copy link
Contributor

@kshitijrajsharma Is the test_create_dataset testcase currently passing?

image

This is where mine fails:
image

I have tried changing the input data and headers to match different branches of the LabelViewSet create method but the error remains the same.

I have also tried debugging by printing, printing to stderr, and logging output to a file from the create method but none of those approaches yields anything. It could be that the request fails before it even reaches this method.

Is there something I might have misconfigured?

@marameref
Copy link

Hello @kshitijrajsharma my Outreachy initial application was approved and I would like to work on this issue. Is it still open, can I proceed to work on this issue? Pls respond

@ohthebrave
Copy link

@kshitijrajsharma You should mention the need to set up a virtual environment when writing tests.

@maryagiamah
Copy link

Hello can I contribute here too.

@azharcodeit
Copy link

Hey @kshitijrajsharma, appreciate the opportunity to contribute, will drop a PR as soon as possible!

@nifedara
Copy link
Contributor

Hi @kshitijrajsharma, I will be contributing

@princyym
Copy link

Hello @kshitijrajsharma, I want to contribute for the same!!

@nifedara
Copy link
Contributor

nifedara commented Mar 26, 2024

Hello @kshitijrajsharma, when I hit the login to get an access token, I get this:
image

image

Another time, it redirects here to the frontend:
image

I can't seem to get the access token. I don't know where to get it from here. Please point me to how to get it

@mvhammedali
Copy link

@nifedara inspect > Application > LocalStorage

@nifedara
Copy link
Contributor

@nifedara inspect > Application > LocalStorage

Thank youu. I have gotten it now

@nwekealex65
Copy link
Contributor

@kshitijrajsharma Please review my PR nwekealex65#6

@medinasheriff
Copy link

Hi, I will be contributing to this project. Thank you.

@nifedara
Copy link
Contributor

Hi, @kshitijrajsharma,
here is my PR: Oluwanifemi PR

@tony-nyagah
Copy link

Hi @kshitijrajsharma, here is my PR: tony-nyagah#3

@durotimmi-sk
Copy link

hi, i will like to contribute to this project. Thank you

@Pazil24
Copy link

Pazil24 commented Apr 1, 2024

I would like to contribute to this @kshitijrajsharma , I an still analyzing and learning. However I love the challenge this project brings.

@princyym
Copy link

princyym commented Apr 2, 2024

hello @kshitijrajsharma,. Do I need to create all three files (models, views, and API) or is it sufficient to create just one of them? Additionally, should I document the test cases in Notion?

@nifedara
Copy link
Contributor

nifedara commented Apr 2, 2024

Hello, @kshitijrajsharma,
Here's another PR:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component : backend enhancement New feature or request good first issue Issues that welcome contributions Outreachy Project tasks for Outreachy internship - May to August 2023
Projects
None yet
Development

No branches or pull requests