'Test matching a stanza against an XPath expression.'

def testMatch(self):

    class TestSubStanza(ElementBase, ):
        name = 'sub'
        namespace = 'baz'
        interfaces = set(('attrib',))
    class TestStanza(ElementBase, ):
        name = 'foo'
        namespace = 'foo'
        interfaces = set(('bar', 'baz', 'qux'))
        sub_interfaces = set(('qux',))
        def setQux(self, value):
            self._set_sub_text('qux', text=value)
        def getQux(self):
            return self._get_sub_text('qux')
    class TestStanzaPlugin(ElementBase, ):
        name = 'plugin'
        namespace = 'http://test/slash/bar'
        interfaces = set(('attrib',))
    register_stanza_plugin(TestStanza, TestSubStanza, iterable=True)
    register_stanza_plugin(TestStanza, TestStanzaPlugin)
    stanza = TestStanza()
    self.failUnless(stanza.match('foo'), 'Stanza    did    not    match    its    own    tag    name.')
    self.failUnless(stanza.match('{foo}foo'), 'Stanza    did    not    match    its    own    namespaced    name.')
    stanza['bar'] = 'a'
    self.failUnless(stanza.match('foo@bar=a'), 'Stanza    did    not    match    its    own    name    with    attribute    value    check.')
    stanza['baz'] = 'b'
    self.failUnless(stanza.match('foo@bar=a@baz=b'), 'Stanza    did    not    match    its    own    name    with    multiple    attributes.')
    stanza['qux'] = 'c'
    self.failUnless(stanza.match('foo/qux'), 'Stanza    did    not    match    with    subelements.')
    stanza['qux'] = ''
    self.failUnless((stanza.match('foo/qux') == False), 'Stanza    matched    missing    subinterface    element.')
    self.failUnless((stanza.match('foo/bar') == False), 'Stanza    matched    nonexistent    element.')
    stanza['plugin']['attrib'] = 'c'
    self.failUnless(stanza.match('foo/plugin@attrib=c'), 'Stanza    did    not    match    with    plugin    and    attribute.')
    self.failUnless(stanza.match('foo/{http://test/slash/bar}plugin'), 'Stanza    did    not    match    with    namespaced    plugin.')
    substanza = TestSubStanza()
    substanza['attrib'] = 'd'
    stanza.append(substanza)
    self.failUnless(stanza.match('foo/sub@attrib=d'), 'Stanza    did    not    match    with    substanzas    and    attribute.')
    self.failUnless(stanza.match('foo/{baz}sub'), 'Stanza    did    not    match    with    namespaced    substanza.')
