def test_delete(self):
     loader = TitleLoader()
     loader.load_file(abs_filename('./test-data/title-delete.xml'))
     self.assertEqual(loader.records_deleted, 1)
     self.assertEqual(loader.records_processed, 2)
     self.assertRaises(Title.DoesNotExist, Title.objects.get,
                       lccn='sn83030846')
 def test_vague_dates(self):
     loader = TitleLoader()
     filename = abs_filename('./test-data/bib-with-vague-dates.xml')
     loader.load_file(filename)
     t = Title.objects.get(lccn='00062183')
     self.assertEqual(t.start_year_int, 1900)
     self.assertEqual(t.end_year_int, 1999)
Exemplo n.º 3
0
    def test_holdings(self):
        # title data
        titlexml = os.path.join(os.path.dirname(chronam.core.__file__),
                                'test-data', 'title.xml')

        # holdings data
        holdingsxml = os.path.join(os.path.dirname(chronam.core.__file__),
                                   'test-data', 'holdings.xml')

        # first need to load the titles so we can link against them
        title_loader = TitleLoader()
        title_loader.load_file(titlexml)

        # now load the holdings from the same file
        holding_loader = HoldingLoader()
        holding_loader.load_file(holdingsxml)

        # fetch the title and see that holdings are attached
        t = Title.objects.get(lccn='sn83030846')
        holdings = list(t.holdings.all())
        self.assertEqual(len(holdings), 10)
        h = holdings[1]
        self.assertEqual(h.institution.name, 'Colgate Univ')
        self.assertEqual(h.type, 'Original')
        self.assertEqual(h.description, '<1876:5:18> <1884:1:10> <1885:9:3>')
        self.assertEqual(h.description_as_list(),
                         [u'<1876:5:18>', u'<1884:1:10>', u'<1885:9:3>'])
        self.assertEqual(str(h.last_updated), '01/1992')
Exemplo n.º 4
0
    def test_holdings(self):
        # title data
        titlexml = os.path.join(os.path.dirname(chronam.core.__file__), 
            'test-data', 'title.xml')

        # holdings data
        holdingsxml = os.path.join(os.path.dirname(chronam.core.__file__), 
            'test-data', 'holdings.xml')

        # first need to load the titles so we can link against them
        title_loader = TitleLoader()
        title_loader.load_file(titlexml)

        # now load the holdings from the same file
        holding_loader = HoldingLoader()
        holding_loader.load_file(holdingsxml)
        
        # fetch the title and see that holdings are attached
        t = Title.objects.get(lccn='sn83030846')
        holdings = list(t.holdings.all())
        self.assertEqual(len(holdings), 10)
        h = holdings[1]
        self.assertEqual(h.institution.name, 'Colgate Univ')
        self.assertEqual(h.type, 'Original')
        self.assertEqual(h.description, '<1876:5:18> <1884:1:10> <1885:9:3>')
        self.assertEqual(h.description_as_list(), [u'<1876:5:18>', u'<1884:1:10>', u'<1885:9:3>'])
        self.assertEqual(str(h.last_updated), '01/1992')
 def setUp(self):
     # wipe the slate clean
     Title.objects.all().delete()
     # load a title
     loader = TitleLoader()
     titlexml = os.path.join(os.path.dirname(chronam.core.__file__),
         'test-data', 'title.xml')
     loader.load_file(titlexml)
 def test_etitle(self):
     # we shouldn't load in [electronic resource] records for 
     # chronicling america titles, since they muddle up search results
     # https://rdc.lctl.gov/trac/ndnp/ticket/375
     loader = TitleLoader()
     loader.load_file(abs_filename('./test-data/etitle.xml'))
     self.assertRaises(Title.DoesNotExist, Title.objects.get,
                       lccn='2008264012')
 def test_oclc_num(self):
     t = TitleLoader()
     t.load_file(abs_filename('./test-data/sn86069873.xml'))
     t = Title.objects.get(lccn='sn86069873')
     self.assertEqual(t.oclc, '13528482')
 def test_rda_place_of_publication(self):
     loader = TitleLoader()
     loader.load_file(abs_filename('./test-data/rda.xml'))
     self.assertEqual(loader.records_processed, 1)
     t = Title.objects.get(lccn='sn84022687')
     self.assertEqual(t.place_of_publication, 'Montpelier, Vt.')
Exemplo n.º 9
0
 def test_rda_place_of_publication(self):
     loader = TitleLoader()
     loader.load_file(abs_filename('./test-data/rda.xml'))
     self.assertEqual(loader.records_processed, 1)
     t = Title.objects.get(lccn='sn84022687')
     self.assertEqual(t.place_of_publication, 'Montpelier, Vt.')