Пример #1
0
 def test_w_weight(self):
     from repoze.lemonade.content import IContent
     from zope.interface import directlyProvides
     from karl.utilities.groupsearch import WeightedQuery
     context = self.context
     context.description = 'foo'
     directlyProvides(context, IContent)
     def fut():
         return self._callFUT(context, None).coefficient
     wf = WeightedQuery.weight_factor
     context.search_weight = -1
     self.assertEqual(fut(), wf ** -1)
     context.search_weight = 0
     self.assertEqual(fut(), wf ** 0)
     context.search_weight = 1
     self.assertEqual(fut(), wf ** 1)
     context.search_weight = 2
     self.assertEqual(fut(), wf ** 2)
Пример #2
0
    def test_w_weight(self):
        from repoze.lemonade.content import IContent
        from zope.interface import directlyProvides
        from karl.utilities.groupsearch import WeightedQuery
        context = self.context
        context.description = 'foo'
        directlyProvides(context, IContent)

        def fut():
            return self._callFUT(context, None).coefficient

        wf = WeightedQuery.weight_factor
        context.search_weight = -1
        self.assertEqual(fut(), wf**-1)
        context.search_weight = 0
        self.assertEqual(fut(), wf**0)
        context.search_weight = 1
        self.assertEqual(fut(), wf**1)
        context.search_weight = 2
        self.assertEqual(fut(), wf**2)
Пример #3
0
 def _callFUT(self, object, default):
     from karl.models.site import get_weighted_textrepr as fut
     return fut(object, default)
Пример #4
0
 def _callFUT(self, object, default):
     from karl.models.site import get_weighted_textrepr as fut
     return fut(object, default)