def test_version_user(self): environ = {'xmpp.body': 'version that@guy', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat'} with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [u"who's that?"])
def test_dont_pass_anything_for_others(self): environ = {'xmpp.stanza': 'presence', 'xmpp.jid': 'bar', 'type': 'available'} with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [])
def test_version_user_ru(self): environ = {'xmpp.body': u'версия that@guy', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat'} with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [u"а это еще кто?"])
def test_pass_message_on_available_presence(self): environ = {'xmpp.stanza': 'presence', 'xmpp.jid': 'foo', 'type': 'available'} with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [self.expected])
def test_pass_message_on_available_presence(self): environ = { 'xmpp.stanza': 'presence', 'xmpp.jid': 'foo', 'type': 'available' } with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [self.expected])
def test_dont_pass_anything_for_others(self): environ = { 'xmpp.stanza': 'presence', 'xmpp.jid': 'bar', 'type': 'available' } with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [])
def test_version_hidden_ru(self): environ = {'xmpp.body': u'версия', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat'} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(None) self.assertEquals(rv, u"он зашифровался")
def test_version_user_in_muc(self): environ = {'xmpp.body': 'version tasman', 'xmpp.jid': JID('[email protected]/somebody'), 'xmpp.stanza_type': 'groupchat'} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') self.assertEqual(payload['jid'], '[email protected]/tasman')
def test_version_user_ru(self): environ = { 'xmpp.body': u'версия that@guy', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat' } with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [u"а это еще кто?"])
def test_version_hidden(self): environ = {'xmpp.body': u'version', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat'} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(None) self.assertEquals(rv, u"seems he's hiding from NSA")
def test_version_user(self): environ = { 'xmpp.body': 'version that@guy', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat' } with app.request_context(environ): rv = app(environ) self.assertEqual(list(rv), [u"who's that?"])
def test_version_no_ver(self): environ = {'xmpp.body': 'version', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat'} info = {'os': 'Linux', 'name': '', 'version': ''} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(info) self.assertEquals(rv, u'[no name] [no ver] @ {os}'.format(**info))
def test_version_user_in_muc(self): environ = { 'xmpp.body': 'version tasman', 'xmpp.jid': JID('[email protected]/somebody'), 'xmpp.stanza_type': 'groupchat' } with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') self.assertEqual(payload['jid'], '[email protected]/tasman')
def test_version_ru(self): environ = {'xmpp.body': u'версия', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat'} info = {'os': 'Linux', 'name': 'xmppflask', 'version': '1.0'} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(info) self.assertEquals(rv, u'{name} {version} @ {os}'.format(**info))
def test_version_hidden_ru(self): environ = { 'xmpp.body': u'версия', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat' } with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(None) self.assertEquals(rv, u"он зашифровался")
def test_version_hidden(self): environ = { 'xmpp.body': u'version', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat' } with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(None) self.assertEquals(rv, u"seems he's hiding from NSA")
def test_version_no_ver(self): environ = { 'xmpp.body': 'version', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat' } info = {'os': 'Linux', 'name': '', 'version': ''} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(info) self.assertEquals(rv, u'[no name] [no ver] @ {os}'.format(**info))
def test_version_ru(self): environ = { 'xmpp.body': u'версия', 'xmpp.jid': JID('*****@*****.**'), 'xmpp.stanza_type': 'chat' } info = {'os': 'Linux', 'name': 'xmppflask', 'version': '1.0'} with app.request_context(environ): rv = app(environ) cmd, payload = rv.next() self.assertEqual(cmd, 'version') rv = rv.send(info) self.assertEquals(rv, u'{name} {version} @ {os}'.format(**info))