def test_all_options(self):
     generator = BareResourceGenerator()
     normal_options = generator.get_options()
     local_options = generator.get_local_options()
     # Order should be normal options, then local options
     options_order = list(normal_options) + list(local_options)
     self.assertListEqual(options_order, list(generator.options))
     for option in local_options.values():
         self.assertIsInstance(option, ResourceParameter)
 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,
     )
 def test_generate_thumbnail_valid_single_page(self):
     generator = BareResourceGenerator()
     thumbnail_data = generator.generate_thumbnail()
     self.assertEqual(thumbnail_data["data"], "Page 1")
 def test_pdf_single_page(self):
     generator = BareResourceGenerator()
     (pdf_file, filename) = generator.pdf("Test")
     pdf = PdfFileReader(BytesIO(pdf_file))
     self.assertEqual(pdf.getNumPages(), 1)