Пример #1
0
    def test_hashable(self):
        a = Operator('ab', 'is', 'input')
        b = Operator('bc', 'is', 'input')
        c = Operator('cd', 'is', 'input')

        lookup = {a: 1, b: 2, c: 3}
        assert lookup[a] == 1
Пример #2
0
    def test_operator_equality(self):
        a = Operator('eq', 'is', 'input')
        b = Operator('eq', 'is', 'input')
        c = Operator('fb', 'is', 'input')

        assert a == b
        assert a != c
Пример #3
0
    def test_string_in(self):
        a = Operator('a', 'a', 'a')
        b = Operator('b', 'b', 'b')
        c = Operator('c', 'c', 'c')
        d = Operator('d', 'd', 'd')

        assert a in (a, b, c)
        assert 'a' in (a, b, c)

        assert d not in (a, b, c)
        assert 'd' not in (a, b, c)
Пример #4
0
class YesNoFilter(FilterBase):
    operators = (
        Operator('a', 'all', None),
        Operator('y', 'yes', None),
        Operator('n', 'no', None),
    )

    def apply(self, query):
        if self.op == 'a':
            return query
        if self.op == 'y':
            return query.filter(self.sa_col == sa.true())
        if self.op == 'n':
            return query.filter(self.sa_col == sa.false())
        return FilterBase.apply(self, query)
Пример #5
0
    def test_string_equality(self):
        eq = Operator('eq', 'is', 'input')
        assert eq == 'eq'
        assert 'eq' == eq

        assert eq != '!eq'
        assert '!eq' != eq
Пример #6
0
class StatusFilter(OptionsFilterBase):
    operators = (Operator('o', _('open'), None), ops.is_, ops.not_is,
                 Operator('c', _('closed'), None), ops.empty, ops.not_empty)
    options_from = Status.pairs
Пример #7
0
 def test_self_equality(self):
     eq = Operator('eq', 'is', 'input')
     assert eq == eq