async def test_nodes_mutator(flow, flow_args): """Test the nodes mutation method.""" flow_args['workflows'].append((flow.owner, flow.name, None)) ids = [parse_node_id(n, TASK_PROXIES) for n in flow.node_ids] response = await flow.resolvers.nodes_mutator(None, 'force_trigger_tasks', ids, flow_args, {}) assert response[0]['id'] == flow.id
def test_nodes_mutator(self): """Test the nodes mutation method.""" w_args = deepcopy(FLOW_ARGS) w_args['workflows'].append((self.owner, self.suite_name, None)) args = {} ids = [parse_node_id(n, TASK_PROXIES) for n in self.node_ids] response = _run_coroutine( self.resolvers.nodes_mutator(None, 'trigger_tasks', ids, w_args, args)) self.assertEqual(response[0]['id'], self.workflow_id)
async def test_get_nodes_all(flow, node_args): """Test method returning workflow(s) node message satisfying filter args. """ node_args['workflows'].append((flow.owner, flow.name, None)) node_args['states'].append('failed') nodes = await flow.resolvers.get_nodes_all(TASK_PROXIES, node_args) assert len(nodes) == 0 node_args['ghosts'] = True node_args['states'] = [] node_args['ids'].append(parse_node_id(flow.node_ids[0], TASK_PROXIES)) nodes = [ n for n in await flow.resolvers.get_nodes_all(TASK_PROXIES, node_args) if n in flow.data[TASK_PROXIES].values() ] assert len(nodes) == 1
def test_get_nodes_all(self): """Test method returning workflow(s) node messages satisfying filter args.""" args = deepcopy(NODE_ARGS) args['workflows'].append((self.owner, self.suite_name, None)) args['states'].append('failed') nodes = _run_coroutine(self.resolvers.get_nodes_all( TASK_PROXIES, args)) self.assertEqual(0, len(nodes)) args['ghosts'] = True args['states'] = [] args['ids'].append(parse_node_id(self.node_ids[0], TASK_PROXIES)) nodes = [ n for n in _run_coroutine( self.resolvers.get_nodes_all(TASK_PROXIES, args)) if n in self.data[TASK_PROXIES].values() ] self.assertEqual(1, len(nodes))
def node_filter(node, node_type, args): """Filter nodes based on attribute arguments""" # Updated delta nodes don't contain name but still need filter if not node.name: n_atts = list(parse_node_id(node.id, node_type)) n_atts[3] = [n_atts[3]] else: n_atts = collate_node_atts(node) # The n_atts (node attributes) list contains ordered node values # or defaults (see collate function for index item). return ( (args.get('ghosts') or n_atts[5] != '') and (not args.get('states') or n_atts[5] in args['states']) and not (args.get('exstates') and n_atts[5] in args['exstates']) and (args.get('is_held') is None or (node.is_held == args['is_held'])) and (args.get('mindepth', -1) < 0 or node.depth >= args['mindepth']) and (args.get('maxdepth', -1) < 0 or node.depth <= args['maxdepth']) and # Now filter node against id arg lists (not args.get('ids') or node_ids_filter(n_atts, args['ids'])) and not (args.get('exids') and node_ids_filter(n_atts, args['exids'])))