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

Unit tests for new_student view #79

Open
garg3133 opened this issue Jan 25, 2021 · 27 comments
Open

Unit tests for new_student view #79

garg3133 opened this issue Jan 25, 2021 · 27 comments

Comments

@garg3133
Copy link
Owner

Write unit tests for new_student view in the students app. The tests need to be added in a file test_views in test directory of students app.

To learn about how to write unit tests in Django, you may follow this tutorial from MDN: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Testing

For any further doubts and queries, feel free to join the community and ask there: https://discord.gg/Ek9q45ZjAv

@Vrindagupta6828
Copy link
Contributor

@garg3133 Can I work on this issue. Please assign this issue to me.

@garg3133
Copy link
Owner Author

Sure @Vrindagupta6828!

@Vrindagupta6828
Copy link
Contributor

@garg3133 Can you please tell me how to run the test written as when i am executing the statement manage.py test students it is showing the following error:
ModuleNotFoundError: No module named 'students'

@garg3133
Copy link
Owner Author

garg3133 commented Feb 3, 2021

Try to run python manage.py test apps/students

Also, add an empty __init__.py file in tests directory.

@Vrindagupta6828
Copy link
Contributor

I did all that but when i am running this it is showing ran 0 test

@Vrindagupta6828
Copy link
Contributor

It should show ran 1 test

@garg3133
Copy link
Owner Author

garg3133 commented Feb 3, 2021

Have you deleted the tests.py file? If not, you should delete it.

You may also add a __init__.py file in apps directory if you face any ModuleNotFoundError.

@Vrindagupta6828
Copy link
Contributor

Vrindagupta6828 commented Feb 4, 2021

I have deleted the file and create a folder named tests and in that have made a file test_views.py

@Vrindagupta6828
Copy link
Contributor

@garg3133 Can you please assist me how to advance further?

@garg3133
Copy link
Owner Author

garg3133 commented Feb 4, 2021

@Vrindagupta6828 Where are you stuck at?

You first need to create a class with name that matches function view name like NewStudentViewTest.

In that class, create a function setUpTestData in which you'll need to create some sample user (with auth & is_active as True), and then create that user's volunteer profile so that the user can access new_student view.

Then the first few functions will be same as in https://github.com/garg3133/fossee/blob/master/roomslotbooking/home/tests/test_views.py IndexViewTest which just tests if the user is being redirected properly if the user is not a volunteer, hasn't completed the profile or not authenticated. Then it should test if the correct template is being shown to the user. Then just the basic working of the new_student view to check if everything is working as expected.

Everything is explained in great details in this tutorial: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Testing

Testing is a very major part of any software and hence should be done properly.

You can watch this video to get an essence of why we actually do testing: https://www.youtube.com/watch?v=1Lfv5tUGsn8

@anurag0singh
Copy link
Contributor

@garg3133 please assign this to me under GSSOC'21

@garg3133
Copy link
Owner Author

Sure @anurag0singh!

@Jagrati-Bot
Copy link
Collaborator

Jagrati-Bot commented Apr 14, 2021

Hello @anurag0singh, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.

Thanks for your contributions, and hope to see you again soon!

@harshakhmk
Copy link
Contributor

Is the issue still alive to add code, I am interested in adding the unit-tests

@anurag0singh
Copy link
Contributor

Is the issue still alive to add code, I am interested in adding the unit-tests

Yes, you can work on it.
@garg3133 I am sorry but I cannot do this work. Please assign @harshakhmk on this one.

@AjaySharma132
Copy link

Is the issue still alive to add code, I am interested in adding the unit-tests

@harshakhmk I am assigning you this issue

@harshakhmk
Copy link
Contributor

Do I need to add test views in all apps

@Jagrati-Bot
Copy link
Collaborator

Hello @harshakhmk, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?

If so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.

If you've decided to work on something else, simply unassign yourself from this issue by going to the Assignees section and clicking on unassign me, so that someone else can claim it and continue from where you left off.

Thank you for your valuable contributions to JagratiWebApp!

@harshakhmk
Copy link
Contributor

I am working on it @Jagrati-Bot

@garg3133
Copy link
Owner Author

Do I need to add test views in all apps

No, you just need to add the tests in the students app for this issue.

@harshakhmk
Copy link
Contributor

I have created the PR 262 please review it @garg3133

@harshakhmk
Copy link
Contributor

@Jagrati-Bot review pending

@Jagrati-Bot
Copy link
Collaborator

Hello @harshakhmk, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?

If so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.

If you've decided to work on something else, simply unassign yourself from this issue by going to the Assignees section and clicking on unassign me, so that someone else can claim it and continue from where you left off.

Thank you for your valuable contributions to JagratiWebApp!

@harshakhmk
Copy link
Contributor

I am sorry, I was not able to work @priyansh3133 you guided me well with the workflow, but it failed on my local system and I was not clear with flow of user signup process, unassign me this issue

@akshay399
Copy link
Contributor

@garg3133 is this issue open? if so pls assign me, i have never worked with unit tests i want to give it a try

@Jagrati-Bot
Copy link
Collaborator

Hello @akshay399, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?

If so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 4 days.

If you've decided to work on something else, simply unassign yourself from this issue by going to the Assignees section and clicking on unassign me, so that someone else can claim it and continue from where you left off.

Thank you for your valuable contributions to JagratiWebApp!

@Jagrati-Bot
Copy link
Collaborator

Jagrati-Bot commented Jun 18, 2021

Hello @akshay399, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.

Thanks for your contributions, and hope to see you again soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants