def test_and_or(self): self.assertEqual('a and b and c', XPath.and_('a', 'b', 'c')) self.assertEqual('a and (b and c)', XPath.and_('a', XPath.and_('b', 'c'))) self.assertEqual('a or b or c', XPath.or_('a', 'b', 'c')) self.assertEqual('(a or b) or c', XPath.or_(XPath.or_('a', 'b'), XPath('c')))
def test_complex(self): xp = XPath.and_( XPath('a').eq('1'), XPath('b').neq(XPath.string('')), XPath.or_( XPath('c').eq(XPath.string('')), XPath.date('d').neq('today()') )) self.assertEqual("a = 1 and b != '' and (c = '' or date(d) != today())", xp)
def test_complex(self): xp = XPath.and_( XPath('a').eq('1'), XPath('b').neq(XPath.string('')), XPath.or_( XPath('c').eq(XPath.string('')), XPath.date('d').neq('today()'))) self.assertEqual( "a = 1 and b != '' and (c = '' or date(d) != today())", xp)
def test_not(self): self.assertEqual('not a', XPath.not_('a')) self.assertEqual('not (a or b)', XPath.not_(XPath.or_('a', 'b')))