def test_iregex_generates_the_right_expression_for_the_iregex_lookup_when_comparing_to_a_field(self):
        field1 = NaturalQueryDescriptor('field1')
        field2 = NaturalQueryDescriptor('field2')

        expected = Q(field1__iregex=F('field2'))

        actual = field1.iregex(field2)

        self.assertEqual(actual, expected)
Пример #2
0
    def test_cant_or_expressions_when_braces_are_not_present(self):
        field1 = NaturalQueryDescriptor('field1')
        field2 = NaturalQueryDescriptor('field2')

        expected = Q(field1__exact=sentinel.VALUE1) | Q(
            field2__exact=sentinel.VALUE2)

        actual = field1 == sentinel.VALUE1 | field2 == sentinel.VALUE2

        self.assertEqual(actual, expected)
Пример #3
0
    def test_iregex_generates_the_right_expression_for_the_iregex_lookup_when_comparing_to_a_field(
            self):
        field1 = NaturalQueryDescriptor('field1')
        field2 = NaturalQueryDescriptor('field2')

        expected = Q(field1__iregex=F('field2'))

        actual = field1.iregex(field2)

        self.assertEqual(actual, expected)
Пример #4
0
    def test_between_generates_the_right_expression_for_the_range_lookup_when_comparing_to_a_field(
            self):
        sut = self.system_under_test
        field2 = NaturalQueryDescriptor('field2')

        expected = Q(field__range=(sentinel.VALUE, F('field2')))

        actual = sut.between(sentinel.VALUE, field2)

        self.assertEqual(actual, expected)
Пример #5
0
    def system_under_test(self):
        sut = NaturalQueryDescriptor('field')

        return sut
Пример #6
0
 def field(self):
     return NaturalQueryDescriptor(name=sentinel.FIELD_NAME)