hotosm / fAIr

AI Assisted Mapping
GNU Affero General Public License v3.0
70 stars 58 forks source link

Implement Backend Test Cases for fAIr #229

Open kshitijrajsharma opened 4 months ago

kshitijrajsharma commented 4 months ago

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:

Expected Outcomes:

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 :

Videos and docs :

What should be included in PR:

--- What does this PR do ?

--- Consideration:

--- How to test ?

Support:

Feel free to ask questions or seek clarifications by commenting on this issue. We're excited to see your contributions.

How to Proceed:

Issue will be completed when :

ohthebrave commented 4 months ago

Kindly assign this issue to me

kshitijrajsharma commented 4 months ago

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 commented 4 months ago

I will also be working on this.

hamzambo commented 4 months ago

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

owolabioromidayo commented 4 months ago

Hello! I will also be working on this.

angeangoh commented 4 months ago

please @kshitijrajsharma can you assign it to me too ?

kshitijrajsharma commented 4 months ago

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

Payne680 commented 4 months ago

I will be working on this too

Munaelekwa commented 4 months ago

Hello, I would also be working on this issue

Munaelekwa commented 4 months ago

@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 commented 4 months ago

I will also be working on this.

Jojowangfy commented 4 months ago

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

kshitijrajsharma commented 4 months ago

@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 commented 4 months ago

Working on this, thank you.

Munaelekwa commented 4 months ago

@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 commented 4 months ago

I would like to working on this issue

Talikamuhib commented 4 months ago

Hello World!

I would love to work on this project!

Happy contributing :)

owolabioromidayo commented 4 months ago

@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 commented 4 months ago

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 commented 4 months ago

Thank you! On it.

owolabioromidayo commented 4 months ago

@kshitijrajsharma https://github.com/owolabioromidayo/fAIr/pull/1

ademolaomosanya commented 4 months ago

@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 commented 4 months ago

@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 commented 4 months ago

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 commented 4 months ago

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

maryagiamah commented 4 months ago

Hello can I contribute here too.

kshitijrajsharma commented 4 months ago

@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?

You are missing authentication in header , You can get your authentication from /auth endpoints . In your logs it says forbidden 🚫

kshitijrajsharma commented 4 months ago

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

Go ahead

owolabioromidayo commented 4 months ago

@kshitijrajsharma

I have my TESTING_TOKEN set using the token value in the localStorage of the frontend website. It seems to work fine for the auth endpoint tests.

image

The 403 comes from the first dataset test without the header. The 500 however, is due an internal server error from the request with the correct header set.

kshitijrajsharma commented 4 months ago

@kshitijrajsharma

I have my TESTING_TOKEN set using the token value in the localStorage of the frontend website.

It seems to work fine for the auth endpoint tests.

image

The 403 comes from the first dataset test without the header.

The 500 however, is due an internal server error from the request with the correct header set.

Right , Do you have export tool api env variable set ? If yes , remove it and let it use default one ! It should work

owolabioromidayo commented 4 months ago

image

It wasn't set. Ran again and nothing changed.

Then I explicitly set it to its default value and got this.

image

kshitijrajsharma commented 4 months ago

image

It wasn't set. Ran again and nothing changed.

Then I explicitly set it to its default value and got this.

image

There you go ,You solved the application error . Now that's something to debug in your test case !

Liz-Adhiambo commented 4 months ago

I will be working on this issue

hadijah10 commented 4 months ago

I will be working on this.

tony-nyagah commented 4 months ago

I'll be working on this.

Oluwakunmi-Obaditan commented 4 months ago

Hi Kshitij, I will be contributing to this project.

tony-nyagah commented 4 months ago

Hello, @kshitijrajsharma. Would you mind taking a look at my submission? I'd greatly appreciate your feedback. https://github.com/tony-nyagah/fAIr/pull/1

Arnav2824 commented 4 months ago

Hey @kshitijrajsharma , I would like to work on this issue

nwekealex65 commented 4 months ago

Hello @kshitijrajsharma, I would like to work on this issue. I started already, I would make a pull request soon

Pazil24 commented 4 months ago

@kshitijrajsharma I have received an invite to the HOTOSM slack community but I am able to join due to an org email being required. Should I go ahead and work on this issue?

nwekealex65 commented 4 months ago

@kshitijrajsharma review my pull request. This is the url => https://github.com/nwekealex65/fAIr/pull/1

Janarthana2992 commented 4 months ago

I would like to work on this issue. @kshitijrajsharma

owolabioromidayo commented 4 months ago

Hi @kshitijrajsharma , I also have a PR ready here https://github.com/owolabioromidayo/fAIr/pull/2.

Would like to get your thoughts on it, so I can continue coverage over other endpoints if this style is desirable. Thank you.

RuthM-K commented 4 months ago

Hello, @kshitijrajsharma can I work on this issue as well?

nwekealex65 commented 4 months ago

Hello @kshitijrajsharma I wrote test cases for the TrainingViewSet and DataSetView this is a link to my pull request https://github.com/nwekealex65/fAIr/pull/2 please review and give me feedback

tony-nyagah commented 4 months ago

Hello @kshitijrajsharma. I wrote some tests for models in the login app. I'd greatly appreciate some feedback when you get the time. Here is the link to my pr: https://github.com/tony-nyagah/fAIr/pull/2.

Olatundeawo commented 4 months ago

I will like to work on this project

mvhammedali commented 4 months ago

Here is my PR https://github.com/mvhammedali/fAIr/pull/2 :D

Liz-Adhiambo commented 4 months ago

Hello, I just made a pull request here . I would really appreciate your feedback. Thank you

Peace-Apple commented 4 months ago

I will also be working on this issue.