def test_set_dids_metadata_bulk_multi_client(did_factory, rucio_client): """ DID (CLIENT) : Test setting metadata in bulk with multiple key-values on multiple dids""" skip_without_json() nb_dids = 5 dids = [did_factory.make_dataset() for _ in range(nb_dids)] for did in dids: testkeys = list(map(lambda i: 'testkey' + generate_uuid(), range(3))) testmeta = {key: key + 'value' for key in testkeys} did['meta'] = testmeta external_testdids = deepcopy(dids) for did in external_testdids: did['scope'] = did['scope'].external print(dids) print(external_testdids) result = rucio_client.set_dids_metadata_bulk(dids=external_testdids, recursive=False) assert result is True for did in dids: testmeta = did['meta'] print('Metadata:', testmeta) meta = get_metadata(plugin="ALL", scope=did['scope'], name=did['name']) print('Metadata:', meta) for testkey in testmeta: assert testkey in meta and meta[testkey] == testmeta[testkey]
def test_get_metadata(self): """ DID Meta (JSON): Get did meta """ skip_without_json() did_name = 'mock_did_%s' % generate_uuid() meta_key = 'my_key_%s' % generate_uuid() meta_value = 'my_value_%s' % generate_uuid() add_did(scope=self.tmp_scope, name=did_name, type='DATASET', account=self.root) set_metadata(scope=self.tmp_scope, name=did_name, key=meta_key, value=meta_value) assert get_metadata(scope=self.tmp_scope, name=did_name, plugin='JSON')[meta_key] == meta_value
def test_get_did_meta(self): """ DID Meta (Hardcoded): Get did meta """ did_name = 'mock_did_%s' % generate_uuid() dataset_meta = {'project': 'data12_8TeV'} add_did(scope=self.tmp_scope, name=did_name, type='DATASET', meta=dataset_meta, account=self.root) assert get_metadata(scope=self.tmp_scope, name=did_name)['project'] == 'data12_8TeV'
def test_did_set_metadata_bulk_single(testdid): """ DID (CORE) : Test setting metadata in bulk with a single key-value pair """ skip_without_json() testkey = 'testkey' testmeta = {testkey: 'testvalue'} set_metadata_bulk(meta=testmeta, recursive=False, **testdid) meta = get_metadata(plugin="ALL", **testdid) print('Metadata:', meta) assert testkey in meta and meta[testkey] == testmeta[testkey]
def test_add_did_meta(self): """ DID Meta (Hardcoded): Add did meta """ did_name = 'mock_did_%s' % generate_uuid() add_did(scope=self.tmp_scope, name=did_name, type='DATASET', account=self.root) set_metadata(scope=self.tmp_scope, name=did_name, key='project', value='data12_8TeV') assert get_metadata(scope=self.tmp_scope, name=did_name)['project'] == 'data12_8TeV'
def test_did_set_metadata_bulk_multi(testdid): """ DID (CORE) : Test setting metadata in bulk with multiple key-values """ skip_without_json() testkeys = list(map(lambda i: 'testkey' + str(i), range(3))) testmeta = {key: key + 'value' for key in testkeys} # let two keys have the same value testmeta[testkeys[1]] = testmeta[testkeys[0]] set_metadata_bulk(meta=testmeta, recursive=False, **testdid) meta = get_metadata(plugin="ALL", **testdid) print('Metadata:', meta) for testkey in testkeys: assert testkey in meta and meta[testkey] == testmeta[testkey]
def test_get_metadata(self): """ DID Meta (JSON): Get did meta """ if not self.implemented: # For some oracle and sqlite version json support is not implemented return did_name = 'mock_did_%s' % generate_uuid() meta_key = 'my_key_%s' % generate_uuid() meta_value = 'my_value_%s' % generate_uuid() add_did(scope=self.tmp_scope, name=did_name, type='DATASET', account=self.root) set_metadata(scope=self.tmp_scope, name=did_name, key=meta_key, value=meta_value) assert get_metadata(scope=self.tmp_scope, name=did_name, plugin='JSON')[meta_key] == meta_value
def test_did_set_metadata_bulk_multi_client(testdid): """ DID (CLIENT) : Test setting metadata in bulk with multiple key-values """ skip_without_json() testkeys = list(map(lambda i: 'testkey' + str(i), range(3))) testmeta = {key: key + 'value' for key in testkeys} # let two keys have the same value testmeta[testkeys[1]] = testmeta[testkeys[0]] didclient = DIDClient() external_testdid = testdid.copy() external_testdid['scope'] = testdid['scope'].external result = didclient.set_metadata_bulk(meta=testmeta, recursive=False, **external_testdid) assert result is True meta = get_metadata(plugin="ALL", **testdid) print('Metadata:', meta) for testkey in testkeys: assert testkey in meta and meta[testkey] == testmeta[testkey]
def test_set_dids_metadata_bulk_multi(did_factory): """ DID (CORE) : Test setting metadata in bulk with multiple key-values on multiple dids""" skip_without_json() nb_dids = 5 dids = [did_factory.make_dataset() for _ in range(nb_dids)] for did in dids: testkeys = list(map(lambda i: 'testkey' + generate_uuid(), range(3))) testmeta = {key: key + 'value' for key in testkeys} did['meta'] = testmeta print(dids) set_dids_metadata_bulk(dids=dids, recursive=False) for did in dids: testmeta = did['meta'] print('Metadata:', testmeta) meta = get_metadata(plugin="ALL", scope=did['scope'], name=did['name']) print('Metadata:', meta) for testkey in testmeta: assert testkey in meta and meta[testkey] == testmeta[testkey]