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')
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')
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')
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(), '')