Ejemplo n.º 1
0
    def test_combining_same_type(self):
        flt1 = filtering.And(
            filtering.Equal('fiction', True),
            filtering.LessThan('rrp', 20),
        )
        flt2 = filtering.And(
            filtering.Equal('authors', 1, len),
            filtering.NotEqual('genre', 'fantasy'),
        )
        flt = flt1 + flt2

        assert "(fiction == True AND rrp < 20 AND len(authors) == 1 AND genre != 'fantasy')" == str(
            flt)
Ejemplo n.º 2
0
    def test_combine_with_comparison(self):
        flt1 = filtering.And(
            filtering.Equal('fiction', True),
            filtering.LessThan('rrp', 20),
        )
        flt = flt1 + filtering.Equal('authors', 1, len)

        self.assertEqual(
            "(fiction == True AND rrp < 20 AND len(authors) == 1)", str(flt))
Ejemplo n.º 3
0
 def test_matches_multiple_matches_resource(self):
     # Less than fiction $20 with a single author and not fantasy
     flt = filtering.And(
         filtering.Equal('fiction', True),
         filtering.LessThan('rrp', 20),
         filtering.Equal('authors', 1, len),
         filtering.NotEqual('genre', 'fantasy'),
     )
     self.assertTrue(flt(first_book))
Ejemplo n.º 4
0
 def test_combine_with_other_type(self):
     flt1 = filtering.And(
         filtering.Equal('fiction', True),
         filtering.LessThan('rrp', 20),
     )
     self.assertRaises(TypeError, lambda: flt1 + 'abc')
Ejemplo n.º 5
0
 def test_description(self):
     flt = filtering.And(
         filtering.Equal('fiction', True),
         filtering.LessThan('rrp', 20),
     )
     self.assertEqual('(fiction == True AND rrp < 20)', str(flt))
Ejemplo n.º 6
0
 def test_empty_description(self):
     flt = filtering.And()
     self.assertEqual('', str(flt))
Ejemplo n.º 7
0
 def test_empty_description(self):
     flt = filtering.And()
     assert '' == str(flt)