def test_pub_place_failure(self): testCodes = { 'tst': 'test' } placeRec = HathiRecord({}) placeRec.parsePubPlace('mis', testCodes) self.assertEqual(placeRec.instance.pub_place, 'mis')
def test_pub_place_success(self): testCodes = { 'tst': 'test' } placeRec = HathiRecord({}) placeRec.parsePubPlace('tst', testCodes) self.assertEqual(placeRec.instance.pub_place, 'test')
def test_build_instance(self): testInstanceRow = { 'title': 'Instance Test', 'language': 'en', 'copyright_date': '2019', 'publisher_pub_date': 'New York [2019]', 'pub_place': 'nyu' } instanceTest = HathiRecord(testInstanceRow) instanceTest.parseIdentifiers = MagicMock() instanceTest.parsePubInfo = MagicMock() instanceTest.parsePubPlace = MagicMock() instanceTest.buildInstance({}) self.assertIsInstance(instanceTest.instance, InstanceRecord) self.assertEqual(instanceTest.instance.language, 'en') self.assertEqual(instanceTest.instance.title, 'Instance Test')
def test_build_instance_no_cover(self, mockCover): testInstanceRow = { 'htid': 'test.1', 'title': 'Instance Test', 'language': 'en', 'copyright_date': '2019', 'publisher_pub_date': 'New York [2019]', 'pub_place': 'nyu', 'description': 'testing' } instanceTest = HathiRecord(testInstanceRow) instanceTest.parseIdentifiers = MagicMock() instanceTest.parsePubInfo = MagicMock() instanceTest.parsePubPlace = MagicMock() instanceTest.buildInstance({}) mockCover.assert_called_once_with() self.assertIsInstance(instanceTest.instance, InstanceRecord) self.assertEqual(instanceTest.instance.language, 'en') self.assertEqual(instanceTest.instance.title, 'Instance Test')
def test_build_instance_cover(self, mockAddItem, mockCover): testInstanceRow = { 'htid': 'test.1', 'title': 'Instance Test', 'language': 'en', 'copyright_date': '2019', 'publisher_pub_date': 'New York [2019]', 'pub_place': 'nyu', 'description': 'testing' } instanceTest = HathiRecord(testInstanceRow) instanceTest.parseIdentifiers = MagicMock() instanceTest.parsePubInfo = MagicMock() instanceTest.parsePubPlace = MagicMock() instanceTest.buildInstance({}) mockCover.assert_called_once() mockAddItem.assert_has_calls([ call( 'dates', Date, **{ 'display_date': '2019', 'date_range': '2019', 'date_type': 'copyright_date' }), call( 'links', Link, **{ 'url': 'test_url', 'media_type': 'image/jpeg', 'flags': { 'cover': True, 'temporary': True } }) ]) self.assertIsInstance(instanceTest.instance, InstanceRecord) self.assertEqual(instanceTest.instance.language, 'en')