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
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
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)
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)
def test_string_equality(self): eq = Operator('eq', 'is', 'input') assert eq == 'eq' assert 'eq' == eq assert eq != '!eq' assert '!eq' != eq
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
def test_self_equality(self): eq = Operator('eq', 'is', 'input') assert eq == eq