Ignore:
Timestamp:
Oct 6, 2008, 10:56:52 PM (14 years ago)
Author:
Christopher Zorn <tofu@…>
Branch:
wokkel-muc-client-support-24
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/branches/wokkel-muc-client-support-24@76
Message:

all tests pass, needs comments, also need to get the entire xep in the tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_muc.py

    r111 r112  
    5555        self.room_jid = JID(self.test_room+'@'+self.test_srv+'/'+self.test_nick)
    5656
     57        self.user_jid = JID('test@jabber.org/Testing')
     58
    5759    def test_interface(self):
    5860        """
     
    167169
    168170    def test_partRoom(self):
    169         self.fail('Not Implemented')
     171       
     172        def cb(left):
     173            self.failUnless(left, 'did not leave room')
     174
     175
     176        d = self.protocol.leave(self.room_jid)
     177        d.addCallback(cb)
     178
     179        prs = self.stub.output[-1]
     180       
     181        self.failUnless(prs['type']=='unavailable', 'Unavailable is not being sent')
     182       
     183        response = prs
     184        response['from'] = response['to']
     185        response['to'] = 'test@jabber.org'
     186
     187        self.stub.send(response)
     188        return d
    170189       
    171190
    172191    def test_ban(self):
    173192       
    174         self.fail('Not Implemented')
     193        banned = JID('ban@jabber.org/TroubleMakger')
     194        def cb(banned):
     195            self.failUnless(banned, 'Did not ban user')
     196
     197           
     198        d = self.protocol.ban(self.room_jid, banned, self.user_jid, reason='Spam')
     199        d.addCallback(cb)
     200
     201        iq = self.stub.output[-1]
     202       
     203        self.failUnless(xpath.matches("/iq[@type='set' and @to='%s']/query/item[@affiliation='outcast']" % (self.room_jid.userhost(),), iq), 'Wrong ban stanza')
     204
     205        response = toResponse(iq, 'result')
     206
     207        self.stub.send(response)
     208
     209        return d
     210
    175211
    176212    def test_kick(self):
     213
     214        kicked = JID('kick@jabber.org/TroubleMakger')
     215        def cb(kicked):
     216            self.failUnless(kicked, 'Did not kick user')
     217
     218           
     219        d = self.protocol.kick(self.room_jid, kicked, self.user_jid, reason='Spam')
     220        d.addCallback(cb)
     221
     222        iq = self.stub.output[-1]
     223       
     224        self.failUnless(xpath.matches("/iq[@type='set' and @to='%s']/query/item[@affiliation='none']" % (self.room_jid.userhost(),), iq), 'Wrong kick stanza')
     225
     226        response = toResponse(iq, 'result')
     227
     228        self.stub.send(response)
     229
     230        return d
     231
    177232        self.fail('Not Implemented')
    178233       
     
    182237        """
    183238       
    184        
    185         self.fail('Not Implemented')
     239        self.protocol.password(self.room_jid, 'secret')
     240       
     241        prs = self.stub.output[-1]
     242       
     243        self.failUnless(xpath.matches("/presence[@to='%s']/x/password[text()='secret']" % (self.room_jid.full(),), prs), 'Wrong presence stanza')
     244
    186245
    187246    def test_history(self):
    188        
    189         self.fail('Not Implemented')
     247        """Test receiving history on room join.
     248        """
     249        m = muc.HistoryMessage(self.room_jid.userhost(), self.protocol._makeTimeStamp(), body='test')
     250       
     251        def roomHistory(h):
     252            self.failUnless(getattr(h,'delay',None), 'No delay element')
     253                   
     254
     255        d, self.protocol.receivedHistory = calledAsync(roomHistory)
     256        self.stub.send(m)
     257        return d
    190258
    191259
     
    223291
    224292    def test_invite(self):
    225         self.fail('Not Implemented')
     293        other_jid = 'test@jabber.org'
     294
     295        self.protocol.invite(other_jid, 'This is a test')
     296
     297        msg = self.stub.output[-1]
     298
     299        self.failUnless(xpath.matches("/message[@to='%s']/x/invite/reason" % (other_jid,), msg), 'Wrong message type')
     300
    226301
    227302       
    228303    def test_privateMessage(self):
    229        
    230         self.fail('Not Implemented')
     304        """Test sending private messages to muc entities.
     305        """
     306        other_nick = self.room_jid.userhost()+'/OtherNick'
     307
     308        self.protocol.chat(other_nick, 'This is a test')
     309
     310        msg = self.stub.output[-1]
     311
     312        self.failUnless(xpath.matches("/message[@type='chat' and @to='%s']/body" % (other_nick,), msg), 'Wrong message type')
     313
    231314
    232315    def test_register(self):
Note: See TracChangeset for help on using the changeset viewer.