示例#1
0
 def test_get_url_value(self):
     h = HandleRecord()
     res = h.get_url_value()
     assert res is None
     h.add_url('http://www.foo.bar/')
     assert 'http://www.foo.bar/' == h.get_url_value()
     assert 'http://www.rando.m/' != h.get_url_value()
示例#2
0
 def test_get_checksum(self):
     h = HandleRecord()
     res = h.get_checksum_value()
     assert res is None
     h.add_checksum(1234)
     assert 1234 == h.get_checksum_value()
     assert 7631 != h.get_checksum_value()
示例#3
0
 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()
示例#4
0
 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()
示例#5
0
 def test_retrieve_all_locations(self):
     h = HandleRecord.from_json(json.loads(self.handle_str))
     assert h is not None
     locations = h.get_all_locations()
     assert locations
     print locations
     assert len(locations) == 2
     assert locations[0] == h.get_url_value()
示例#6
0
 def test_retrieve_all_locations(self):
     h = HandleRecord.from_json(json.loads(self.handle_str))
     assert h is not None
     locations = h.get_all_locations()
     assert locations
     print locations
     assert len(locations) == 2
     assert locations[0] == h.get_url_value()
示例#7
0
 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'
示例#8
0
 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'
示例#9
0
 def test_get_checksum(self):
     h = HandleRecord()
     res = h.get_checksum_value()
     assert res is None
     h.add_checksum(1234)
     assert 1234 == h.get_checksum_value()
     assert 7631 != h.get_checksum_value()
示例#10
0
 def test_get_url_value(self):
     h = HandleRecord()
     res = h.get_url_value()
     assert res is None
     h.add_url('http://www.foo.bar/')
     assert 'http://www.foo.bar/' == h.get_url_value()
     assert 'http://www.rando.m/' != h.get_url_value()
示例#11
0
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
示例#12
0
    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)
示例#13
0
    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
示例#14
0
    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
示例#15
0
    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)
示例#16
0
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
示例#17
0
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
示例#18
0
 def test_add_url(self):
     expected_result = 'http://www.google.com'
     h = HandleRecord()
     h.add_url(expected_result)
     res = h.get_url_value()
     assert res == expected_result
示例#19
0
 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()
示例#20
0
 def test_to_string(self):
     h = HandleRecord.get_handle_with_values('http://www.foo.bar', 772)
     print h
示例#21
0
 def test_from_handle_json_array(self):
     h = HandleRecord.from_json(json.loads(self.handle_str))
     assert h is not None
     assert h.get_url_value() == 'irods://ed-res-01.csc.fi:1247/ed-csc/rc/enes/cmip5/output1/MPI-M/MPI-ESM-LR/rcp45/mon/ocean/Omon/r1i1p1/v20120110/hfsithermds/hfsithermds_Omon_MPI-ESM-LR_rcp45_r1i1p1_229001-230012.nc'
     assert h.get_checksum_value() == '393e2b4fad2df7e30c89d6287969d0b1'
示例#22
0
 def test_from_epic_json_array(self):
     h = HandleRecord.from_json(json.loads(self.epic_str))
     assert h is not None
     assert h.get_url_value() == 'irods://irods0-eudat.rzg.mpg' \
                                '.de:1247/vzRZGE/eudat/clarin/archive/qfs1/media-archive/lac_data/Ozyurek//20100203172555.imdi'
     assert h.get_checksum_value() == '409b793ccab2c3b7113da1c8f8c1e5e5'
示例#23
0
 def test_from_epic_json_array(self):
     h = HandleRecord.from_json(json.loads(self.epic_str))
     assert h is not None
     assert h.get_url_value() == 'irods://irods0-eudat.rzg.mpg' \
                                '.de:1247/vzRZGE/eudat/clarin/archive/qfs1/media-archive/lac_data/Ozyurek//20100203172555.imdi'
     assert h.get_checksum_value() == '409b793ccab2c3b7113da1c8f8c1e5e5'
示例#24
0
 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()
示例#25
0
 def test_add_checksum(self):
     h = HandleRecord()
     h.add_checksum(6673)
     res = h.get_checksum_value()
     assert res == 6673
示例#26
0
 def test_add_url(self):
     expected_result = 'http://www.google.com'
     h = HandleRecord()
     h.add_url(expected_result)
     res = h.get_url_value()
     assert res == expected_result
示例#27
0
 def test_from_handle_json_array(self):
     h = HandleRecord.from_json(json.loads(self.handle_str))
     assert h is not None
     assert h.get_url_value(
     ) == 'irods://ed-res-01.csc.fi:1247/ed-csc/rc/enes/cmip5/output1/MPI-M/MPI-ESM-LR/rcp45/mon/ocean/Omon/r1i1p1/v20120110/hfsithermds/hfsithermds_Omon_MPI-ESM-LR_rcp45_r1i1p1_229001-230012.nc'
     assert h.get_checksum_value() == '393e2b4fad2df7e30c89d6287969d0b1'
示例#28
0
 def test_add_checksum(self):
     h = HandleRecord()
     h.add_checksum(6673)
     res = h.get_checksum_value()
     assert res == 6673
示例#29
0
 def test_to_string(self):
     h = HandleRecord.get_handle_with_values('http://www.foo.bar', 772)
     print h