Ejemplo n.º 1
0
 def testError(self):
     """Test marking a stanza as an error."""
     stanza = StanzaBase()
     stanza['type'] = 'get'
     stanza.error()
     self.failUnless(stanza['type'] == 'error',
         "Stanza type is not 'error' after calling error()")
Ejemplo n.º 2
0
 def testError(self):
     """Test marking a stanza as an error."""
     stanza = StanzaBase()
     stanza['type'] = 'get'
     stanza.error()
     self.failUnless(stanza['type'] == 'error',
                     "Stanza type is not 'error' after calling error()")
Ejemplo n.º 3
0
    def testClear(self):
        """Test clearing a stanza."""
        stanza = StanzaBase()
        stanza['to'] = '*****@*****.**'
        stanza['payload'] = ET.Element("{foo}foo")
        stanza.clear()

        self.failUnless(stanza['payload'] == [],
            "Stanza payload was not cleared after calling .clear()")
        self.failUnless(str(stanza['to']) == "*****@*****.**",
            "Stanza attributes were not preserved after calling .clear()")
Ejemplo n.º 4
0
    def testReply(self):
        """Test creating a reply stanza."""
        stanza = StanzaBase()
        stanza["to"] = "*****@*****.**"
        stanza["from"] = "*****@*****.**"
        stanza["payload"] = ET.Element("{foo}foo")

        stanza.reply()

        self.failUnless(str(stanza["to"] == "*****@*****.**"), "Stanza reply did not change 'to' attribute.")
        self.failUnless(stanza["payload"] == [], "Stanza reply did not empty stanza payload.")
Ejemplo n.º 5
0
    def testClear(self):
        """Test clearing a stanza."""
        stanza = StanzaBase()
        stanza["to"] = "*****@*****.**"
        stanza["payload"] = ET.Element("{foo}foo")
        stanza.clear()

        self.failUnless(stanza["payload"] == [], "Stanza payload was not cleared after calling .clear()")
        self.failUnless(
            str(stanza["to"]) == "*****@*****.**", "Stanza attributes were not preserved after calling .clear()"
        )
Ejemplo n.º 6
0
    def testReply(self):
        """Test creating a reply stanza."""
        stanza = StanzaBase()
        stanza['to'] = "*****@*****.**"
        stanza['from'] = "*****@*****.**"
        stanza['payload'] = ET.Element("{foo}foo")

        stanza.reply()

        self.failUnless(str(stanza['to'] == "*****@*****.**"),
                        "Stanza reply did not change 'to' attribute.")
        self.failUnless(stanza['payload'] == [],
                        "Stanza reply did not empty stanza payload.")
Ejemplo n.º 7
0
 def testTo(self):
     """Test the 'to' interface of StanzaBase."""
     stanza = StanzaBase()
     stanza['to'] = '*****@*****.**'
     self.failUnless(
         str(stanza['to']) == '*****@*****.**',
         "Setting and retrieving stanza 'to' attribute did not work.")
Ejemplo n.º 8
0
    def testPayload(self):
        """Test the 'payload' interface of StanzaBase."""
        stanza = StanzaBase()
        self.failUnless(stanza['payload'] == [],
            "Empty stanza does not have an empty payload.")

        stanza['payload'] = ET.Element("{foo}foo")
        self.failUnless(len(stanza['payload']) == 1,
            "Stanza contents and payload do not match.")

        stanza['payload'] = ET.Element('{bar}bar')
        self.failUnless(len(stanza['payload']) == 2,
            "Stanza payload was not appended.")

        del stanza['payload']
        self.failUnless(stanza['payload'] == [],
            "Stanza payload not cleared after deletion.")

        stanza['payload'] = [ET.Element('{foo}foo'),
                             ET.Element('{bar}bar')]
        self.failUnless(len(stanza['payload']) == 2,
            "Adding multiple elements to stanza's payload did not work.")
Ejemplo n.º 9
0
 def testError(self):
     """Test marking a stanza as an error."""
     stanza = StanzaBase()
     stanza["type"] = "get"
     stanza.error()
     self.failUnless(stanza["type"] == "error", "Stanza type is not 'error' after calling error()")