'Test getStanzaValues using plugins and substanzas.'

def testGetStanzaValues(self):

    class TestStanzaPlugin(ElementBase, ):
        name = 'foo2'
        namespace = 'foo'
        interfaces = set(('bar', 'baz'))
        plugin_attrib = 'foo2'
    class TestSubStanza(ElementBase, ):
        name = 'subfoo'
        namespace = 'foo'
        interfaces = set(('bar', 'baz'))
    class TestStanza(ElementBase, ):
        name = 'foo'
        namespace = 'foo'
        interfaces = set(('bar', 'baz'))
    register_stanza_plugin(TestStanza, TestStanzaPlugin, iterable=True)
    stanza = TestStanza()
    stanza['bar'] = 'a'
    stanza['foo2']['baz'] = 'b'
    substanza = TestSubStanza()
    substanza['bar'] = 'c'
    stanza.append(substanza)
    values = stanza.getStanzaValues()
    expected = {'lang': '', 'bar': 'a', 'baz': '', 'foo2': {'lang': '', 'bar': '', 'baz': 'b'}, 'substanzas': [{'__childtag__': '{foo}foo2', 'lang': '', 'bar': '', 'baz': 'b'}, {'__childtag__': '{foo}subfoo', 'lang': '', 'bar': 'c', 'baz': ''}]}
    self.failUnless((values == expected), ('Unexpected    stanza    values:\n%s\n%s' % (str(expected), str(values))))
