Exemple #1
0
 def createMatcher(self, subject, matchType, query):
     """Creates a matcher for this filter
     @type  subject: opencue.MatchSubject.*
     @param subject: The job attribute to match
     @type  matchType: opencue.MatchType.*
     @param matchType: The type of match to perform
     @type  query: string
     @param query: The value to match
     @rtype:  Matcher
     @return: The new matcher object"""
     matcher = MatcherData(subject=subject,
                           type=matchType,
                           input=query.replace(' ', ''))
     return Matcher(
         self.stub.CreateMatcher(filter_pb2.FilterCreateMatcherRequest(
             filter=self.data, data=matcher),
                                 timeout=Cuebot.Timeout))
Exemple #2
0
    def testCreateMatcher(self, getStubMock):
        matcherId = 'mmm-mmmm-mmm'
        stubMock = mock.Mock()
        stubMock.CreateMatcher.return_value = filter_pb2.FilterCreateMatcherResponse(
            matcher=filter_pb2.Matcher(id=matcherId))
        getStubMock.return_value = stubMock

        queryStr = 'john'
        subject = filter_pb2.USER
        matcherType = filter_pb2.IS_NOT
        matcherData = opencue.wrappers.filter.MatcherData(
            subject=subject, type=matcherType, input=queryStr)
        filterForMatcher = opencue.wrappers.filter.Filter(filter_pb2.Filter(name=TEST_FILTER_NAME))
        matcher = filterForMatcher.createMatcher(subject, matcherType, queryStr)

        stubMock.CreateMatcher.assert_called_with(
            filter_pb2.FilterCreateMatcherRequest(filter=filterForMatcher.data, data=matcherData),
            timeout=mock.ANY)
        self.assertEqual(matcher.id(), matcherId)
Exemple #3
0
    def createMatcher(self, subject, matchType, query):
        """Creates a matcher for the filter.

        :type  subject: filter_pb2.MatchSubject.*
        :param subject: the job attribute to match
        :type  matchType: filter_pb2.MatchType.*
        :param matchType: the type of match to perform
        :type  query: string
        :param query: the value to match
        :rtype:  Matcher
        :return: the new matcher object
        """
        matcher = MatcherData(subject=subject,
                              type=matchType,
                              input=query.replace(' ', ''))
        return Matcher(
            self.stub.CreateMatcher(filter_pb2.FilterCreateMatcherRequest(
                filter=self.data, data=matcher),
                                    timeout=Cuebot.Timeout).matcher)