def create_info(name, info_type, url=None, parent=None, id=None, context=ctx_default, store=False): """Return a group object""" id = str(uuid4()) if id is None else id pubsub = _pubsub_key(id) info = {'id': id, 'type': info_type, 'pubsub': pubsub, 'url': url, 'parent': parent, 'context': context, 'name': name, 'status': 'Queued' if info_type == 'job' else None, 'date_start': None, 'date_end': None, 'date_created': str(datetime.now()), 'result': None} if store: r_client.set(id, json_encode(info)) if parent is not None: r_client.sadd(_children_key(parent), id) return info
def create_info(name, info_type, url=None, parent=None, id=None, context=ctx_default, store=False): """Return a group object""" id = str(uuid4()) if id is None else id pubsub = _pubsub_key(id) info = { 'id': id, 'type': info_type, 'pubsub': pubsub, 'url': url, 'parent': parent, 'context': context, 'name': name, 'status': 'Queued' if info_type == 'job' else None, 'date_start': None, 'date_end': None, 'date_created': str(datetime.now()), 'result': None } if store: r_client.set(id, json_encode(info)) if parent is not None: r_client.sadd(_children_key(parent), id) return info
def test_traverse_complex(self): r_client.sadd('testing:children', 'd') r_client.sadd('d:children', 'd_a', 'd_b') r_client.set('d', '{"type": "group", "id": "d", "name": "d"}') r_client.set('d_a', '{"type": "job", "id": "d_a", "name": "d_a"}') r_client.set('d_b', '{"type": "job", "id": "d_b", "name": "d_b"}') self.to_delete.append('d:children') self.to_delete.append('d_a') self.to_delete.append('d_b') exp = {'a', 'b', 'c', 'd', 'd_a', 'd_b'} obs = {obj['id'] for obj in self.obj.traverse('testing')} self.assertEqual(obs, exp)
def setUp(self): r_client.hset('user-id-map', 'testing', 'testing') r_client.sadd('testing:children', 'a') r_client.sadd('testing:children', 'b') r_client.sadd('testing:children', 'c') r_client.set('a', '{"type": "job", "id": "a", "name": "a"}') r_client.set('b', '{"type": "job", "id": "b", "name": "b"}') r_client.set('c', '{"type": "job", "id": "c", "name": "c"}') r_client.set('d', '{"type": "job", "id": "d", "name": "other job"}') r_client.set('e', '{"type": "job", "id": "e", "name": "other job e"}') self.obj = Group('testing')
def setUp(self): r_client.hset('user-id-map', 'testing', 'testing') r_client.sadd('testing:children', 'a') r_client.sadd('testing:children', 'b') r_client.sadd('testing:children', 'c') r_client.set('a', '{"type": "job", "id": "a", "name": "a"}') r_client.set('b', '{"type": "job", "id": "b", "name": "b"}') r_client.set('c', '{"type": "job", "id": "c", "name": "c"}') r_client.set('d', '{"type": "job", "id": "d", "name": "other job"}') r_client.set('e', '{"type": "job", "id": "e", "name": "other job e"}') self.obj = Group('testing') self.to_delete = ['testing', 'testing:jobs', 'testing:children', 'user-id-map', 'a', 'b', 'c', 'd', 'e']