Exemplo n.º 1
0
 def test_build_medium_content_with_jats(self):
     "test building from a zip file and converting to Medium content"
     docx_file = "DIGEST 99999.zip"
     jats_file = fixture_file("elife-99999-v0.xml")
     expected_medium_content = read_fixture("medium_content_jats_99999.py")
     # build the digest object
     medium_content = medium_post.build_medium_content(
         data_path(docx_file), "tmp", self.digest_config, jats_file)
     # test assertions
     self.assertEqual(medium_content, expected_medium_content)
Exemplo n.º 2
0
 def test_build_medium_content_with_jats_and_image(self):
     "test building from a DOCX file and converting to Medium content"
     docx_file = "DIGEST 99999.docx"
     jats_file = fixture_file("elife-99999-v0.xml")
     image_file_name = "IMAGE 99999.jpeg"
     expected_medium_content = read_fixture("medium_content_jats_99999.py")
     # build the digest object
     medium_content = medium_post.build_medium_content(
         data_path(docx_file), "tmp", self.digest_config, jats_file,
         image_file_name)
     # test assertions
     self.assertEqual(medium_content, expected_medium_content)
Exemplo n.º 3
0
 def test_build_docx(self, test_data):
     "check building a DOCX from a DOCX file"
     file_name = test_data.get("file_name")
     output_dir = test_data.get("output_dir")
     digest = build_digest(data_path(file_name))
     output_file_name = output.docx_file_name(digest)
     expected_fixture = fixture_file(test_data.get("expected_docx_file"))
     # build now
     full_file_name = os.path.join(output_dir, output_file_name)
     docx_file = output.build_docx(data_path(file_name), full_file_name)
     # assert assertions
     self.assertEqual(docx_file, os.path.join(output_dir, output_file_name))
     # parse and compare the content of the built docx and the fixture docx
     output_content = parse_content(
         os.path.join(output_dir, output_file_name))
     expected_content = parse_content(expected_fixture)
     self.assertEqual(output_content, expected_content)
Exemplo n.º 4
0
 def test_build_json(self, test_data, fake_iiif_server_info):
     "check building a JSON from a DOCX file"
     fake_iiif_server_info.return_value = test_data.get("iiif_info")
     file_name = data_path(test_data.get("file_name"))
     jats_file = fixture_file(test_data.get("jats_file"))
     expected_json = read_fixture(test_data.get("expected_json_file"))
     # config
     digest_config = parse_raw_config(
         raw_config(test_data.get("config_section")))
     image_file_name = test_data.get("image_file_name")
     related = test_data.get("related")
     # build now
     json_content = json_output.build_json(file_name, "tmp", digest_config,
                                           jats_file, image_file_name,
                                           related)
     # assert assertions
     self.assertEqual(
         json_content,
         expected_json,
         "failed in {comment}".format(comment=test_data.get("comment")),
     )
Exemplo n.º 5
0
 def test_parse_jats_pub_date(self):
     "extract pub date from a JATS file"
     soup = jats.parse_jats_file(fixture_file("elife-99999-v0.xml"))
     pub_date = jats.parse_jats_pub_date(soup)
     self.assertEqual(pub_date, date_struct(2018, 8, 1))
Exemplo n.º 6
0
 def test_parse_jats_digest(self):
     "extract text content from a JATS file abstract digest"
     soup = jats.parse_jats_file(fixture_file("elife-99999-v0.xml"))
     content = jats.parse_jats_digest(soup)
     expected_content = read_fixture("elife_99999_v0_digest.py")
     self.assertEqual(content, expected_content)