JagratiWebApp
JagratiWebApp copied to clipboard
Unit tests for new_student view
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
@garg3133 Can I work on this issue. Please assign this issue to me.
Sure @Vrindagupta6828!
@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'
Try to run python manage.py test apps/students
Also, add an empty __init__.py
file in tests
directory.
I did all that but when i am running this it is showing ran 0 test
It should show ran 1 test
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.
I have deleted the file and create a folder named tests and in that have made a file test_views.py
@garg3133 Can you please assist me how to advance further?
@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
@garg3133 please assign this to me under GSSOC'21
Sure @anurag0singh!
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!
Is the issue still alive to add code, I am interested in adding the unit-tests
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.
Is the issue still alive to add code, I am interested in adding the unit-tests
@harshakhmk I am assigning you this issue
Do I need to add test views in all apps
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!
I am working on it @Jagrati-Bot
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.
I have created the PR 262 please review it @garg3133
@Jagrati-Bot review pending
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!
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
@garg3133 is this issue open? if so pls assign me, i have never worked with unit tests i want to give it a try
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!
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!