def test_extractBookLinks_idMatch(self, matchEbook, matchIdentifier): matchEbook.return_value = False matchIdentifier.return_value = True testInst = HoldingParser('mock856', 'mockInstance') testInst.extractBookLinks() matchEbook.assert_called_once() matchIdentifier.assert_called_once()
def extractHoldingsLinks(holdings, instance): for holding in holdings: try: parse856 = HoldingParser(holding, instance) parse856.parseField() parse856.extractBookLinks() except HoldingError as err: logger.error('Unable to parse 856 field {}'.format(holding)) logger.debug(err)
def test_extractBookLinks_no_Match(self, matchEbook, matchIdentifier, createLink): matchEbook.return_value = False matchIdentifier.return_value = False createLink.return_value = 'testLink' mockInstance = MagicMock() mockInstance.links = [] testInst = HoldingParser('mock856', mockInstance) testInst.uri = 'testURI' testInst.extractBookLinks() matchEbook.assert_called_once() matchIdentifier.assert_called_once() createLink.assert_called_once_with('testURI', 'text/html') self.assertEqual(testInst.instance.links[0], 'testLink')