示例#1
0
    def testSimple(self):
        fi = mafw.Filter(mafw.F_AND)
        self.assertEqual(len(fi.parts), 0)

        fi.add_children(mafw.Filter(mafw.F_EQ, 'att', 'vvv'))
        self.assertEqual(len(fi.parts), 1)

        fi.add_children(mafw.Filter(mafw.F_LT, 'yyy', 'xxx'))
        self.assertEqual(len(fi.parts), 2)

        self.assertEqual(fi.parts[0].key(), 'att')
        self.assertEqual(fi.parts[0].value(), 'vvv')

        self.assertEqual(fi.parts[1].type(), mafw.F_LT)
        self.assertEqual(fi.parts[1].key(), 'yyy')
        self.assertEqual(fi.parts[1].value(), 'xxx')
示例#2
0
    def testBasic(self):
        fi = mafw.Filter.parse('(artist=belga')

        self.assertEqual(fi.type(), mafw.F_EQ)
        self.assertEqual(fi.key(), 'artist')
        self.assertEqual(fi.value(), 'belga')

        fi = mafw.Filter('(publication-year<1999)')
        self.assertEqual(fi.type(), mafw.F_LT)
        self.assertEqual(fi.key(), 'publication-year')
        self.assertEqual(fi.value(), '1999')
示例#3
0
 def testWithPair(self):
     fi = mafw.Filter(mafw.F_EQ, 'key', 'value')
     self.assert_(isinstance(fi, mafw.Filter))
     self.assertEqual(fi.type(), mafw.F_EQ)
     self.assertEqual(fi.key(), 'key')
     self.assertEqual(fi.value(), 'value')
示例#4
0
 def testJustType(self):
     fi = mafw.Filter(mafw.F_EQ)
     self.assert_(isinstance(fi, mafw.Filter))
     self.assertEqual(fi.type(), mafw.F_EQ)
     self.assertEqual(fi.key(), '')
     self.assertEqual(fi.value(), '')