Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_capsPresenceCB(self):
fjid = "user@server.com/a"
xml = """
""" % (fjid)
msg = nbxmpp.protocol.Presence(node=nbxmpp.simplexml.XML2Node(xml))
self.module._presence_received(None, msg)
def contact_goes_offline(self, account, jid, resource, prio,
still_exists = True):
'''a remote contact goes offline.'''
xml = """
%s
Goodbye!
""" % (jid, resource, prio)
msg = nbxmpp.protocol.Presence(node=nbxmpp.simplexml.XML2Node(xml))
gajim.connections[account]._presenceCB(None, msg)
contact = None
for c in gajim.contacts.get_contacts(account, jid):
if c.resource == resource:
contact = c
break
if not still_exists:
self.assertTrue(contact is None)
return
self.assertEqual('offline', contact.show)
self.assertEqual('Goodbye!', contact.status)
self.assertEqual(prio, contact.priority)
def receive_chat_msg(self, jid, msgtxt):
'''simulate receiving a chat message from jid'''
msg = nbxmpp.Message()
msg.setBody(msgtxt)
msg.setType('chat')
xml = """%s
123""" % (jid, msgtxt)
stanza = nbxmpp.protocol.Message(node=nbxmpp.simplexml.XML2Node(xml))
self.conn._messageCB(None, stanza)
def contact_comes_online(self, account, jid, resource, prio,
should_popup=True):
'''a remote contact comes online'''
xml = """%s
I'm back!
""" % (jid, resource, prio)
msg = nbxmpp.protocol.Presence(node=nbxmpp.simplexml.XML2Node(xml))
gajim.connections[account]._presenceCB(None, msg)
contact = None
for c in gajim.contacts.get_contacts(account, jid):
if c.resource == resource:
contact = c
break
self.assertEqual('online', contact.show)
self.assertEqual("I'm back!", contact.status)
self.assertEqual(prio, contact.priority)
# the most recent notification is that the contact connected
if should_popup:
self.assertEqual('Contact Signed In',
notify.notifications[-1].popup_event_type)