Пример #1
0
 def test_make_fq(self):
     self.assertEqual(make_fq(X(status=0)), u"status:0")
     self.assertEqual(
         make_fq(X(status=0) & X(company_status__in=[0, 6])),
         u"status:0 AND (company_status:0 OR company_status:6)")
     self.assertEqual(make_fq(X(status=0) | X(company_status=0)),
                      u"(status:0 OR company_status:0)")
     self.assertEqual(make_fq(X(with_photo=True)), u"with_photo:1")
     self.assertEqual(
         make_fq(
             X(date_created__gt=datetime(2012, 5, 17, 14, 35, 41, 794880))),
         u"date_created:{2012-05-17T14:35:41Z TO *}")
     self.assertEqual(make_fq(X(price__lt=1000)), u"price:{* TO 1000}")
     self.assertEqual(make_fq(X(price__gte=100) & X(price__lte=1000)),
                      u"price:[100 TO *] AND price:[* TO 1000]")
     self.assertEqual(make_fq(X(price__between=[500, 1000])),
                      u"price:[500 TO 1000]")
     self.assertEqual(
         make_fq(
             X(category__in=[1, 2, 3, 4, 5])
             & (X(status=0) | X(status=5)
                | X(status=1) & X(company_status=6))),
         u"(category:1 OR category:2 OR category:3 OR category:4 OR category:5) AND (status:0 OR status:5 OR (status:1 AND company_status:6))"
     )
     self.assertEqual(make_fq(~X(status=1)), u"(NOT status:1)")
     self.assertEqual(make_fq(~X(status__in=[1, 2, 3])),
                      u"(NOT (status:1 OR status:2 OR status:3))")
Пример #2
0
 def test_make_fq(self):
     self.assertEqual(make_fq(X(status=0)),
                      u"status:0")
     self.assertEqual(make_fq(X(status=0) & X(company_status__in=[0,6])),
                      u"status:0 AND (company_status:0 OR company_status:6)")
     self.assertEqual(make_fq(X(status=0) | X(company_status=0)),
                      u"(status:0 OR company_status:0)")
     self.assertEqual(make_fq(X(with_photo=True)),
                      u"with_photo:1")
     self.assertEqual(make_fq(X(date_created__gt=datetime(2012, 5, 17, 14, 35, 41, 794880))),
                      u"date_created:{2012-05-17T14:35:41Z TO *}")
     self.assertEqual(make_fq(X(price__lt=1000)),
                      u"price:{* TO 1000}")
     self.assertEqual(make_fq(X(price__gte=100) & X(price__lte=1000)),
                      u"price:[100 TO *] AND price:[* TO 1000]")
     self.assertEqual(make_fq(X(price__between=[500, 1000])),
                      u"price:[500 TO 1000]")
     self.assertEqual(make_fq(X(category__in=[1, 2, 3, 4, 5]) & (X(status=0) | X(status=5) | X(status=1) & X(company_status=6))),
                      u"(category:1 OR category:2 OR category:3 OR category:4 OR category:5) AND (status:0 OR status:5 OR (status:1 AND company_status:6))")
     self.assertEqual(make_fq(~X(status=1)),
                      u"(NOT status:1)")
     self.assertEqual(make_fq(~X(status__in=[1, 2, 3])),
                      u"(NOT (status:1 OR status:2 OR status:3))")
