예제 #1
0
    def test_nested_endswith(self):
        q_obj = Q(secret__gem__endswith='uby')
        obj = SecretModel(secret=StringSecret())
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__endswith='rb')
        self.assertFalse(q_obj.comparator(obj))
예제 #2
0
    def test_nested_endswith(self):
        q_obj = Q(secret__gem__endswith='uby')
        obj = SomeModel.objects.create()
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__endswith='rb')
        self.assertFalse(q_obj.comparator(obj))
예제 #3
0
    def test_exact(self):
        q_obj = Q(secret__gem__exact='ruby')
        obj = SomeModel.objects.create()
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__exact='Ruby')
        self.assertFalse(q_obj.comparator(obj))
예제 #4
0
    def test_exact(self):
        q_obj = Q(secret__gem__exact='ruby')
        obj = SecretModel(secret=StringSecret())
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__exact='Ruby')
        self.assertFalse(q_obj.comparator(obj))
예제 #5
0
    def test_nested_contains(self):
        q_obj = Q(secret__gem__contains='ub')
        obj = SomeModel.objects.create()
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__contains='rby')
        self.assertFalse(q_obj.comparator(obj))
예제 #6
0
    def test_iexact(self):
        q_obj = Q(secret__gem__iexact='Ruby')
        obj = SomeModel.objects.create()
        self.assertTrue(q_obj.comparator(obj))

        obj = SomeModel.objects.create(secret='BUẞE')
        q_obj = Q(secret__gem__iexact='busse')
        self.assertTrue(q_obj.comparator(obj))
예제 #7
0
    def test_nested_in(self):
        obj = SecretModel(secret=NumericSecret())

        q_obj = Q(secret__gem__in=[1, 2, 3, 4, 5, 6, 7])
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__in=[1, 2, 3])
        self.assertFalse(q_obj.comparator(obj))
예제 #8
0
    def test_nested_gt(self):
        obj = SecretModel(secret=NumericSecret())

        q_obj = Q(secret__gem__gt=6)
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__gt=8)
        self.assertFalse(q_obj.comparator(obj))
예제 #9
0
    def test_iexact(self):
        q_obj = Q(secret__gem__iexact='Ruby')
        obj = SecretModel(secret=StringSecret())
        self.assertTrue(q_obj.comparator(obj))

        obj = SecretModel(secret=StringSecret('BUẞE'))
        q_obj = Q(secret__gem__iexact='busse')
        self.assertTrue(q_obj.comparator(obj))
예제 #10
0
    def test_nested_lt(self):
        obj = SomeModel.objects.create(secret=7)

        q_obj = Q(secret__gem__lt=8)
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__lt=6)
        self.assertFalse(q_obj.comparator(obj))
예제 #11
0
    def test_isnone(self):
        obj = SecretModel(question=None)

        q_obj = Q(question__isnone=True)
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__isnone=True)
        self.assertTrue(q_obj.comparator(obj))
예제 #12
0
    def test_isnull(self):
        obj = SomeModel.objects.create(question=None)

        q_obj = Q(question__isnull=True)
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__isnull=True)
        self.assertFalse(q_obj.comparator(obj))
예제 #13
0
    def test_nested_in(self):
        obj = SomeModel.objects.create(secret=7)

        q_obj = Q(secret__gem__in=[1, 2, 3, 4, 5, 6, 7])
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__in=[1, 2, 3])
        self.assertFalse(q_obj.comparator(obj))
예제 #14
0
    def test_nested_icontains(self):
        q_obj = Q(secret__gem__icontains='UB')
        obj = SecretModel(secret=StringSecret())
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__icontains='c')
        obj = SecretModel(secret=IterableSecret())
        self.assertTrue(q_obj.comparator(obj))
예제 #15
0
    def test_Q_composition_OR(self):
        Qa = Q(secret__gem__istartswith='RUB')
        Qb = Q(secret__gem__iendswith='Y')

        obj_ok = SecretModel(secret={'gem': 'ruby'})
        self.assertTrue((Qa | Qb).comparator(obj_ok))

        obj_ok2 = SecretModel(secret={'gem': 'shiny'})
        self.assertTrue((Qa | Qb).comparator(obj_ok2))
예제 #16
0
    def test_nested_contains(self):
        q_obj = Q(secret__gem__contains='ub')
        obj = SecretModel(secret=StringSecret())
        self.assertTrue(q_obj.comparator(obj))

        q_obj = Q(secret__gem__contains='rby')
        self.assertFalse(q_obj.comparator(obj))

        q_obj = Q(secret__gem__contains='C')
        obj = SecretModel(secret=IterableSecret())
        self.assertTrue(q_obj.comparator(obj))
예제 #17
0
    def filter(self, **kwargs):
        q = Q(**kwargs)

        return QuerySet(
            filter(q.comparator, self._object_store),
            model=self.model
        )
예제 #18
0
    def test_simple(self):
        q_obj = Q(question='What?')

        obj = SecretModel(question='What?')
        self.assertTrue(q_obj.comparator(obj))

        obj = SecretModel(question='When?')
        self.assertFalse(q_obj.comparator(obj))
예제 #19
0
    def test_simple(self):
        q_obj = Q(question='What?')

        obj = SomeModel.objects.create(question='What?')
        self.assertTrue(q_obj.comparator(obj))

        obj = SomeModel.objects.create(question='When?')
        self.assertFalse(q_obj.comparator(obj))
예제 #20
0
 def test_nested_icontains(self):
     q_obj = Q(secret__gem__icontains='UB')
     obj = SomeModel.objects.create()
     self.assertTrue(q_obj.comparator(obj))
예제 #21
0
 def test_nested_attrs(self):
     q_obj = Q(secret__gem='ruby')
     obj = SecretModel(secret=StringSecret())
     self.assertTrue(q_obj.comparator(obj))
예제 #22
0
 def test_nested_iin(self):
     obj = SecretModel(secret=StringSecret())
     q_obj = Q(secret__gem__iin=['RuBy', 'PeaRls', 'DiamOnds'])
     self.assertTrue(q_obj.comparator(obj))
예제 #23
0
 def test_nested_iin(self):
     obj = SomeModel.objects.create()
     q_obj = Q(secret__gem__iin=['RuBy', 'PeaRls', 'DiamOnds'])
     self.assertTrue(q_obj.comparator(obj))
예제 #24
0
 def test_nested_istartswith(self):
     q_obj = Q(secret__gem__istartswith='RUB')
     obj = SomeModel.objects.create()
     self.assertTrue(q_obj.comparator(obj))
예제 #25
0
 def test_nested_istartswith(self):
     q_obj = Q(secret__gem__istartswith='RUB')
     obj = SecretModel(secret=StringSecret())
     self.assertTrue(q_obj.comparator(obj))
예제 #26
0
 def test_nested_dict_istartswith(self):
     q_obj = Q(secret__gem__istartswith='RUB')
     obj = SecretModel(secret={'gem': 'ruby'})
     self.assertTrue(q_obj.comparator(obj))
예제 #27
0
    def filter(self, **kwargs):
        q = Q(**kwargs)

        return type(self)(filter(q.comparator, self), model=self.model)
예제 #28
0
 def test_nested_attrs(self):
     q_obj = Q(secret__gem='ruby')
     obj = SomeModel.objects.create()
     self.assertTrue(q_obj.comparator(obj))