""" django imports """ from django.test import TestCase from django.test.client import Client from django.apps import apps """ regluit imports """ from . import models, load a_marc_record = ''' 01021cam a2200301 a 4500 3057297 19970108080513.5 960131r19761970ke b b 000 0 eng (DLC) 96109467 7 cbc orignew u ncip 19 y-gencatlg 082 done aa11 96109467 0195724135 DLC DLC DLC f------ PL8010 .F5 1976 398.2/096 20 Finnegan, Ruth H. Oral literature in Africa / Ruth Finnegan. Nairobi : Oxford University Press, 1976 (1994 printing). xviii, 558 p. : map ; 21 cm. Oxford library of African literature Originally published: Oxford : Clarendon Press, 1970. Includes index and bibliographical references (p. [522]-536). Folk literature, African History and criticism. Oral tradition Africa. ap c-GenColl PL8010 .F5 1976 Copy 1 BOOKS ''' class MarcTests(TestCase): fixtures = ['initial_data.json'] work_id=None def test_records(self): w = apps.get_model('core','Work').objects.create(title="Work 1") e = apps.get_model('core','Edition').objects.create(title=w.title,work=w) eb = apps.get_model('core','Ebook').objects.create(url = "http://example.org",edition = e,format = 'epub', rights='CC BY') mr = models.MARCRecord.objects.create(guts=a_marc_record, edition=e ) mr.direct_record_xml() mr.direct_record_mrc() mr.via_record_xml() mr.via_record_mrc() load.stub(e) w.description='test' e.set_publisher('test pub') e.publication_date = '2000' e.add_author('joe writer') id = apps.get_model('core','Identifier').objects.create(work=w,edition=e, type='isbn', value='0030839939') id = apps.get_model('core','Identifier').objects.create(work=w,edition=e, type='oclc', value='0074009772') load.stub(e) mr2 = models.MARCRecord.objects.create(guts=a_marc_record, edition=e ) mr2.load_from_file('loc') mr3 = models.MARCRecord.objects.create(guts=a_marc_record, edition=e ) mr3.load_from_file('raw') mr2.direct_record_xml() mr2.direct_record_mrc() mr2.via_record_xml() mr2.via_record_mrc()