def setUp(self): self.matcher = mock.Mock(name='matcher', spec_set=IMatcher) self.origin = mock.Mock(name='origin', spec_set=Origin) self.qualifier_i = FieldQualifier(self._FIELD, self.matcher, self.origin, True) self.qualifier_e = FieldQualifier(self._FIELD, self.matcher, self.origin, False)
def _gen_qualifiers(self, field_name, field_value, inclusive): if field_value is not None: field_origin = self.origin.just_line().with_offset( self.field_offset_map[field_name]) matchers_gen = self.parse_matchers(field_value) for lineno_offset, matcher_field, matcher, error in matchers_gen: if error is not None: raise error offset = field_origin.with_offset(lineno_offset) yield FieldQualifier(matcher_field, matcher, offset, inclusive)
def _get_qualifier_for(self, testplan, field_name, inclusive): field_value = getattr(testplan, field_name) if field_value is None: return [] field_origin = testplan.origin.just_line().with_offset( testplan.field_offset_map[field_name]) matchers_gen = self._get_matchers(testplan, field_value) results = [] for lineno_offset, matcher_field, matcher in matchers_gen: offset = field_origin.with_offset(lineno_offset) results.append( FieldQualifier(matcher_field, matcher, offset, inclusive)) return results
def get_bootstrap_qualifier(self, excluding=False): """ Convert this test plan to an equivalent qualifier for job selection """ qual_list = [] if self.bootstrap_include is not None: field_origin = self.origin.just_line().with_offset( self.field_offset_map['bootstrap_include']) qual_list = [FieldQualifier( 'id', OperatorMatcher(operator.eq, target_id), field_origin, not excluding) for target_id in self.get_bootstrap_job_ids()] for tp_unit in self.get_nested_part(): qual_list.extend([tp_unit.get_bootstrap_qualifier(excluding)]) return CompositeQualifier(qual_list)
def select_local_jobs(self): print(self.C.header(_("Selecting Job Generators"))) # Create a qualifier list that will pick all local jobs out of the # subset of jobs also enumerated by the whitelists we've already # picked. # # Since each whitelist is a qualifier that selects jobs enumerated # within, we only need to and an exclusive qualifier that deselects # non-local jobs and we're done. qualifier_list = [] qualifier_list.extend(self._qualifier_list) origin = Origin.get_caller_origin() qualifier_list.append(FieldQualifier( 'plugin', OperatorMatcher(operator.ne, 'local'), origin, inclusive=False)) local_job_list = select_jobs( self.manager.state.job_list, qualifier_list) self._update_desired_job_list(local_job_list)
def setUp(self): self._matcher = mock.Mock(spec=IMatcher) self.qualifier_i = FieldQualifier(self._FIELD, self._matcher, True) self.qualifier_e = FieldQualifier(self._FIELD, self._matcher, False)