Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
 def _callFUT(self, object, default):
     from karl.models.site import get_weighted_textrepr as fut
     return fut(object, default)
Ejemplo n.º 4
0
 def _callFUT(self, object, default):
     from karl.models.site import get_weighted_textrepr as fut
     return fut(object, default)