def test_hashable(self): """ Test JID hashability. """ j1 = jid.JID("user@host/resource") j2 = jid.JID("user@host/resource") self.assertEqual(hash(j1), hash(j2))
def test_inequality(self): """ Test JID inequality. """ j1 = jid.JID("user1@host/resource") j2 = jid.JID("user2@host/resource") self.assertNotEqual(j1, j2)
def test_equality(self): """ Test JID equality. """ j1 = jid.JID("user@host/resource") j2 = jid.JID("user@host/resource") self.assertNotIdentical(j1, j2) self.assertEqual(j1, j2)
def test_sendHeaderInitiating(self): """ Test addressing when initiating a stream. """ xs = self.xmlstream xs.thisEntity = jid.JID('thisHost') xs.otherEntity = jid.JID('otherHost') xs.initiating = True xs.sendHeader() splitHeader = xs.transport.value()[0:-1].split(' ') self.assertIn("to='otherhost'", splitHeader) self.assertIn("from='thishost'", splitHeader)
def test_userhostJID(self): """ Test getting a JID object of the bare JID. """ j1 = jid.JID("user@host/resource") j2 = jid.internJID("user@host") self.assertIdentical(j2, j1.userhostJID())
def test_attributes(self): """ Test that the attributes correspond with the JID parts. """ j = jid.JID("user@host/resource") self.assertEquals(j.user, "user") self.assertEquals(j.host, "host") self.assertEquals(j.resource, "resource")
def test_notAcceptableWithoutUser(self): """ Test using an unacceptable SASL authentication mechanism with no JID. """ self.authenticator.jid = jid.JID('example.com') self.authenticator.password = '******' self.assertRaises(sasl.SASLNoAcceptableMechanism, self._setMechanism, 'SOMETHING_UNACCEPTABLE')
def test_plain(self): """ Test setting PLAIN as the authentication mechanism. """ self.authenticator.jid = jid.JID('*****@*****.**') self.authenticator.password = '******' name = "PLAIN" self.assertEqual(name, self._setMechanism(name))
def test_digest(self): """ Test setting DIGEST-MD5 as the authentication mechanism. """ self.authenticator.jid = jid.JID('*****@*****.**') self.authenticator.password = '******' name = "DIGEST-MD5" self.assertEqual(name, self._setMechanism(name))
def test_anonymous(self): """ Test setting ANONYMOUS as the authentication mechanism. """ self.authenticator.jid = jid.JID('example.com') self.authenticator.password = None name = "ANONYMOUS" self.assertEqual(name, self._setMechanism(name))
def test_userhost(self): """ Test the extraction of the bare JID. """ j = jid.JID("user@host/resource") self.assertEquals("user@host", j.userhost())
def test_userhostJIDNoResource(self): """ Test getting a JID object of the bare JID when there was no resource. """ j = jid.JID("user@host") self.assertIdentical(j, j.userhostJID())
def test_repr(self): """ Test representation of JID objects. """ j = jid.JID(tuple=('user', 'host', 'resource')) self.assertEquals("JID(u'user@host/resource')", repr(j))
def test_fullHost(self): """ Test giving a string representation of the JID with only a host part. """ j = jid.JID(tuple=(None, 'host', None)) self.assertEqual('host', j.full())
def test_fullHostResource(self): """ Test giving a string representation of the JID with host, resource. """ j = jid.JID(tuple=(None, 'host', 'resource')) self.assertEqual('host/resource', j.full())
def test_unicode(self): """ Test unicode representation of JIDs. """ j = jid.JID(tuple=('user', 'host', 'resource')) self.assertEquals("user@host/resource", unicode(j))
def test_inequalityWithNonJIDs(self): """ Test JID equality. """ j = jid.JID("user@host/resource") self.assertNotEqual(j, 'user@host/resource')
def test_userhostOnlyHost(self): """ Test the extraction of the bare JID of the full form host/resource. """ j = jid.JID("host/resource") self.assertEquals("host", j.userhost())
def test_equalityWithNonJIDs(self): """ Test JID equality. """ j = jid.JID("user@host/resource") self.assertFalse(j == 'user@host/resource')
def test_fullUserHost(self): """ Test giving a string representation of the JID with user, host. """ j = jid.JID(tuple=('user', 'host', None)) self.assertEqual('user@host', j.full())
def test_fullAll(self): """ Test giving a string representation of the JID. """ j = jid.JID(tuple=('user', 'host', 'resource')) self.assertEqual('user@host/resource', j.full())