示例#1
0
    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)
示例#2
0
 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}"))
示例#3
0
    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)
示例#4
0
 def setUp(self):
     self.book1 = BookFactory.create(name="test book1",
                                     isbn="111-1111111111")
示例#5
0
 def setUp(self):
     self.book1 = BookFactory.create()
示例#6
0
 def setUp(self):
     self.client = Client()
     self.book = BookFactory.create()
     self.user = UserFactory.create()
示例#7
0
 def setUp(self):
     self.client = Client()
     self.book1 = BookFactory.create()
     self.book2 = BookFactory.create()
示例#8
0
 def test_request_by_owner(self):
     book = BookFactory.create()
     with self.assertRaises(BookRequestError):
         book.request(book.owner)
示例#9
0
 def test_requests(self):
     user = UserFactory.create()
     book = BookFactory.create()
     request = BookRequest(book=book, requester=user)
     request.save()
     self.assertEqual(list(book.requests()), [request])