def test_books_list_logged(self): user1 = UserFactory.create() user2 = UserFactory.create() book1 = BookFactory.create(owner=user1) book2 = BookFactory.create(owner=user1) book3 = BookFactory.create(owner=user2) with self.login(user1): response = self.client.get('/books/my/') self.assertEqual(response.status_code, 200) self.assertContains(response, book1.title) self.assertContains(response, book2.title) self.assertNotContains(response, book3.title)
def setUp(self): self.num_books = 3 self.books = [] for i in range(self.num_books): self.books.append( BookFactory.create(name=f"test book{i}", isbn=f"111-111111111{i}"))
def test_delete_book(self): book = BookFactory.create() book_services.delete_book(book.id) with self.assertRaises(Book.DoesNotExist): Book.objects.get(id=book.id)
def setUp(self): self.book1 = BookFactory.create(name="test book1", isbn="111-1111111111")
def setUp(self): self.book1 = BookFactory.create()
def setUp(self): self.client = Client() self.book = BookFactory.create() self.user = UserFactory.create()
def setUp(self): self.client = Client() self.book1 = BookFactory.create() self.book2 = BookFactory.create()
def test_request_by_owner(self): book = BookFactory.create() with self.assertRaises(BookRequestError): book.request(book.owner)
def test_requests(self): user = UserFactory.create() book = BookFactory.create() request = BookRequest(book=book, requester=user) request.save() self.assertEqual(list(book.requests()), [request])