コード例 #1
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 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))
コード例 #2
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
    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))
コード例 #3
0
ファイル: test_filtering.py プロジェクト: thedrow/odin
    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)
コード例 #4
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_combine_with_other_type(self):
     flt1 = filtering.And(
         filtering.Equal('fiction', True),
         filtering.LessThan('rrp', 20),
     )
     self.assertRaises(TypeError, lambda: flt1 + 'abc')
コード例 #5
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_description(self):
     flt = filtering.And(
         filtering.Equal('fiction', True),
         filtering.LessThan('rrp', 20),
     )
     self.assertEqual('(fiction == True AND rrp < 20)', str(flt))
コード例 #6
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_resource_field_does_not_exist(self):
     flt = filtering.Equal('title', 'Public Library')
     self.assertFalse(flt(library))
コード例 #7
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_find_sub_resources(self):
     flt = filtering.Equal('fiction', True)
     # Some fiction?
     self.assertTrue(flt.any(library.books))
     # All fiction
     self.assertFalse(flt.all(library.books))
コード例 #8
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_matches_sub_resource(self):
     flt = filtering.Equal('publisher.name', 'Macmillan')
     self.assertTrue(flt(first_book))
コード例 #9
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_matches_top_level_resource(self):
     flt = filtering.Equal('title', "Consider Phlebas")
     self.assertTrue(flt(first_book))
コード例 #10
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_equal_integer(self):
     comp = filtering.Equal('foo', 5)
     self.assertTrue(comp.compare(5))
     self.assertFalse(comp.compare(6))
     self.assertEqual('foo == 5', str(comp))
コード例 #11
0
ファイル: test_filtering.py プロジェクト: sathish86/odin
 def test_equal_string(self):
     comp = filtering.Equal('foo', 'bar')
     self.assertTrue(comp.compare('bar'))
     self.assertFalse(comp.compare('eek'))
     self.assertEqual("foo == 'bar'", str(comp))
コード例 #12
0
ファイル: test_filtering.py プロジェクト: thedrow/odin
 def test_find_sub_resources(self):
     flt = filtering.Equal('fiction', True)
     # Some fiction?
     assert flt.any(library.books)
     # All fiction
     assert not flt.all(library.books)
コード例 #13
0
ファイル: test_filtering.py プロジェクト: thedrow/odin
 def test_equal_integer(self):
     comp = filtering.Equal('foo', 5)
     assert comp.compare(5)
     assert not comp.compare(6)
     assert 'foo == 5' == str(comp)
コード例 #14
0
ファイル: test_filtering.py プロジェクト: thedrow/odin
 def test_equal_string(self):
     comp = filtering.Equal('foo', 'bar')
     assert comp.compare('bar')
     assert not comp.compare('eek')
     assert "foo == 'bar'" == str(comp)