def test_on_changed(jid): agent = MockedPresenceAgentFactory() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE, show=PresenceShow.CHAT) agent.presence.presenceclient.handle_presence(stanza) contact = agent.presence.get_contact(jid) assert contact["name"] == "My Friend" assert contact["presence"].show == PresenceShow.CHAT stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE, show=PresenceShow.AWAY) agent.presence.presenceclient.handle_presence(stanza) contact = agent.presence.get_contact(jid) assert contact["name"] == "My Friend" assert contact["presence"].show == PresenceShow.AWAY
def test_on_changed(jid): agent = make_presence_connected_agent() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE, show=PresenceShow.CHAT) agent.presence.presenceclient.handle_presence(stanza) contact = agent.presence.get_contact(jid) assert contact["name"] == "My Friend" assert contact["presence"].show == PresenceShow.CHAT stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE, show=PresenceShow.AWAY) agent.presence.presenceclient.handle_presence(stanza) contact = agent.presence.get_contact(jid) assert contact["name"] == "My Friend" assert contact["presence"].show == PresenceShow.AWAY
def test_on_changed(jid): agent = make_presence_connected_agent() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE, show=PresenceShow.CHAT) agent.presence.presenceclient.handle_presence(stanza) contact = agent.presence.get_contact(jid) assert contact["name"] == "My Friend" assert contact["presence"].show == PresenceShow.CHAT stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE, show=PresenceShow.AWAY) agent.presence.presenceclient.handle_presence(stanza) contact = agent.presence.get_contact(jid) assert contact["name"] == "My Friend" assert contact["presence"].show == PresenceShow.AWAY
def add_fake_contact(self, jid, presence, show=None): jid = JID.fromstr(jid) item = Item(jid=jid) item.approved = True self.presence.roster._update_entry(item) if show: stanza = Presence(from_=jid, type_=presence, show=show) else: stanza = Presence(from_=jid, type_=presence) self.presence.presenceclient.handle_presence(stanza)
def test_get_contact(jid): agent = make_presence_connected_agent() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) contact = agent.presence.get_contact(jid) assert type(contact) == dict assert contact["approved"] assert contact["name"] == "My Friend" assert contact["subscription"] == 'none' assert "ask" not in contact assert "groups" not in contact
def test_get_contacts_with_presence_unavailable(jid): agent = make_presence_connected_agent() item = XSOItem(jid=jid) item.approved = True item.name = "My UnAvailable Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.UNAVAILABLE) agent.presence.presenceclient.handle_presence(stanza) contacts = agent.presence.get_contacts() assert jid in contacts assert contacts[jid]["name"] == "My UnAvailable Friend" assert "presence" not in contacts[jid]
def test_get_contact(jid): agent = MockedPresenceAgentFactory() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) contact = agent.presence.get_contact(jid) assert type(contact) == dict assert contact["approved"] assert contact["name"] == "My Friend" assert contact["subscription"] == 'none' assert "ask" not in contact assert "groups" not in contact
def test_get_contact(jid): agent = make_presence_connected_agent() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) contact = agent.presence.get_contact(jid) assert type(contact) == dict assert contact["approved"] assert contact["name"] == "My Friend" assert contact["subscription"] == 'none' assert "ask" not in contact assert "groups" not in contact
def test_get_contacts_with_presence_on_and_off(jid): agent = make_presence_connected_agent() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE) agent.presence.presenceclient.handle_presence(stanza) stanza = Presence(from_=jid, type_=PresenceType.UNAVAILABLE) agent.presence.presenceclient.handle_presence(stanza) contacts = agent.presence.get_contacts() bare_jid = jid.bare() assert bare_jid in contacts assert contacts[bare_jid]["name"] == "My Friend" assert contacts[bare_jid]["presence"].type_ == PresenceType.UNAVAILABLE
def test_get_contacts_with_presence_unavailable(jid): agent = MockedPresenceAgentFactory() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My UnAvailable Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.UNAVAILABLE) agent.presence.presenceclient.handle_presence(stanza) contacts = agent.presence.get_contacts() bare_jid = jid.bare() assert bare_jid in contacts assert contacts[bare_jid]["name"] == "My UnAvailable Friend" assert "presence" not in contacts[bare_jid]
def test_get_contacts(jid): agent = make_presence_connected_agent() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" agent.presence.roster._update_entry(item) contacts = agent.presence.get_contacts() bare_jid = jid.bare() assert bare_jid in contacts assert type(contacts[bare_jid]) == dict assert contacts[bare_jid]["approved"] assert contacts[bare_jid]["name"] == "My Friend" assert contacts[bare_jid]["subscription"] == 'none' assert "ask" not in contacts[bare_jid] assert "groups" not in contacts[bare_jid]
def test_get_contacts_with_presence_unavailable(jid): agent = make_presence_connected_agent() future = agent.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My UnAvailable Friend" agent.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.UNAVAILABLE) agent.presence.presenceclient.handle_presence(stanza) contacts = agent.presence.get_contacts() bare_jid = jid.bare() assert bare_jid in contacts assert contacts[bare_jid]["name"] == "My UnAvailable Friend" assert "presence" not in contacts[bare_jid]
def test_get_contacts_with_presence_on_and_off(jid): artifact = MockedConnectedArtifactFactory() future = artifact.start(auto_register=False) future.result() item = XSOItem(jid=jid) item.approved = True item.name = "My Friend" artifact.presence.roster._update_entry(item) stanza = Presence(from_=jid, type_=PresenceType.AVAILABLE) artifact.presence.presenceclient.handle_presence(stanza) stanza = Presence(from_=jid, type_=PresenceType.UNAVAILABLE) artifact.presence.presenceclient.handle_presence(stanza) contacts = artifact.presence.get_contacts() bare_jid = jid.bare() assert bare_jid in contacts assert contacts[bare_jid]["name"] == "My Friend" assert contacts[bare_jid]["presence"].type_ == PresenceType.UNAVAILABLE