def test_constructor(self): """Tests the proper constructor values are set""" client = self._new_client() self.assertEqual(client.baseurl['scheme'], 'http', 'Scheme not set to http as spected for baseurl!') self.assertEqual(client.baseurl['host'], 'brutus.library.emory.edu', 'Host not correctly set for baseurl!') self.assertEqual(client.baseurl['path'], '/pidman', 'Path not correctly set for baseurl!') # url with trailing slash - treated same as without client = PidmanRestClient('%s/' % self.baseurl) self.assertEqual( client.baseurl['path'], '/pidman', 'Path not correctly set when baseurl specified with trailing slash' )
# validate that each arg starts with http and ends with a port number validate(new_url_base, fedora_url) else: print '\nError: argument list incomplete. See usage example below.' usage() sys.exit() global repo repo = Repository(fedora_url, username=fedora_username, password=fedora_password) #Pidman Client global client client = PidmanRestClient(db_baseurl, db_username, db_password) connection = client._get_connection() current_page = 1 count = 0 max = 10000 # search for existing arks by domain where type='ark', domain='LSDI' search_results = client.search_pids(type='ark', domain='Rushdie Collection', count=max) total_pages = search_results['page_count'] page_link_1 = search_results['first_page_link'] page_link = page_link_1[0:-1] print "\n=> Processing page[%d] that contains [%d] of a total of [%d] pages ..." % (
# validate that each arg starts with http and ends with a port number validate(new_url_base, fedora_url) else: print '\nError: argument list incomplete. See usage example below.' usage() sys.exit() global repo repo = Repository(fedora_url, username=fedora_username, password=fedora_password) #Pidman Client global client client = PidmanRestClient(db_baseurl, db_username, db_password) connection = client._get_connection() current_page = 1 count = 0 max = 10000 # search for existing arks by domain where type='ark', domain='LSDI' search_results = client.search_pids(type='ark', domain='Rushdie Collection', count=max) total_pages = search_results['page_count'] page_link_1 = search_results['first_page_link'] page_link = page_link_1[0:-1] print "\n=> Processing page[%d] that contains [%d] of a total of [%d] pages ..." %(current_page, max, total_pages) page_results = search_results['results'] count = process_page(current_page, page_results)
db_username = args[2] db_password = args[3] domain = args[4] if (len(args) == 6): db_baseurl = args[5] else: # use the test pid manager if not specified db_baseurl = 'https://testpid.library.emory.edu/' else: print '\nError: argument list incomplete. See usage example below.' usage() sys.exit() global client client = PidmanRestClient(db_baseurl, db_username, db_password) current_page = 1 count = 0 max = 50000 search_results = client.search_pids(type='purl', domain=domain, count=max) total_pages = search_results['page_count'] page_results = search_results['results'] print "\n=> Processing page[%d] that contains [%d] of a total of [%d] pages..." %(current_page, max, total_pages) count = process_page(current_page, page_results) current_page = current_page + 1 while (current_page <= total_pages):
def _new_client(self): """ Initialize client with configured settings for testing. """ return PidmanRestClient(self.baseurl, self.username, self.password)
new_netloc = args[1] db_username = args[2] db_password = args[3] domain = args[4] if (len(args) == 6): db_baseurl = args[5] else: # use the test pid manager if not specified db_baseurl = 'https://testpid.library.emory.edu/' else: print '\nError: argument list incomplete. See usage example below.' usage() sys.exit() global client client = PidmanRestClient(db_baseurl, db_username, db_password) current_page = 1 count = 0 max = 50000 search_results = client.search_pids(type='purl', domain=domain, count=max) total_pages = search_results['page_count'] page_results = search_results['results'] print "\n=> Processing page[%d] that contains [%d] of a total of [%d] pages..." % ( current_page, max, total_pages) count = process_page(current_page, page_results) current_page = current_page + 1