示例#1
0
 def setUp(self):
     """ Runs initialization. """
     self.builder = HoldingsDctBuilder(
         settings_app.TEST_FROM_RAPID_UTF8_FILEPATH, )
     p = ProcessorTracker(current_status='not_yet_processed',
                          recent_processing=json.dumps(
                              {
                                  'percent_done': 'N/A',
                                  'time_left': 'N/A',
                                  'recent_times_per_record': [],
                                  'average_time_per_record': 0
                              },
                              sort_keys=True,
                              indent=2))
     p.save()
示例#2
0
 def setUp( self ):
     """ Runs initialization. """
     self.builder = HoldingsDctBuilder(
         settings_app.TEST_FROM_RAPID_UTF8_FILEPATH,
         )
     p = ProcessorTracker(
         current_status='not_yet_processed',
         recent_processing=json.dumps(
             {'percent_done': 'N/A', 'time_left': 'N/A', 'recent_times_per_record': [], 'average_time_per_record': 0 }, sort_keys=True, indent=2 )
         )
     p.save()
示例#3
0
class HoldingsDctBuilderTest( TestCase ):
    """ Tests lib.processor.HoldingsDctBuilder """

    def setUp( self ):
        """ Runs initialization. """
        self.builder = HoldingsDctBuilder(
            settings_app.TEST_FROM_RAPID_UTF8_FILEPATH,
            )
        p = ProcessorTracker(
            current_status='not_yet_processed',
            recent_processing=json.dumps(
                {'percent_done': 'N/A', 'time_left': 'N/A', 'recent_times_per_record': [], 'average_time_per_record': 0 }, sort_keys=True, indent=2 )
            )
        p.save()

    def test__build_holdings_elements( self):
        """ Checkds dct-entry prepared from row data.
            Returned data definition: ( key, issn, title, location, building, callnumber, year ) """
        row = [u'RBN', u'Main Library', u'sci', u'1-SIZE TN24.T2 A2', u'Information circular / State of Tennessee Department of Conservation, Division of Geology', u'Print', u'0492-7079', u'ISSN', u'', u'', u'1971']
        self.assertEqual(
            (u'04927079Sciences1SIZETN24T2A2', u'0492-7079', u'Information circular / State of Tennessee Department of Conservation, Division of Geology', u'sci', u'Sciences', u'1-SIZE TN24.T2 A2', u'1971'),
            self.builder._build_holdings_elements(row)
            )



    # def test__make_title__unicode( self ):
    #     """ Checks api lookup. """
    #     issn = '0259-3750'  # 'Dong Wu fa lü xue bao = Soochow law review'
    #     initial_title = 'Dong Wu fa l� xue bao = Soochow law review'
    #     self.assertEqual( 'Dong Wu fa lü xue bao = Soochow law review', self.builder._make_title(issn, initial_title) )

    # def test__make_title__no_blacklight_match( self ):
    #     """ No blacklight match; shouldn't need to be looked up though. """
    #     issn = '0146-4787'  # 'SIAM journal on control and optimization'
    #     initial_title = 'SIAM journal on control and optimization'
    #     self.assertEqual( 'SIAM journal on control and optimization', self.builder._make_title(issn, initial_title) )



    def test__build_url( self ):
        """ Checks url built from title. """
        title = '5th IEEE International Workshop on Object-Orientation in Operating Systems'
        self.assertEqual(
            'https://search.library.brown.edu/catalog/?q=5th+IEEE+International+Workshop+on+Object-Orientation+in+Operating+Systems&f%5Bformat%5D%5B%5D=Periodical+Title',
            self.builder._build_url( title )
            )

    def test__build_url_nonascii( self ):
        """ Checks temporary handling of non-ascii text. """
        title = 'Zeitschrift für anorganische und allgemeine Chemie'
        self.assertEqual(
            'https://search.library.brown.edu/catalog/?q=Zeitschrift+f%C3%BCr+anorganische+und+allgemeine+Chemie&f%5Bformat%5D%5B%5D=Periodical+Title',
            self.builder._build_url( title )
            )

    def test__build_holdings_dct( self ):
        """ Tests filtering and parsing of records for easyAccess db. """
        # pprint.pprint( self.builder.build_holdings_dct() )
        self.assertEqual( {
            u'00029483Annex1SIZEGN1A55': {
                u'building': u'Annex',
                u'call_number': u'1-SIZE GN1 .A55',
                u'issn': u'0002-9483',
                u'location': u'qs',
                u'title': u'American journal of physical anthropology',
                u'url': u'https://search.library.brown.edu/catalog/?q=American+journal+of+physical+anthropology&f%5Bformat%5D%5B%5D=Periodical+Title',
                u'years': [u'1919']},
            u'00029629SciencesR11A6': {
                u'building': u'Sciences',
                u'call_number': u'R11 .A6',
                u'issn': u'0002-9629',
                u'location': u'sci',
                u'title': u'The American journal of the medical sciences',
                u'url': u'https://search.library.brown.edu/catalog/?q=The+American+journal+of+the+medical+sciences&f%5Bformat%5D%5B%5D=Periodical+Title',
                u'years': [u'1926', u'1928']},
            u'0022197XRockJX1C58': {
                u'building': u'Rock',
                u'call_number': u'JX1 .C58',
                u'issn': u'0022-197X',
                u'location': u'rsmch',
                u'title': u'Journal of international affairs',
                u'url': u'https://search.library.brown.edu/catalog/?q=Journal+of+international+affairs&f%5Bformat%5D%5B%5D=Periodical+Title',
                u'years': [u'1991', u'1992']},
            u'00318701SciencesTR1P58': {
                u'building': u'Sciences',
                u'call_number': u'TR1 .P58',
                u'issn': u'0031-8701',
                u'location': u'sci',
                u'title': u'Photographic abstracts',
                u'url': u'https://search.library.brown.edu/catalog/?q=Photographic+abstracts&f%5Bformat%5D%5B%5D=Periodical+Title',
                u'years': [u'1962']},
            u'00802042AnnexQP1E7': {
                u'building': u'Annex',
                u'call_number': u'QP1 .E7',
                u'issn': u'0080-2042',
                u'location': u'qs',
                u'title': u'Ergebnisse der Physiologie biologischen Chemie und experimentellen Pharmakologie. Reviews of physiology, biochemistry, and experimental pharmacology',
                u'url': u'https://search.library.brown.edu/catalog/?q=Ergebnisse+der+Physiologie+biologischen+Chemie+und+experimentellen+Pharmakologie.+Reviews+of+physiology%2C+biochemistry%2C+and+experimental+pharmacology&f%5Bformat%5D%5B%5D=Periodical+Title',
                u'years': [u'1937', u'1938']},
            u'04927079Sciences1SIZETN24T2A2': {
                u'building': u'Sciences',
                u'call_number': u'1-SIZE TN24.T2 A2',
                u'issn': u'0492-7079',
                u'location': u'sci',
                u'title': u'Information circular / State of Tennessee Department of Conservation, Division of Geology',
                u'url': u'https://search.library.brown.edu/catalog/?q=Information+circular+%2F+State+of+Tennessee+Department+of+Conservation%2C+Division+of+Geology&f%5Bformat%5D%5B%5D=Periodical+Title',
                u'years': [u'1971']}},
            self.builder.build_holdings_dct()
            )
