def test_generate_thumbnail_valid_multiple_pages(self):
     generator = BareResourceGenerator()
     generator.data = MagicMock(
         return_value=[
             {"type": "html", "data": "Page 1"},
             {"type": "html", "data": "Page 2", "thumbnail": True}
         ]
     )
     thumbnail_data = generator.generate_thumbnail()
     self.assertEqual(thumbnail_data["data"], "Page 2")
 def test_pdf_multiple_pages(self):
     generator = BareResourceGenerator()
     generator.data = MagicMock(
         return_value=[
             {"type": "html", "data": "Page 1"},
             {"type": "html", "data": "Page 2"},
         ]
     )
     (pdf_file, filename) = generator.pdf("Test")
     pdf = PdfFileReader(BytesIO(pdf_file))
     self.assertEqual(pdf.getNumPages(), 2)
 def test_generate_thumbnail_more_than_one_given(self):
     generator = BareResourceGenerator()
     generator.data = MagicMock(
         return_value=[
             {"type": "html", "data": "", "thumbnail": True},
             {"type": "html", "data": "", "thumbnail": True}
         ]
     )
     self.assertRaises(
         MoreThanOneThumbnailPageFoundError,
         generator.generate_thumbnail,
     )
 def test_generate_thumbnail_none_given(self):
     generator = BareResourceGenerator()
     generator.data = MagicMock(
         return_value=[
             {"type": "html", "data": ""},
             {"type": "html", "data": ""}
         ]
     )
     self.assertRaises(
         ThumbnailPageNotFoundError,
         generator.generate_thumbnail,
     )