Пример #3
0
 def test_make_fq(self):
     self.assertEqual(make_fq(X(status=0)), "status:0")
     self.assertEqual(
         make_fq(X(status=0) & X(company_status__in=[0, 6])),
         "status:0 AND (company_status:0 OR company_status:6)")
     self.assertEqual(make_fq(X(status=0) | X(company_status=0)),
                      "(status:0 OR company_status:0)")
     self.assertEqual(make_fq(X(name='Chuck Norris')),
                      "name:(Chuck Norris)")
     self.assertEqual(make_fq(X(name__exact='Chuck Norris')),
                      'name:"Chuck Norris"')
     self.assertEqual(make_fq(X(name__startswith='Chuck Nor')),
                      'name:(Chuck Nor*)')
     self.assertEqual(make_fq(X(with_photo=True)), "with_photo:true")
     self.assertEqual(
         make_fq(
             X(date_created__gt=datetime(2012, 5, 17, 14, 35, 41, 794880))),
         "date_created:{2012-05-17T14:35:41Z TO *}")
     self.assertEqual(make_fq(X(price__lt=1000)), "price:{* TO 1000}")
     self.assertEqual(make_fq(X(price__gte=100) & X(price__lte=1000)),
                      "price:[100 TO *] AND price:[* TO 1000]")
     self.assertEqual(make_fq(X(price__between=[500, 1000])),
                      "price:{500 TO 1000}")
     self.assertEqual(make_fq(X(price__range=[2, 10])), "price:[2 TO 10]")
     self.assertEqual(
         make_fq(
             X(category__in=[1, 2, 3, 4, 5])
             & (X(status=0) | X(status=5)
                | X(status=1) & X(company_status=6))),
         "(category:1 OR category:2 OR category:3 OR category:4 OR category:5) AND (status:0 OR status:5 OR (status:1 AND company_status:6))"
     )
     self.assertEqual(make_fq(~X(status=1)), "NOT (status:1)")
     self.assertEqual(make_fq(~X(status__in=[1, 2, 3])),
                      "NOT ((status:1 OR status:2 OR status:3))")
     self.assertEqual(make_fq(X("status:0 OR status:1")),
                      "status\\:0 or status\\:1")
     self.assertEqual(make_fq(X(SafeUnicode("status:0 OR status:1"))),
                      "status:0 OR status:1")
     self.assertEqual(make_fq(X(status=SafeUnicode('"0"'))), 'status:"0"')
     self.assertEqual(
         make_fq(X(LocalParams('dismax', qf='name', v=X('nokia lumia')))),
         "{!dismax qf=name v='nokia lumia'}")
     self.assertEqual(
         make_fq(
             X(_query_=LocalParams('dismax', qf='name', v=X(
                 'nokia lumia')))),
         "_query_:\"{!dismax qf=name v='nokia lumia'}\"")
Пример #4
0
 def test_make_fq(self):
     self.assertEqual(make_fq(X(status=0)),
                      u"status:0")
     self.assertEqual(make_fq(X(status=0) & X(company_status__in=[0,6])),
                      u"status:0 AND (company_status:0 OR company_status:6)")
     self.assertEqual(make_fq(X(status=0) | X(company_status=0)),
                      u"(status:0 OR company_status:0)")
     self.assertEqual(make_fq(X(manufacturer__exact='Chuck Norris')),
                      u'manufacturer:"Chuck Norris"')
     self.assertEqual(make_fq(X(with_photo=True)),
                      u"with_photo:true")
     self.assertEqual(make_fq(X(date_created__gt=datetime(2012, 5, 17, 14, 35, 41, 794880))),
                      u"date_created:{2012-05-17T14:35:41Z TO *}")
     self.assertEqual(make_fq(X(price__lt=1000)),
                      u"price:{* TO 1000}")
     self.assertEqual(make_fq(X(price__gte=100) & X(price__lte=1000)),
                      u"price:[100 TO *] AND price:[* TO 1000]")
     self.assertEqual(make_fq(X(price__between=[500, 1000])),
                      u"price:{500 TO 1000}")
     self.assertEqual(make_fq(X(price__range=[2, 10])),
                      u"price:[2 TO 10]")
     self.assertEqual(make_fq(X(category__in=[1, 2, 3, 4, 5]) & (X(status=0) | X(status=5) | X(status=1) & X(company_status=6))),
                      u"(category:1 OR category:2 OR category:3 OR category:4 OR category:5) AND (status:0 OR status:5 OR (status:1 AND company_status:6))")
     self.assertEqual(make_fq(~X(status=1)),
                      u"NOT (status:1)")
     self.assertEqual(make_fq(~X(status__in=[1, 2, 3])),
                      u"NOT ((status:1 OR status:2 OR status:3))")
     self.assertEqual(make_fq(X(u"status:0 OR status:1")),
                      u"status\\:0 or status\\:1")
     self.assertEqual(make_fq(X(SafeUnicode(u"status:0 OR status:1"))),
                      u"status:0 OR status:1")
     self.assertEqual(make_fq(X(status=SafeUnicode(u'"0"'))),
                      u'status:"0"')
     self.assertEqual(make_fq(X(LocalParams('dismax', qf='name', v=X(u'nokia lumia')))),
                      u"{!dismax qf=name v='nokia lumia'}")
