class IndexerTest( unittest.TestCase ): """ Tests Indexer functions. To use: - activate the virtual environment - cd to usep_gh_handler_app directory - for all tests: python ./tests/test_indexer.py - for single test (eg): python ./tests/test_indexer.py IndexerTest.test__post_solr_update """ def setUp( self ): self.indexer = Indexer() def test__build_solr_doc(self): """ Tests bib-only inscription. """ inscription_xml_path = os.path.abspath( './tests/test_files/CA.Berk.UC.HMA.G.8-4213.xml' ) solr_xml = self.indexer._build_solr_doc( inscription_xml_path ) self.assertEqual( str, type(solr_xml) ) self.assertTrue( '<field name="title">CA.Berk.UC.HMA.G.8/4213</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_settlement">Berk</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_institution">UC</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_repository">HMA</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_idno">8/4213</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="language">grc</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) def test__post_solr_update(self): """ Tests post to solr. """ inscription_xml_path=u'./tests/test_files/CA.Berk.UC.HMA.G.8-4213.xml' solr_xml = self.indexer._build_solr_doc( inscription_xml_path ) self.assertTrue( '<int name="status">0</int>' in self.indexer._post_solr_update(solr_xml) )
class IndexerTest( unittest.TestCase ): """ Tests Indexer functions. To use: - activate the virtual environment - cd to tests directory - run python ./test_indexer.py """ def setUp( self ): self.indexer = Indexer( log ) def test__build_solr_doc(self): """ Tests bib-only inscription. """ inscription_xml_path=u'./test_files/CA.Berk.UC.HMA.G.8-4213.xml' solr_xml = self.indexer._build_solr_doc( inscription_xml_path ) self.assertEqual( unicode, type(solr_xml) ) self.assertTrue( '<field name="title">CA.Berk.UC.HMA.G.8/4213</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_settlement">Berk</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_institution">UC</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_repository">HMA</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="msid_idno">8/4213</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) self.assertTrue( '<field name="language">grc</field>' in solr_xml, 'solr_xml, ```%s```' % solr_xml ) def test__post_solr_update(self): """ Tests post to solr. """ inscription_xml_path=u'./test_files/CA.Berk.UC.HMA.G.8-4213.xml' solr_xml = self.indexer._build_solr_doc( inscription_xml_path ) self.assertEqual( '<int name="status">0</int>', self.indexer._post_solr_update(solr_xml) )
def setUp( self ): self.indexer = Indexer()