def setUp(self): """ Sets Up sample Records for Adding Field Scenario.""" GenericBibUploadTest.setUp(self) self.data = init_test_records() # Rev 2 Update -- Rev2 + tag 300 self.rev2_add_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHOPHO</subfield> </datafield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">100P</subfield> </datafield> </record>""" # Rev 2 Update -- Rev2 + tag 100* self.rev2_add_sim_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="100" ind1="C" ind2="0"> <subfield code="a">Devel, D</subfield> <subfield code="u">FUZZY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHOPHO</subfield> </datafield> </record>""" # Record Patch -- Ouput For a New Field self.patch = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag="300" ind1=" " ind2=" "> <subfield code="a">100P</subfield> </datafield> </record>""" # Record Patch -- Outpute for a New Identical Field self.patch_identical_field = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="100" ind1="C" ind2="0"> <subfield code="a">Devel, D</subfield> <subfield code="u">FUZZY</subfield> </datafield> </record>""" self.rev2_add_field = self.rev2_add_field.replace("123456789", self.data["id"][0]) self.rev2_add_field = self.rev2_add_field.replace("20110101000000.0", self.data["rev2"][1]) self.rev2_add_sim_field = self.rev2_add_sim_field.replace("123456789", self.data["id"][0]) self.rev2_add_sim_field = self.rev2_add_sim_field.replace("20110101000000.0", self.data["rev2"][1]) self.patch = self.patch.replace("123456789", self.data["id"][0]) self.patch_identical_field = self.patch_identical_field.replace("123456789", self.data["id"][0])
def tearDown(self): GenericBibUploadTest.tearDown(self) if os.path.exists(self.callback_result_path): os.remove(self.callback_result_path) current_task = get_last_taskid() if current_task != self.last_taskid: delete_task(current_task)
def setUp(self): """ Sets up sample records for Modified Fields Scenarios.""" GenericBibUploadTest.setUp(self) self.data = init_test_records() # Rev 2 Update -- Rev2 ~ tag 970 Modified self.rev2_mod_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PZOOPZOO</subfield> </datafield> </record>""" # Rev 3 MOdified = Rev3 ~ Tag 970 modified - Conflict with Rev2-Update self.rev3_mod = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHYPHY</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" # Rev 3 MOdified = Rev3 ~ Tag 970 Deleted - Conflict with Rev2-Update self.rev3_deleted = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" self.rev2_mod_field = self.rev2_mod_field.replace("123456789", self.data["id"][0]) self.rev2_mod_field = self.rev2_mod_field.replace("20110101000000.0", self.data["rev2"][1]) self.rev3_mod = self.rev3_mod.replace("123456789", self.data["id"][0]) self.rev3_mod = self.rev3_mod.replace("20110101000000.0", self.data["rev3"][1]) self.rev3_deleted = self.rev3_deleted.replace("123456789", self.data["id"][0]) self.rev3_deleted = self.rev3_deleted.replace("20110101000000.0", self.data["rev3"][1])
def setUp(self): GenericBibUploadTest.setUp(self) self.callback_result_path = os.path.join(CFG_TMPDIR, 'robotupload.json') self.callback_url = CFG_SITE_URL + '/httptest/post2?%s' % urlencode({ "save": self.callback_result_path}) self.oracle_callback_url = CFG_SITE_URL + '/httptest/oraclefriendly?%s' % urlencode({ "save": self.callback_result_path}) if os.path.exists(self.callback_result_path): os.remove(self.callback_result_path) self.last_taskid = get_last_taskid() self.marcxml = """\ <record> <datafield tag="100" ind1=" " ind2=" "> <subfield code="a">Doe, John</subfield> </datafield> <datafield tag="245" ind1=" " ind2=" "> <subfield code="a">The title</subfield> </datafield> <datafield tag="980" ind1=" " ind2=" "> <subfield code="a">TEST</subfield> </datafield> </record>""" self.req = urllib2.Request(CFG_SITE_URL + '/batchuploader/robotupload/insert') self.req.add_header('Content-Type', 'application/marcxml+xml') self.req.add_header('User-Agent', make_user_agent_string('BatchUploader')) self.req.add_data(self.marcxml) self.req_callback = urllib2.Request(CFG_SITE_URL + '/batchuploader/robotupload/insert?' + urlencode({ 'callback_url': self.callback_url})) self.req_callback.add_header('Content-Type', 'application/marcxml+xml') self.req_callback.add_header('User-Agent', 'invenio_webupload') self.req_callback.add_data(self.marcxml) self.nonce_url = CFG_SITE_URL + '/batchuploader/robotupload/insert?' + urlencode({ 'nonce': "1234", 'callback_url': self.callback_url}) self.req_nonce = urllib2.Request(self.nonce_url) self.req_nonce.add_header('Content-Type', 'application/marcxml+xml') self.req_nonce.add_header('User-Agent', 'invenio_webupload') self.req_nonce.add_data(self.marcxml) self.oracle_url = CFG_SITE_URL + '/batchuploader/robotupload/insert?' + urlencode({ 'special_treatment': 'oracle', 'callback_url': self.oracle_callback_url}) self.req_oracle = urllib2.Request(self.oracle_url) self.req_oracle.add_header('Content-Type', 'application/marcxml+xml') self.req_oracle.add_header('User-Agent', 'invenio_webupload') self.req_oracle.add_data(self.marcxml) self.legacy_url = CFG_SITE_URL + '/batchuploader/robotupload'
def setUp(self): """ Set up all the sample records required for Test Cases.""" GenericBibUploadTest.setUp(self) self.data = init_test_records() # Rev 2 Update -- Rev2 ~ tag 970 Modified self.rev2_modified = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PZOOPZOO</subfield> </datafield> </record>""" self.rev2_modified = self.rev2_modified.replace("123456789", self.data["id"][0])
def setUp(self): """ Set up all the sample records required for Test Cases.""" GenericBibUploadTest.setUp(self) # Rev 1 -- To Insert self.rev1 = """<record> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="870" ind1=" " ind2=" "> <subfield code="a">3719PZOOPZOO</subfield> </datafield> </record>""" # Rev 1 Modified -- To Replace self.rev1_modified = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="870" ind1=" " ind2=" "> <subfield code="a">3719PZOOPZOO_modified</subfield> </datafield> </record>""" # Rev 2 Update -- Rev2 self.rev2 = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="870" ind1=" " ind2=" "> <subfield code="a">3719PZOOPZOO</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" # Rev 2 MOdified -- Rev2 - 870 modified self.rev2_modified = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="870" ind1=" " ind2=" "> <subfield code="a">3719PZOOPZOO_another modification</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" self.final_xm = """<record>
def setUp(self): """ Sets up sample records for Modified Fields Scenarios.""" GenericBibUploadTest.setUp(self) # Rev 1 -- 100-1/100-2/100-3 self.rev1 = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester1, T</subfield> <subfield code="u">DESY1</subfield> </datafield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester2, T</subfield> <subfield code="u">DESY2</subfield> </datafield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester3, T</subfield> <subfield code="u">DESY3</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHYPHY</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" # Rev 1 Modified -- 100-2/100-3/100-1 self.rev1_mod = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester2, T</subfield> <subfield code="u">DESY2</subfield> </datafield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester3, T</subfield> <subfield code="u">DESY3</subfield> </datafield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester1, T</subfield> <subfield code="u">DESY1</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHYPHY</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" self.patch = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester2, T</subfield> <subfield code="u">DESY2</subfield> </datafield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester3, T</subfield> <subfield code="u">DESY3</subfield> </datafield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester1, T</subfield> <subfield code="u">DESY1</subfield> </datafield> </record>""" insert_record = self.rev1.replace('<controlfield tag="001">123456789</controlfield>', "") insert_record = insert_record.replace('<controlfield tag="005">20110101000000.0</controlfield>', "") recs = xml_marc_to_records(insert_record) # --> Revision 1 submitted res = bibupload(recs[0], opt_mode="insert") self.recid = res[1] self.check_record_consistency(self.recid) rec = get_record(self.recid) rev_tag = record_get_field_value(rec, "005", "", "") # update the test data self.rev1 = self.rev1.replace("123456789", str(self.recid)) self.rev1 = self.rev1.replace("20110101000000.0", rev_tag) self.rev1_mod = self.rev1_mod.replace("123456789", str(self.recid)) self.rev1_mod = self.rev1_mod.replace("20110101000000.0", rev_tag) self.patch = self.patch.replace("123456789", str(self.recid))
def setUp(self): """ Sets up sample records for Modified Fields Scenarios.""" GenericBibUploadTest.setUp(self) # Rev 1 self.rev1 = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="300" ind1=" " ind2=" "> <subfield code="a">Test, Field-1</subfield> </datafield> <datafield tag ="300" ind1=" " ind2=" "> <subfield code="a">Test, Field-2</subfield> </datafield> <datafield tag ="300" ind1="C" ind2="P"> <subfield code="a">Test, Field-3</subfield> </datafield> </record>""" # Rev 1 -- To Replace self.rev1_mod = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> </record>""" # Patch with SPECIAL DELETE FIELD-1 self.patch_1 = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="300" ind1=" " ind2=" "> <subfield code="0">__DELETE_FIELDS__</subfield> </datafield> <datafield tag ="300" ind1="C" ind2="P"> <subfield code="0">__DELETE_FIELDS__</subfield> </datafield> </record>""" # Patch with SPECIAL DELETE FIELD-2 self.patch_2 = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="300" ind1="C" ind2="P"> <subfield code="0">__DELETE_FIELDS__</subfield> </datafield> <datafield tag ="300" ind1=" " ind2=" "> <subfield code="0">__DELETE_FIELDS__</subfield> </datafield> </record>""" self.rev_to_insert = self.rev1.replace('<controlfield tag="001">123456789</controlfield>', "") self.rev_to_insert = self.rev_to_insert.replace('<controlfield tag="005">20110101000000.0</controlfield>', "") rec = xml_marc_to_records(self.rev_to_insert) dummy_error, self.recid, dummy_msg = bibupload(rec[0], opt_mode="insert") self.check_record_consistency(self.recid) self.rev1 = self.rev1.replace("123456789", str(self.recid)) self.rev1_mod = self.rev1_mod.replace("123456789", str(self.recid)) self.patch_1 = self.patch_1.replace("123456789", str(self.recid)) self.patch_2 = self.patch_2.replace("123456789", str(self.recid)) record = get_record(self.recid) rev = record_get_field_value(record, "005") self.rev1 = self.rev1.replace("20110101000000.0", rev) self.rev1_mod = self.rev1_mod.replace("20110101000000.0", rev)
def setUp(self): """ Sets up sample records for Modified Fields Scenarios.""" GenericBibUploadTest.setUp(self) self.data = init_test_records() # Rev 2 Update -- Rev2 ~ tag 970 Modified self.rev2_mod_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PZOOPZOO</subfield> </datafield> </record>""" # Modify Record Patch Output self.patch = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PZOOPZOO</subfield> </datafield> </record>""" # Scenario 2 - 970CP added to existing record # Rev 2 Update -- Rev2 ~ tag 970CP Added self.rev2_mod_field_diff_ind = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHOPHO</subfield> </datafield> <datafield tag ="970" ind1="C" ind2="P"> <subfield code="a">0003719XYZOXYZO</subfield> </datafield> </record>""" # Modify Record Patch Output self.patch_diff_ind = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="970" ind1="C" ind2="P"> <subfield code="a">0003719XYZOXYZO</subfield> </datafield> </record>""" # Scenario 3 - 970__ deleted and 970CP added to existing record # Rev 2 Update -- Rev2 ~ tag 970CP Added self.rev2_mod_del_one_add_one = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="970" ind1="C" ind2="P"> <subfield code="a">0003719XYZOXYZO</subfield> </datafield> </record>""" # Modify Record Patch Output - 1st possibility self.patch_del_one_add_one = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="0">__DELETED_FIELDS__</subfield> </datafield> <datafield tag ="970" ind1="C" ind2="P"> <subfield code="a">0003719XYZOXYZO</subfield> </datafield> </record>""" # Modify Record Patch Output - 2nd possibility self.patch_del_one_add_one_2 = """<record> <controlfield tag="001">123456789</controlfield> <datafield tag ="970" ind1="C" ind2="P"> <subfield code="a">0003719XYZOXYZO</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="0">__DELETED_FIELDS__</subfield> </datafield> </record>""" self.rev2_mod_field = self.rev2_mod_field.replace("123456789", self.data["id"][0]) self.rev2_mod_field = self.rev2_mod_field.replace("20110101000000.0", self.data["rev2"][1]) self.patch = self.patch.replace("123456789", self.data["id"][0]) self.rev2_mod_field_diff_ind = self.rev2_mod_field_diff_ind.replace("123456789", self.data["id"][0]) self.rev2_mod_field_diff_ind = self.rev2_mod_field_diff_ind.replace("20110101000000.0", self.data["rev2"][1]) self.patch_diff_ind = self.patch_diff_ind.replace("123456789", self.data["id"][0]) self.rev2_mod_del_one_add_one = self.rev2_mod_del_one_add_one.replace("123456789", self.data["id"][0]) self.rev2_mod_del_one_add_one = self.rev2_mod_del_one_add_one.replace("20110101000000.0", self.data["rev2"][1]) self.patch_del_one_add_one = self.patch_del_one_add_one.replace("123456789", self.data["id"][0]) self.patch_del_one_add_one_2 = self.patch_del_one_add_one_2.replace("123456789", self.data["id"][0])
def setUp(self): """ Sets Up sample Records for Adding Field Scenario.""" GenericBibUploadTest.setUp(self) self.data = init_test_records() # Rev 2 Update -- Rev2 + tag 888 self.rev2_add_conf_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" # Rev 2 Update -- Rev2 + tag 100* self.rev2_add_sim_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="100" ind1="C" ind2="0"> <subfield code="a">Devel, D</subfield> <subfield code="u">FUZZY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHOPHO</subfield> </datafield> </record>""" # Rev 3 -- Rev2 + tag 100* +tag 888 self.rev3_add_sim_field = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="u">DESY</subfield> </datafield> <datafield tag ="100" ind1="C" ind2="1"> <subfield code="a">Devel, D</subfield> <subfield code="z">FUZZY</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHOPHO</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" # Rev 3 -- tag 100 updated from Rev 2 + Tag 888 self.rev3_mod = """<record> <controlfield tag="001">123456789</controlfield> <controlfield tag="005">20110101000000.0</controlfield> <datafield tag ="100" ind1=" " ind2=" "> <subfield code="a">Tester, T</subfield> <subfield code="z">DEVEL, U</subfield> </datafield> <datafield tag ="970" ind1=" " ind2=" "> <subfield code="a">0003719PHOPHO</subfield> </datafield> <datafield tag="888" ind1=" " ind2=" "> <subfield code="a">dumb text</subfield> </datafield> </record>""" self.rev2_add_conf_field = self.rev2_add_conf_field.replace("123456789", self.data["id"][0]) self.rev2_add_conf_field = self.rev2_add_conf_field.replace("20110101000000.0", self.data["rev2"][1]) self.rev2_add_sim_field = self.rev2_add_sim_field.replace("123456789", self.data["id"][0]) self.rev2_add_sim_field = self.rev2_add_sim_field.replace("20110101000000.0", self.data["rev2"][1]) self.rev3_mod = self.rev3_mod.replace("123456789", self.data["id"][0]) self.rev3_mod = self.rev3_mod.replace("20110101000000.0", self.data["rev3"][1]) self.rev3_add_sim_field = self.rev3_add_sim_field.replace("123456789", self.data["id"][0]) self.rev3_add_sim_field = self.rev3_add_sim_field.replace("20110101000000.0", self.data["rev3"][1])
def setUp(self): GenericBibUploadTest.setUp(self) self.data = init_test_records()