'Test that the changed_status event is handled properly.'

def test_changed_status(self):

    events = []
    def changed_status(presence):
        events.append(presence['type'])
    self.xmpp.add_event_handler('changed_status', changed_status)
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>away</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>away</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>dnd</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>dnd</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>chat</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>chat</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>xa</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>xa</show>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"\n                                                                                to="tester@localhost"\n                                                                                type="unavailable"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"\n                                                                                to="tester@localhost"\n                                                                                type="unavailable"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost"    />\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <status>Testing!</status>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <status>Testing!</status>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>dnd</show>\n                                                <status>Testing!</status>\n                                        </presence>\n                                ')
    self.recv('\n                                        <presence    from="user@example.com"    to="tester@localhost">\n                                                <show>dnd</show>\n                                                <status>Testing!</status>\n                                        </presence>\n                                ')
    time.sleep(0.3)
    self.assertEqual(events, ['available', 'away', 'dnd', 'chat', 'xa', 'unavailable', 'available', 'available', 'dnd'], ('Changed    status    events    incorrect:    %s' % events))
