def setUp(self): """ Creates Issue from test file fixtures/1912_11_10_bl.xml. """ self.filename = get_path(fixtures, '1912_11_10_bl.xml') self.issue = Issue(self.filename) self.issue_id = "NID123_19121110"
def setUp(self): """ Creates Archive from test file fixtures/000000037_0_1-42pgs__944211_dat_modified.zip. """ self.filename = get_path( fixtures, '000000037_0_1-42pgs__944211_dat_modified.zip') self.archive = Archive(self.filename)
def setUp(self): """ Creates Issue from test file fixtures/1912_11_10_galen.xml then retrieves first Article. """ self.filename = get_path(fixtures, '1912_11_10_galen.xml') issue = Issue(self.filename) self.article = issue.articles[0] self.article_id = 'NID123-1912-1110-0001-001' self.page_id = '0001'
def test_filename_to_object(self): """ Tests filename_to_object with valid XML file results in a tuple with an Issue. """ filename = get_path(fixtures, '1912_11_10_bl.xml') result = filename_to_object(filename) self.assertTrue(result[0] is not None) self.assertTrue(isinstance(result[0], Issue)) self.assertEqual(None, result[1])
def setUp(self): """ Creates Archive from test file fixtures/000000037_0_1-42pgs__944211_dat_modified.zip then retrieves first Document. """ source = get_path(fixtures, '000000037_0_1-42pgs__944211_dat_modified.zip') self.archive = Archive(source) self.document = self.archive[0]
def test_filename_to_object(self): """ Tests filename_to_object with valid ZIP file results in a tuple with an Archive. """ filename = get_path(fixtures, '000000037_0_1-42pgs__944211_dat_modified.zip') result = filename_to_object(filename) self.assertTrue(result[0] is not None) self.assertTrue(isinstance(result[0], Archive)) self.assertEqual(None, result[1])
def test_filename_to_object_no_such_file(self): """ Tests filename_to_object with a non-existant file results in a tuple with a filename and an error message. """ filename = get_path(fixtures, 'no-such-file.zip') result = filename_to_object(filename) self.assertTrue(result[0] is not None) self.assertTrue(isinstance(result[0], str)) self.assertEqual(filename, result[0]) self.assertTrue(result[1] is not None) self.assertTrue(isinstance(result[1], str)) self.assertTrue("No such file or directory" in str(result[1]))
def test_filename_to_object_bad_xml(self): """ Tests filename_to_object with a bad ZIP file results in a tuple with a filename and an error message. """ filename = get_path(fixtures, 'bad.zip') result = filename_to_object(filename) self.assertTrue(result[0] is not None) self.assertTrue(isinstance(result[0], str)) self.assertEqual(filename, result[0]) self.assertTrue(result[1] is not None) self.assertTrue(isinstance(result[1], str)) self.assertTrue("File is not a zip file" in str(result[1]))
def test_filename_to_object_bad_xml(self): """ Tests filename_to_object with a bad XML file results in a tuple with a filename and an error message. """ filename = get_path(fixtures, 'bad.xml') result = filename_to_object(filename) self.assertTrue(result[0] is not None) self.assertTrue(isinstance(result[0], str)) self.assertEqual(filename, result[0]) self.assertTrue(result[1] is not None) self.assertTrue(isinstance(result[1], str)) self.assertTrue("Missing 'issue' element" in str(result[1]))
def setUp(self): """ Creates Page from test file fixtures/000000037_000005.xml. """ source = get_path(fixtures, '000000037_000005.xml') self.page = Page(None, None, source)