Ignore:
Timestamp:
Oct 7, 2008, 11:47:13 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@83
Message:

some documentation and additions to the interface, also some more abstraction and tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_muc.py

    r112 r113  
    5757        self.user_jid = JID('test@jabber.org/Testing')
    5858
     59    def _createRoom(self):
     60        # create a room
     61        self.current_room = muc.Room(self.test_room, self.test_srv, self.test_nick)
     62        self.protocol._setRoom(self.current_room)
     63
     64
    5965    def test_interface(self):
    6066        """
     
    6470
    6571
    66     def test_presence(self):
    67         """Test receiving room presence
     72    def test_userJoinedRoom(self):
     73        """Test receiving a user joined event.
    6874        """
    6975        p = muc.UserPresence()
     76        p['to'] = self.user_jid.full()
     77        p['from'] = self.room_jid.full()
     78
     79        # create a room
     80        self._createRoom()
     81
     82        def userPresence(room, user):
     83            self.failUnless(room.name==self.test_room, 'Wrong room name')
     84            self.failUnless(room.inRoster(user), 'User not in roster')
     85                           
    7086       
    71         def userPresence(prs):
    72             self.failUnless(len(prs.children)==1, 'Not enough children')
    73             self.failUnless(getattr(prs,'x',None), 'No x element')
    74                    
    75        
    76         d, self.protocol.receivedUserPresence = calledAsync(userPresence)
     87        d, self.protocol.userJoinedRoom = calledAsync(userPresence)
    7788        self.stub.send(p)
    7889        return d
     
    8394        """
    8495        m = muc.GroupChat('test@test.com',body='test')
    85        
    86         def groupChat(elem):
    87             self.failUnless(elem.name=='message','Wrong stanza')
    88             self.failUnless(elem['type'] == 'groupchat', 'Wrong attribute')
     96        m['from'] = self.room_jid.full()
     97
     98        self._createRoom()
     99
     100        def groupChat(room, user, message):
     101            self.failUnless(message=='test', "Wrong group chat message")
     102            self.failUnless(room.name==self.test_room, 'Wrong room name')
    89103                           
    90104       
     
    230244        return d
    231245
    232         self.fail('Not Implemented')
    233246       
    234247
     
    248261        """
    249262        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')
     263        m['from'] = self.room_jid.full()
     264       
     265        self._createRoom()
     266
     267        def roomHistory(room, user, body, stamp, frm=None):
     268            self.failUnless(body=='test', "wrong message body")
     269            self.failUnless(stamp, 'Does not have a history stamp')
    253270                   
    254271
Note: See TracChangeset for help on using the changeset viewer.