示例#4
0
class HoldingsDctBuilderTest(TestCase):
    """ Tests lib.processor.HoldingsDctBuilder """
    def setUp(self):
        """ Runs initialization. """
        self.builder = HoldingsDctBuilder(
            settings_app.TEST_FROM_RAPID_UTF8_FILEPATH, )
        p = ProcessorTracker(current_status='not_yet_processed',
                             recent_processing=json.dumps(
                                 {
                                     'percent_done': 'N/A',
                                     'time_left': 'N/A',
                                     'recent_times_per_record': [],
                                     'average_time_per_record': 0
                                 },
                                 sort_keys=True,
                                 indent=2))
        p.save()

    def test__build_holdings_elements(self):
        """ Checkds dct-entry prepared from row data.
            Returned data definition: ( key, issn, title, location, building, callnumber, year ) """
        row = [
            u'RBN', u'Main Library', u'sci', u'1-SIZE TN24.T2 A2',
            u'Information circular / State of Tennessee Department of Conservation, Division of Geology',
            u'Print', u'0492-7079', u'ISSN', u'', u'', u'1971'
        ]
        self.assertEqual((
            u'04927079Sciences1SIZETN24T2A2', u'0492-7079',
            u'Information circular / State of Tennessee Department of Conservation, Division of Geology',
            u'sci', u'Sciences', u'1-SIZE TN24.T2 A2', u'1971'),
                         self.builder._build_holdings_elements(row))

    # def test__make_title__unicode( self ):
    #     """ Checks api lookup. """
    #     issn = '0259-3750'  # 'Dong Wu fa lü xue bao = Soochow law review'
    #     initial_title = 'Dong Wu fa l� xue bao = Soochow law review'
    #     self.assertEqual( 'Dong Wu fa lü xue bao = Soochow law review', self.builder._make_title(issn, initial_title) )

    # def test__make_title__no_blacklight_match( self ):
    #     """ No blacklight match; shouldn't need to be looked up though. """
    #     issn = '0146-4787'  # 'SIAM journal on control and optimization'
    #     initial_title = 'SIAM journal on control and optimization'
    #     self.assertEqual( 'SIAM journal on control and optimization', self.builder._make_title(issn, initial_title) )

    def test__build_url(self):
        """ Checks url built from title. """
        title = '5th IEEE International Workshop on Object-Orientation in Operating Systems'
        self.assertEqual(
            'https://search.library.brown.edu/catalog/?q=5th+IEEE+International+Workshop+on+Object-Orientation+in+Operating+Systems&f%5Bformat%5D%5B%5D=Periodical+Title',
            self.builder._build_url(title))

    def test__build_url_nonascii(self):
        """ Checks temporary handling of non-ascii text. """
        title = 'Zeitschrift für anorganische und allgemeine Chemie'
        self.assertEqual(
            'https://search.library.brown.edu/catalog/?q=Zeitschrift+f%C3%BCr+anorganische+und+allgemeine+Chemie&f%5Bformat%5D%5B%5D=Periodical+Title',
            self.builder._build_url(title))

    def test__build_holdings_dct(self):
        """ Tests filtering and parsing of records for easyAccess db. """
        # pprint.pprint( self.builder.build_holdings_dct() )
        self.assertEqual(
            {
                u'00029483Annex1SIZEGN1A55': {
                    u'building': u'Annex',
                    u'call_number': u'1-SIZE GN1 .A55',
                    u'issn': u'0002-9483',
                    u'location': u'qs',
                    u'title': u'American journal of physical anthropology',
                    u'url':
                    u'https://search.library.brown.edu/catalog/?q=American+journal+of+physical+anthropology&f%5Bformat%5D%5B%5D=Periodical+Title',
                    u'years': [u'1919']
                },
                u'00029629SciencesR11A6': {
                    u'building': u'Sciences',
                    u'call_number': u'R11 .A6',
                    u'issn': u'0002-9629',
                    u'location': u'sci',
                    u'title': u'The American journal of the medical sciences',
                    u'url':
                    u'https://search.library.brown.edu/catalog/?q=The+American+journal+of+the+medical+sciences&f%5Bformat%5D%5B%5D=Periodical+Title',
                    u'years': [u'1926', u'1928']
                },
                u'0022197XRockJX1C58': {
                    u'building': u'Rock',
                    u'call_number': u'JX1 .C58',
                    u'issn': u'0022-197X',
                    u'location': u'rsmch',
                    u'title': u'Journal of international affairs',
                    u'url':
                    u'https://search.library.brown.edu/catalog/?q=Journal+of+international+affairs&f%5Bformat%5D%5B%5D=Periodical+Title',
                    u'years': [u'1991', u'1992']
                },
                u'00318701SciencesTR1P58': {
                    u'building': u'Sciences',
                    u'call_number': u'TR1 .P58',
                    u'issn': u'0031-8701',
                    u'location': u'sci',
                    u'title': u'Photographic abstracts',
                    u'url':
                    u'https://search.library.brown.edu/catalog/?q=Photographic+abstracts&f%5Bformat%5D%5B%5D=Periodical+Title',
                    u'years': [u'1962']
                },
                u'00802042AnnexQP1E7': {
                    u'building': u'Annex',
                    u'call_number': u'QP1 .E7',
                    u'issn': u'0080-2042',
                    u'location': u'qs',
                    u'title':
                    u'Ergebnisse der Physiologie biologischen Chemie und experimentellen Pharmakologie. Reviews of physiology, biochemistry, and experimental pharmacology',
                    u'url':
                    u'https://search.library.brown.edu/catalog/?q=Ergebnisse+der+Physiologie+biologischen+Chemie+und+experimentellen+Pharmakologie.+Reviews+of+physiology%2C+biochemistry%2C+and+experimental+pharmacology&f%5Bformat%5D%5B%5D=Periodical+Title',
                    u'years': [u'1937', u'1938']
                },
                u'04927079Sciences1SIZETN24T2A2': {
                    u'building': u'Sciences',
                    u'call_number': u'1-SIZE TN24.T2 A2',
                    u'issn': u'0492-7079',
                    u'location': u'sci',
                    u'title':
                    u'Information circular / State of Tennessee Department of Conservation, Division of Geology',
                    u'url':
                    u'https://search.library.brown.edu/catalog/?q=Information+circular+%2F+State+of+Tennessee+Department+of+Conservation%2C+Division+of+Geology&f%5Bformat%5D%5B%5D=Periodical+Title',
                    u'years': [u'1971']
                }
            }, self.builder.build_holdings_dct())