def test_preparing_books_from_imported_cards_without_duplicates(self): catalog = fake_catalog(CATALOG_PROPER_HEADER, 10) self.catalog._import_cards(catalog) self.catalog._prepare_authors() self.catalog._prepare_books() self.assertEqual(Book.select().count(), 10) self.assertEqual(Author.select().count(), 10) self.assertEqual(BookAuthors.select().count(), 10)
def test_preparing_index_from_imported_cards_with_author_duplicates(self): catalog = fake_catalog_with_author_duplicates(CATALOG_PROPER_HEADER, 10) self.catalog._import_cards(catalog) self.catalog._prepare_authors() self.catalog._prepare_books() self.catalog._prepare_card_index() self.assertLess(Book.select().count(), 10) self.assertLess(Author.select().count(), 10) self.assertEqual(BookAuthors.select().count(), 10) self.assertEqual(CardIndex.select().count(), 10)
def setUp(self): super().setUp() self.books = [] for _ in range(5): book = Book(book_id=fake.random.randint(100, 1000000), title=fake.sentence(), subtitle=fake.sentence(), year=fake.random.randint(1990, 2020), series=fake.sentence(), language="ru") author = Author(author_id=fake.random.randint(100, 1000000), first_name=fake.first_name(), last_name=fake.last_name()) book.authors.add(author) self.response = SearchResponse(self.books)
def test_create_book(self): book_inserted = Book(**fake_book()) self.assertEqual(book_inserted.save(), 1) book_selected = Book.get(Book.book_id == book_inserted.book_id) self.assertEqual(book_inserted, book_selected)