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

Testing for views, models, and forms in Django Application #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eshaanagarwal
Copy link

Completed Tutorial 11 - Testing of Django Application

  • example of implementing test with Book model
  • example of implementing test of form with RenewBookForm
  • example of implementing test of views
  • example of implementing test of views with restricted access
  • example of implementing test of views with forms

Copy link
Collaborator

@davidgarg20 davidgarg20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests seems fine though I do not remember the main code so didn't reviewed that deeply. if these test are running successfully and you are confident about them we are good to merge this

from django.contrib.auth.models import User # Required to assign User as a borrower

from catalog.models import BookCopy, Book

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to have import at top (one place). here you are also reimporting book that should not be done.

login = self.client.login(username='testuser2', password='2HJ1vRV0Z&3iD')
valid_date_in_future = datetime.date.today() + datetime.timedelta(weeks=2)
response = self.client.post(reverse('renew-book-librarian', kwargs={'pk':self.test_bookinstance1.pk,}), {'renewal_date':valid_date_in_future})
self.assertRedirects(response, reverse('all-borrowed'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use a linter also to avoid lint issue like missing newline an end or any other lint issues.

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

Successfully merging this pull request may close these issues.

2 participants