def test_retrieve_all_locations_with_url(self): h = HandleRecord.get_handle_with_values('http://www.foo.bar') assert h is not None locations = h.get_all_locations() assert locations print locations assert len(locations) == 1 assert locations[0] == h.get_url_value()
def test_to_json_array(self): h = HandleRecord.get_handle_with_values('http://www.foo.bar', 634) json_str = h.as_epic_json_array() assert json_str is not None assert json_str.count('http://www.foo.bar') == 1 array = json.loads(json_str) array.sort() assert array[0]['parsed_data'] == 634 assert array[1]['parsed_data'] == 'http://www.foo.bar'
def get_handle(context): update_request(context, 'Creating handle') epic_client = get_epic_client() pid = epic_client.create_new(config['EPIC_PREFIX'], HandleRecord.get_handle_with_values( create_storage_url(context.destination), context.checksum)) if pid is None: return False context.pid = '/'.join(extract_prefix_suffix(pid)) return True
def setUp(self): self.prefix = '11858' self.suffix = '00-ZZZZ-0000-0000-000C-7' self.base_uri = 'http://www.foo.bar' self.record = HandleRecord.get_handle_with_values( 'irods://tempZone/home/foo/bar', checksum=667) handles[create_uri(base_uri='', prefix=self.prefix, suffix=self.suffix)] = \ self.record.as_epic_json_array() self.epic_client = EpicClient(base_uri=self.base_uri, credentials=HTTPBasicAuth( 'user', 'pass'), debug=True)
def test_create(self): with HTTMock(my_mock): h = HandleRecord.get_handle_with_values('http://foo.bar/', 667) handle = self.epic_client.create_new(prefix='666', handle_record=h) assert handle is not None assert handle.count('666') > 0 prefix, suffix = extract_prefix_suffix(handle) print prefix, suffix handle_r = self.epic_client.retrieve_handle(prefix=prefix, suffix=suffix) assert handle_r is not None print handle_r assert handle_r.get_url_value() == 'http://foo.bar/' assert handle_r.get_checksum_value() == 667
def get_handle(context): update_request(context, 'Creating handle') epic_client = get_epic_client() storage_url = create_storage_url(context.destination) # store for the replication file (for irods) context.storage_url = storage_url #update_request(context, 'created storage_url: %s' % storage_url) pid = epic_client.create_new( config['HANDLE_PREFIX'], HandleRecord.get_handle_with_values(storage_url, context.checksum)) if pid is None: return False context.pid = '/'.join(extract_prefix_suffix(pid)) return True
def setUp(self): self.prefix = '11858' self.suffix = '00-ZZZZ-0000-0000-000C-7' self.base_uri = 'http://www.foo.bar' self.record = HandleRecord.get_handle_with_values( 'irods://tempZone/home/foo/bar', checksum=667) handles[create_uri(base_uri='', prefix=self.prefix, suffix=self.suffix)] = \ self.record.as_epic_json_array() self.epic_client = EpicClient(base_uri=self.base_uri, credentials=HTTPBasicAuth('user', 'pass'), debug=True)
def get_handle(context): update_request(context, 'Creating handle') epic_client = get_epic_client() storage_url = create_storage_url(context.destination) # store for the replication file (for irods) context.storage_url = storage_url #update_request(context, 'created storage_url: %s' % storage_url) pid = epic_client.create_new(config['HANDLE_PREFIX'], HandleRecord.get_handle_with_values( storage_url, context.checksum)) if pid is None: return False context.pid = '/'.join(extract_prefix_suffix(pid)) return True
def test_to_string(self): h = HandleRecord.get_handle_with_values('http://www.foo.bar', 772) print h
def test_handle_factory_method_with_checksum(self): h = HandleRecord.get_handle_with_values('http://www.foo.bar', 667) assert h is not None assert 'http://www.foo.bar' == h.get_url_value() assert h.get_checksum_value() is not None assert 667 == h.get_checksum_value()