def setUp(self): self.borges = Author("Jorge Luis Borges", "AR") self.poe = Author('Edgar Allan Poe', 'US') self.ficciones = Book("Ficciones", author=self.borges) self.aleph = Book("The Aleph", author=self.borges) self.raven = Book("The Raven", author=self.poe)
def test_author_creation(self): borges = Author("Jorge Luis Borges", "AR") poe = Author('Edgar Allan Poe', 'US') self.assertEqual(borges.name, "Jorge Luis Borges") self.assertEqual(borges.nationality, "AR") self.assertEqual(poe.name, "Edgar Allan Poe") self.assertEqual(poe.nationality, "US")
def test_author_creation(): borges = Author("Jorge Luis Borges", "AR") poe = Author('Edgar Allan Poe', 'US') assert borges.name == "Jorge Luis Borges" assert borges.nationality == "AR" assert poe.name == "Edgar Allan Poe" assert poe.nationality == "US"
def fixtures(): fix = Namespace() fix.borges = Author("Jorge Luis Borges", "AR") fix.poe = Author('Edgar Allan Poe', 'US') fix.ficciones = Book("Ficciones", author=fix.borges) fix.aleph = Book("The Aleph", author=fix.borges) fix.raven = Book("The Raven", author=fix.poe) return fix
def deploy(): db.drop_all() db.create_all() jane = Author( name='Jane Austen', intro= 'Jane Austen was an English novelist known primarily for her six major novels, which interpret, critique and comment upon the British landed gentry at the end of the 18th century.' ) jk = Author( name='J. K. Rowling', intro= 'Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Potter fantasy series. ' ) book1 = Book( name='Pride and Prejudice', year='1813', author_id=1, summary= 'Pride and Prejudice is a romance novel by Jane Austen, first published in 1813. The story charts the emotional development of the protagonist, Elizabeth Bennet, who learns the error of making hasty judgments and comes to appreciate the difference between the superficial and the essential. The comedy of the writing lies in the depiction of manners, education, marriage, and money in the British Regency.' ) book2 = Book( name='Harry Potter and the Chamber of Secrets', year='1998', author_id=2, summary= 'Harry Potter and the Chamber of Secrets is a fantasy novel written by British author J. K. Rowling and the second novel in the Harry Potter series. The plot follows his second year at Hogwarts School of Witchcraft and Wizardry, during which a series of messages on the walls of the school corridors warn that the "Chamber of Secrets" has been opened and that the "heir of Slytherin" would kill all pupils who do not come from all-magical families. These threats are found after attacks which leave residents of the school "petrified" (frozen like stone). Throughout the year, Harry and his friends Ron and Hermione investigate the attacks.' ) book3 = Book( name='Harry Potter and the Goblet of Fire', year='2001', author_id=2, summary= 'Harry Potter and the Goblet of Fire is a fantasy novel written by British author J. K. Rowling and the fourth novel in the Harry Potter series. It follows Harry Potter, a wizard in his fourth year at Hogwarts School of Witchcraft and Wizardry and the mystery surrounding the entry of his name into the Triwizard Tournament, in which he is forced to compete.' ) book4 = Book( name='Harry Potter and the Half-Blood Prince', year='2005', author_id=2, summary= 'Harry Potter and the Half-Blood Prince is a fantasy novel written by British author J. K. Rowling and the sixth and penultimate novel in the Harry Potter series. Set during protagonist his sixth year at Hogwarts, the novel explores the past of his nemesis, Lord Voldemort, and his preparations for the final battle against Voldemort alongside his headmaster and mentor Albus Dumbledore.' ) db.session.add(jane) db.session.add(jk) db.session.add(book1) db.session.add(book2) db.session.add(book3) db.session.add(book4) db.session.commit()
def deploy(): db.drop_all() db.create_all() jane = Author( name='Jane Austen', intro= 'Jane Austen was an English novelist known primarily for her six major novels, got the British landed gentry at the end of the 18th century.' ) yh = Author( name='Yu Hua', intro= 'Yu Hua is a Chinese author, born April 3, 1960 in Hangzhou, Zhejiang province.' ) scott = Author( name='F. Scott Fitzgerald', intro= 'an American novelist and short story writer, whose works illustrate the Jazz Age' ) book1 = Book( name='Pride and Prejudice', year='1813', author_id=1, summary= 'A romance novel by Jane Austen, first published in 1813. The story charts the emotional development of the protagonist, Elizabeth Bennet, who learns the error of making hasty judgments and comes to appreciate the difference between the superficial and the essential. The comedy of the writing lies in the depiction of manners, education, marriage, and money in the British Regency.' ) book2 = Book( name='To Live', year='1993', author_id=2, summary= 'To Live is one of the most representative work by Yu Hua. The story begins with the narrator traveling through the countryside to collect folk songs and local legends and starting to hear a old peasant talking about his experiences, which encompass many significant historical events in China including the Great Leap Forward, Three-anti and Five-anti Campaigns and Cultural Revolution. ' ) book5 = Book( name='The Great Gatsby', year='1922', author_id=3, summary= 'The Great Gatsby is a 1925 novel written by American author F. Scott Fitzgerald that follows a cast of characters living in the fictional town of West Egg on prosperous Long Island in the summer of 1922. ' ) db.session.add(yh) db.session.add(jk) db.session.add(scott) db.session.add(book1) db.session.add(book2) db.session.add(book5) db.session.commit()
def test_book_creation(self): borges = Author("Jorge Luis Borges", "AR") poe = Author('Edgar Allan Poe', 'US') ficciones = Book("Ficciones", author=borges) aleph = Book("The Aleph", author=borges) raven = Book("The Raven", author=poe) self.assertEqual(ficciones.title, "Ficciones") self.assertEqual(ficciones.author, borges) self.assertEqual(aleph.title, "The Aleph") self.assertEqual(aleph.author, borges) self.assertEqual(raven.title, "The Raven") self.assertEqual(raven.author, poe)
def test_book_creation(): borges = Author("Jorge Luis Borges", "AR") poe = Author('Edgar Allan Poe', 'US') ficciones = Book("Ficciones", author=borges) aleph = Book("The Aleph", author=borges) raven = Book("The Raven", author=poe) assert ficciones.title == "Ficciones" assert ficciones.author == borges assert aleph.title == "The Aleph" assert aleph.author == borges assert raven.title == "The Raven" assert raven.author == poe
def test_search_bookstore_by_book_author(self): store = Bookstore("Rmotr's bookstore") store.add_book(self.ficciones) store.add_book(self.aleph) austen = Author('Jane Austen', 'UK') results = store.search_books(author=austen) self.assertEqual(results, []) results = store.search_books(author=self.borges) self.assertEqual(results, [self.ficciones, self.aleph]) results = store.search_books(author=self.poe) self.assertEqual(results, []) store.add_book(self.raven) results = store.search_books(author=self.poe) self.assertEqual(results, [self.raven])
def test_search_bookstore_by_book_author(fixtures): store = Bookstore("Rmotr's bookstore") store.add_book(fixtures.ficciones) store.add_book(fixtures.aleph) austen = Author('Jane Austen', 'UK') results = store.search_books(author=austen) assert results == [] results = store.search_books(author=fixtures.borges) assert results == [fixtures.ficciones, fixtures.aleph] results = store.search_books(author=fixtures.poe) assert results == [] store.add_book(fixtures.raven) results = store.search_books(author=fixtures.poe) assert results == [fixtures.raven]
def test_get_books_from_author(self): borges = Author("Jorge Luis Borges", "AR") ficciones = Book("Ficciones", author=borges) aleph = Book("The Aleph", author=borges) self.assertEqual(borges.get_books(), [ficciones, aleph])
def test_get_books_from_author(): borges = Author("Jorge Luis Borges", "AR") ficciones = Book("Ficciones", author=borges) aleph = Book("The Aleph", author=borges) assert borges.get_books() == [ficciones, aleph]