def setUp(self): self.fpath = "/humgen/projects/serapis_staging/test-baton/test_add_acls.txt" BatonDataObjectAPI.remove_all_acls(self.fpath) self.acl = ACL(user='******', zone='humgen', permission='READ') BatonDataObjectAPI.add_or_replace_acl(self.fpath, self.acl) existing_acls = BatonDataObjectAPI.get_acls(self.fpath) self.assertEqual(len(existing_acls), 1)
def test_add_or_replace_a_list_of_acls(self): self.acls = [ ACL(user='******', zone='humgen', permission='READ'), ACL(user='******', zone='humgen', permission='READ') ] BatonDataObjectAPI.add_or_replace_a_list_of_acls(self.fpath, self.acls) self.acls_set = BatonDataObjectAPI.get_acls(self.fpath) self.assertEqual(len(self.acls_set), 2)
def setUp(self): self.fpath = "/humgen/projects/serapis_staging/test-baton/test_add_acls.txt" self.acls = [ ACL(user='******', zone='humgen', permission='READ'), ACL(user='******', zone='humgen', permission='READ') ] BatonDataObjectAPI.add_or_replace_a_list_of_acls(self.fpath, self.acls) self.acls_set = BatonDataObjectAPI.get_acls(self.fpath) self.assertNotEqual(len(self.acls_set), 0)
def test_get_or_replace_acls_when_adding_a_new_acl(self): added_acl = ACL(user='******', zone='humgen', permission='OWN') BatonDataObjectAPI.add_or_replace_acl(self.fpath, added_acl) acls_set = BatonDataObjectAPI.get_acls(self.fpath) found = False for acl in acls_set: if acl == added_acl: found = True self.assertTrue(found)
def test_get_acls_data_object(self): result = BatonDataObjectAPI._get_acls("/humgen/projects/serapis_staging/test-baton/test_acls.txt") expected = {ACL(user='******', zone='humgen', permission='READ'), ACL(user='******', zone='Sanger1', permission='READ'), ACL(user='******', zone='humgen', permission='OWN'), ACL(user='******', zone='Sanger1', permission='OWN'), ACL(user='******', zone='humgen', permission='OWN'), ACL(user='******', zone='humgen', permission='OWN') } self.assertSetEqual(result, expected)
def test_get_or_replace_acls_when_replacing_an_acl(self): added_acl = ACL(user='******', zone='humgen', permission='OWN') BatonDataObjectAPI.add_or_replace_acl(self.fpath, added_acl) acls_set = BatonDataObjectAPI.get_acls(self.fpath) self.assertSetEqual(acls_set, {added_acl}) replacement_acl = ACL(user='******', zone='humgen', permission='READ') BatonDataObjectAPI.add_or_replace_acl(self.fpath, replacement_acl) acls_set = BatonDataObjectAPI.get_acls(self.fpath) self.assertSetEqual(acls_set, {replacement_acl})
def setUp(self): self.fpath = "/humgen/projects/serapis_staging/test-baton/test_add_acls.txt" BatonDataObjectAPI.remove_all_acls(self.fpath)
def test_remove_all_acls(self): BatonDataObjectAPI.remove_all_acls(self.fpath) acls_set = BatonDataObjectAPI.get_acls(self.fpath) self.assertEqual(set(), acls_set)
def test_update_metadata(self): BatonDataObjectAPI.update_metadata(self.fpath, 'uniq_key', {'second_value'}) updated_meta = BatonDataObjectAPI.get_all_metadata(self.fpath) values = updated_meta.get_avu('uniq_key') self.assertEqual(values, {'second_value'})
def setUp(self): self.fpath = "/humgen/projects/serapis_staging/test-baton/test_metadata_add_rm.txt" BatonDataObjectAPI.add_metadata(self.fpath, {'uniq_key': {'first_value'}})
def test_remove_metadata(self): BatonDataObjectAPI.remove_metadata(self.fpath, self.meta_dict) crt_meta = BatonDataObjectAPI.get_all_metadata(self.fpath) self.assertEqual(crt_meta, self.previous_meta)
def setUp(self): self.fpath = "/humgen/projects/serapis_staging/test-baton/test_metadata_add_rm.txt" self.meta_dict = {'sample': {'sample2'}, 'sample_id': {'-1'}} self.previous_meta = BatonDataObjectAPI.get_all_metadata(self.fpath) BatonDataObjectAPI.add_metadata(self.fpath, self.meta_dict)
def tearDown(self): BatonDataObjectAPI.remove_metadata(self.fpath, self.meta_dict)
def test_add_metadata(self): BatonDataObjectAPI.add_metadata(self.fpath, self.meta_dict) metadata = BatonDataObjectAPI.get_all_metadata(self.fpath).to_dict() self.assertDictEqual(self.meta_dict, metadata)
def test_remove_acls_for_a_list_of_users(self): BatonDataObjectAPI.remove_acls_for_a_list_of_users(self.fpath, [(self.acl.user, self.acl.zone)]) existing_acls = BatonDataObjectAPI.get_acls(self.fpath) self.assertEqual(0, len(existing_acls))
def tearDown(self): BatonDataObjectAPI.remove_all_acls(self.fpath)
def tearDown(self): BatonDataObjectAPI.remove_metadata(self.fpath, {'uniq_key': {'second_value'}})