Example #1
0
    def test_user_can_reserve_maximum_of_three_books(self):
        books = [
            self.book,
            create_book('test_book_2'),
            create_book('test_book_3'),
            create_book('test_book_4')
        ]

        for book in books:
            self.__post_reservation_create(book.id)

        messages = list(get_messages(self.response.wsgi_request))

        self.assertEqual(Reservation.objects.count(), 3)
        self.assertEqual(str(messages[0]),
                         'You have reserved maximum number of books.')
Example #2
0
    def test_with_objects(self):
        book = create_book('test', 'test', borrowings_count=1)
        create_author('test', 'test')
        create_genre('test')

        self.__get_response()
        self.__assert_context(1, 1, 1, [book], [book])
Example #3
0
    def test_detail_with_logged_in_user(self):
        book = create_book('test', 'test')

        self.login()
        self.__get_detail_response(book.id)
        self.assertEqual(self.response.context['book'], book)
        self.assertEqual(self.response.context['reservation_queue_position'],
                         0)
        self.assertEqual(self.response.status_code, 200)
Example #4
0
 def setUp(self):
     self.book = create_book('test_book')
     self.login()
Example #5
0
 def setUp(self):
     self.book = create_book("test-book", "")
     self.borrowing = create_borrowing('1970-01-01',
                                       book=self.book,
                                       borrower=self.user.libraryuser)
Example #6
0
    def test_detail_with_valid_id(self):
        book = create_book('test', 'test')

        self.__get_detail_response(book.id)
        self.assertEqual(self.response.context['book'], book)
        self.assertEqual(self.response.status_code, 200)
Example #7
0
    def test_list_with_a_book(self):
        book = create_book('test', 'test')

        self.__get_list_response()
        self.assertIn(book, self.response.context['books'])
        self.assertEqual(self.response.status_code, 200)
Example #8
0
 def setUp(self):
     self.book = create_book("test-book", "")
     self.reservation = create_reservation(book=self.book,
                                           reserver=self.user.libraryuser)
Example #9
0
 def setUp(self):
     self.book = create_book("test-book", "")
Example #10
0
 def setUp(self):
     self.book1 = create_book("test-book-1", borrowings_count=2)
     self.book2 = create_book("test-book-2", borrowings_count=0)
     self.book3 = create_book("test-book-3", borrowings_count=1)
Example #11
0
 def setUp(self):
     self.book1 = create_book("test-book-1", "")
     self.book2 = create_book("test-book-2", "")
     self.reserver = User.objects.create_user('test-user')