'Test accessing stanza interfaces.'

def testGetItem(self):

    class TestStanza(ElementBase, ):
        name = 'foo'
        namespace = 'foo'
        interfaces = set(('bar', 'baz', 'qux'))
        sub_interfaces = set(('baz',))
        def getQux(self):
            return 'qux'
    class TestStanzaPlugin(ElementBase, ):
        name = 'foobar'
        namespace = 'foo'
        plugin_attrib = 'foobar'
        interfaces = set(('fizz',))
    register_stanza_plugin(TestStanza, TestStanza, iterable=True)
    register_stanza_plugin(TestStanza, TestStanzaPlugin)
    stanza = TestStanza()
    substanza = TestStanza()
    stanza.append(substanza)
    stanza.setStanzaValues({'bar': 'a', 'baz': 'b', 'qux': 42, 'foobar': {'fizz': 'c'}})
    expected = {'substanzas': [substanza], 'bar': 'a', 'baz': 'b', 'qux': 'qux', 'meh': ''}
    for (interface, value) in expected.items():
        result = stanza[interface]
        self.failUnless((result == value), ('Incorrect    stanza    interface    access    result:    %s' % result))
    self.failUnless(isinstance(stanza['foobar'], TestStanzaPlugin), 'Incorrect    plugin    object    result.')
    self.failUnless((stanza['foobar']['fizz'] == 'c'), 'Incorrect    plugin    subvalue    result.')