Пример #5
0
 def test_make_fq(self):
     self.assertEqual(make_fq(X(status=0)),
                      "status:0")
     self.assertEqual(make_fq(X(status=0) & X(company_status__in=[0,6])),
                      "status:0 AND (company_status:0 OR company_status:6)")
     self.assertEqual(make_fq(X(status=0) | X(company_status=0)),
                      "(status:0 OR company_status:0)")
     self.assertEqual(make_fq(X(name='Chuck Norris')),
                      "name:(Chuck Norris)")
     self.assertEqual(make_fq(X(name__exact='Chuck Norris')),
                      'name:"Chuck Norris"')
     self.assertEqual(make_fq(X(name__startswith='Chuck Nor')),
                      'name:(Chuck Nor*)')
     self.assertEqual(make_fq(X(with_photo=True)),
                      "with_photo:true")
     self.assertEqual(make_fq(X(birthday=datetime(2014, 7, 2, 0, 0, 0))),
                      "birthday:2014-07-02T00\\:00\\:00Z")
     self.assertEqual(make_fq(X(date_created__gt=datetime(2012, 5, 17, 14, 35, 41, 794880))),
                      "date_created:{2012-05-17T14\\:35\\:41Z TO *}")
     self.assertEqual(make_fq(X(price__lt=1000)),
                      "price:{* TO 1000}")
     self.assertEqual(make_fq(X(price__gte=100) & X(price__lte=1000)),
                      "price:[100 TO *] AND price:[* TO 1000]")
     self.assertEqual(make_fq(X(price__between=[500, 1000])),
                      "price:{500 TO 1000}")
     self.assertEqual(make_fq(X(price__range=[2, 10])),
                      "price:[2 TO 10]")
     self.assertEqual(make_fq(X(category__in=[1, 2, 3, 4, 5]) & (X(status=0) | X(status=5) | X(status=1) & X(company_status=6))),
                      "(category:1 OR category:2 OR category:3 OR category:4 OR category:5) AND (status:0 OR status:5 OR (status:1 AND company_status:6))")
     self.assertEqual(make_fq(~X(status=1)),
                      "NOT (status:1)")
     self.assertEqual(make_fq(~X(status__in=[1, 2, 3])),
                      "NOT ((status:1 OR status:2 OR status:3))")
     self.assertEqual(make_fq(X("status:0 OR status:1")),
                      "status\\:0 or status\\:1")
     self.assertEqual(make_fq(X(SafeUnicode("status:0 OR status:1"))),
                      "status:0 OR status:1")
     self.assertEqual(make_fq(X(status=SafeUnicode('"0"'))),
                      'status:"0"')
     self.assertEqual(make_fq(X(LocalParams('dismax', qf='name', v=X('nokia lumia')))),
                      "{!dismax qf=name v='nokia lumia'}")
     self.assertEqual(make_fq(X(_query_=LocalParams('dismax', qf='name', v=X('nokia lumia')))),
                      "_query_:\"{!dismax qf=name v='nokia lumia'}\"")