Exemple #1
0
class TestBookFactory(unittest.TestCase):

    def setUp(self):
        self.__f = BookFactory()
        self.__epubPath = "aquarius/bookformats/tests/data/TreasureIsland.epub"
        self.__pdfpath = "aquarius/bookformats/tests/data/1.pdf"

    def test_get_non_existant_book_returns_none(self):
        b = self.__f.get_book("MyBook.rubbish")
        self.assertIsNone(b)

    def test_get_epub_calls_epub_creator(self):
        epub_creator = EpubCreator()
        epub_creator.create = Mock()
        self.__f.epub_creator = epub_creator
        self.__f.get_book(self.__epubPath)
        self.assertTrue(epub_creator.create.called)

    def test_get_pdf_calls_pdf_creator(self):
        pdf_creator = PdfCreator()
        pdf_creator.create = Mock()
        self.__f.pdf_creator = pdf_creator
        self.__f.get_book(self.__pdfpath)
        self.assertTrue(pdf_creator.create.called)

    def test_epub_creator_property(self):
        self.__f.epub_creator = "moo"
        self.assertEquals("moo", self.__f.epub_creator)

    def test_pdf_creator_property(self):
        self.__f.pdf_creator = "moo"
        self.assertEquals("moo", self.__f.pdf_creator)
Exemple #2
0
 def setUp(self):
     self.__f = BookFactory()
     self.__epubPath = "aquarius/bookformats/tests/data/TreasureIsland.epub"
     self.__pdfpath = "aquarius/bookformats/tests/data/1.pdf"