def setUp(self): self.client = APIClient() self.book = { "id": 1, "isbn": "0", "title": "0", "author": "0", "publication_yr": "0", "publisher": "0", "image_url_s": "http://www.google.com", "image_url_m": "http://www.google.com", "image_url_l": "http://www.google.com", } Book(**self.book).save()
def create_demo_user_and_book(self): self.new_book = { "isbn": "0", "title": "0", "author": "0", "publication_yr": "0", "publisher": "0", "image_url_s": "0", "image_url_m": "0", "image_url_l": "0", } self.new_user = {"user_id": "0", "location": "usa", "age": "25"} Book(**self.new_book).save() User(**self.new_user).save()
def create_demo_user_book_rating(self): self.new_book = { "isbn": "0", "title": "0", "author": "0", "publication_yr": "0", "publisher": "0", "image_url_s": "0", "image_url_m": "0", "image_url_l": "0", } self.new_user = {"user_id": "0", "location": "usa", "age": "25"} Book(**self.new_book).save() User(**self.new_user).save() self.new_rating = { "user_id": User.objects.get(user_id="0"), "isbn": Book.objects.get(isbn="0"), "rating": "5" } Rating(**self.new_rating).save()
def test_can_create_new_book(self): old_count = Book.objects.count() Book(**self.book).save() new_count = Book.objects.count() self.assertEqual(old_count + 1, new_count)