Example #1
0
 def wb_get_receiver_list(self, language):
     receiver_list = yield wbtip.get_receiver_list_wb(
         self.wb_tip_id, language)
     self.assertEqual(len(receiver_list), 2)
     self.assertEqual(
         receiver_list[0]['access_counter'] +
         receiver_list[1]['access_counter'], 2)
Example #2
0
    def do_wb_messages(self):

        before = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        # the direct message has been sent to the receiver 1, and receiver 1
        # is on the element [0] of the list.
        self.assertEqual(len(before), 2)
        self.assertEqual(before[0]['message_counter'], 0)

        msgrequest = {'content': u'a msg from wb to receiver1'}
        x = yield wbtip.create_message_wb(self.wb_tip_id,
                                          self.receiver1_desc['id'],
                                          msgrequest)

        self.assertEqual(x['author'], u'whistleblower')

        after = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        for receivers_message in after:
            if receivers_message['id'] == self.receiver1_desc['id']:
                self.assertEqual(receivers_message['message_counter'], 1)
            else:
                self.assertEqual(receivers_message['message_counter'], 0)

        # and now, two messages for the second receiver
        msgrequest = {'content': u'#1/2 msg from wb to receiver2'}
        yield wbtip.create_message_wb(self.wb_tip_id,
                                      self.receiver2_desc['id'], msgrequest)
        msgrequest = {'content': u'#2/2 msg from wb to receiver2'}
        yield wbtip.create_message_wb(self.wb_tip_id,
                                      self.receiver2_desc['id'], msgrequest)

        end = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        for receivers_message in end:
            if receivers_message['id'] == self.receiver2_desc['id']:
                self.assertEqual(receivers_message['message_counter'], 2)
            else:  # the messages from Receiver1 are not changed, right ?
                self.assertEqual(receivers_message['message_counter'], 1)
Example #3
0
    def do_wb_messages(self):

        before = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')


        # the direct message has been sent to the receiver 1, and receiver 1
        # is on the element [0] of the list.
        self.assertEqual(len(before), 2)
        self.assertEqual(before[0]['message_counter'], 0)

        msgrequest = { 'content': u'a msg from wb to receiver1' }
        x = yield wbtip.create_message_wb(self.wb_tip_id,
                                          self.receiver1_desc['id'], msgrequest)

        self.assertEqual(x['author'], u'whistleblower')

        after = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        for receivers_message in after:
            if receivers_message['id'] == self.receiver1_desc['id']:
                self.assertEqual(receivers_message['message_counter'], 1)
            else:
                self.assertEqual(receivers_message['message_counter'], 0)

        # and now, two messages for the second receiver
        msgrequest = { 'content': u'#1/2 msg from wb to receiver2' }
        yield wbtip.create_message_wb(self.wb_tip_id,
                                          self.receiver2_desc['id'], msgrequest)
        msgrequest = { 'content': u'#2/2 msg from wb to receiver2' }
        yield wbtip.create_message_wb(self.wb_tip_id,
                                          self.receiver2_desc['id'], msgrequest)

        end = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        for receivers_message in end:
            if receivers_message['id'] == self.receiver2_desc['id']:
                self.assertEqual(receivers_message['message_counter'], 2)
            else: # the messages from Receiver1 are not changed, right ?
                self.assertEqual(receivers_message['message_counter'], 1)
Example #4
0
    def do_receivers_messages_and_unread_verification(self):
        # Receiver1 check the presence of the whistleblower message (only 1)
        x = yield receiver.get_receivertip_list(self.receiver1_desc['id'],
                                                'en')
        self.assertEqual(x[0]['message_counter'], 1)

        # Receiver1 send one message
        msgrequest = {'content': u'Receiver1 send a message to WB'}
        k = yield rtip.create_message_receiver(self.receiver1_desc['id'],
                                               self.rtip1_id, msgrequest)
        self.assertEqual(k['visualized'], False)
        self.assertEqual(k['content'], msgrequest['content'])

        # Whistleblower check the presence of receiver1 unread message
        receiver_info_list = yield wbtip.get_receiver_list_wb(
            self.wb_tip_id, 'en')

        for r in receiver_info_list:
            if r['id'] == self.receiver1_desc['id']:
                self.assertEqual(r['name'], self.receiver1_desc['name'])
                self.assertEqual(r['message_counter'], 2)
            else:
                self.assertEqual(r['name'], self.receiver2_desc['name'])
                self.assertEqual(r['message_counter'], 2)

        # Receiver2 check the presence of the whistleblower message (2 expected)
        a = yield receiver.get_receivertip_list(self.receiver1_desc['id'],
                                                'en')
        self.assertEqual(len(a), 1)
        self.assertEqual(a[0]['message_counter'], 2)

        # Receiver2 READ the messages from the whistleblower
        unread = yield rtip.get_messages_list(self.receiver2_desc['id'],
                                              self.rtip2_id)
        self.assertEqual(unread[0]['visualized'], unread[1]['visualized'])
        self.assertEqual(unread[0]['visualized'], False)

        readed = yield rtip.get_messages_list(self.receiver2_desc['id'],
                                              self.rtip2_id)
        self.assertEqual(readed[0]['visualized'], readed[1]['visualized'])
        self.assertEqual(readed[0]['visualized'], True)

        # Receiver2 send two message
        msgrequest = {'content': u'Receiver2 send #1/2 message to WB'}
        yield rtip.create_message_receiver(self.receiver2_desc['id'],
                                           self.rtip2_id, msgrequest)

        msgrequest = {'content': u'Receiver2 send #2/2 message to WB'}
        yield rtip.create_message_receiver(self.receiver2_desc['id'],
                                           self.rtip2_id, msgrequest)

        # Whistleblower read the messages from Receiver2
        wunread = yield wbtip.get_messages_content(self.wb_tip_id,
                                                   self.receiver2_desc['id'])
        self.assertEqual(len(wunread), 4)  # two msg from Wb, two from R2
        self.assertFalse(wunread[2]['visualized'])
        self.assertFalse(wunread[3]['visualized'])

        wreaded = yield wbtip.get_messages_content(self.wb_tip_id,
                                                   self.receiver2_desc['id'])
        self.assertTrue(wreaded[2]['visualized'])
        self.assertTrue(wreaded[3]['visualized'])

        # Whistleblower check 0 unread messages from Receiver2, and still 1 from R1
        end = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        for recv in end:
            if recv['id'] == self.receiver2_desc['id']:
                self.assertEqual(recv['message_counter'], 4)
            else:
                self.assertEqual(recv['message_counter'], 2)
Example #5
0
    def do_receivers_messages_and_unread_verification(self):
        # Receiver1 check the presence of the whistleblower message (only 1)
        x = yield receiver.get_receivertip_list(self.receiver1_desc['id'], 'en')
        self.assertEqual(x[0]['message_counter'], 1)

        # Receiver1 send one message
        msgrequest = { 'content': u'Receiver1 send a message to WB' }
        k = yield rtip.create_message_receiver(self.receiver1_desc['id'],
                                               self.rtip1_id, msgrequest)
        self.assertEqual(k['visualized'], False)
        self.assertEqual(k['content'], msgrequest['content'])

        # Whistleblower check the presence of receiver1 unread message
        receiver_info_list = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')

        for r in receiver_info_list:
            if r['id'] == self.receiver1_desc['id']:
                self.assertEqual(r['name'], self.receiver1_desc['name'])
                self.assertEqual(r['message_counter'], 2)
            else:
                self.assertEqual(r['name'], self.receiver2_desc['name'])
                self.assertEqual(r['message_counter'], 2)

        # Receiver2 check the presence of the whistleblower message (2 expected)
        a = yield receiver.get_receivertip_list(self.receiver1_desc['id'], 'en')
        self.assertEqual(len(a), 1)
        self.assertEqual(a[0]['message_counter'], 2)

        # Receiver2 READ the messages from the whistleblower
        unread = yield rtip.get_messages_list(self.receiver2_desc['id'], self.rtip2_id)
        self.assertEqual(unread[0]['visualized'], unread[1]['visualized'])
        self.assertEqual(unread[0]['visualized'], False)

        readed = yield rtip.get_messages_list(self.receiver2_desc['id'], self.rtip2_id)
        self.assertEqual(readed[0]['visualized'], readed[1]['visualized'])
        self.assertEqual(readed[0]['visualized'], True)

        # Receiver2 send two message
        msgrequest = { 'content': u'Receiver2 send #1/2 message to WB' }
        yield rtip.create_message_receiver(self.receiver2_desc['id'],
                                           self.rtip2_id, msgrequest)

        msgrequest = { 'content': u'Receiver2 send #2/2 message to WB' }
        yield rtip.create_message_receiver(self.receiver2_desc['id'],
                                           self.rtip2_id, msgrequest)

        # Whistleblower read the messages from Receiver2
        wunread = yield wbtip.get_messages_content(self.wb_tip_id, self.receiver2_desc['id'])
        self.assertEqual(len(wunread), 4) # two msg from Wb, two from R2
        self.assertFalse(wunread[2]['visualized'])
        self.assertFalse(wunread[3]['visualized'])

        wreaded = yield wbtip.get_messages_content(self.wb_tip_id, self.receiver2_desc['id'])
        self.assertTrue(wreaded[2]['visualized'])
        self.assertTrue(wreaded[3]['visualized'])

        # Whistleblower check 0 unread messages from Receiver2, and still 1 from R1
        end = yield wbtip.get_receiver_list_wb(self.wb_tip_id, 'en')
        

        for recv in end:
            if recv['id'] == self.receiver2_desc['id']:
                self.assertEqual(recv['message_counter'], 4)
            else:
                self.assertEqual(recv['message_counter'], 2)
Example #6
0
 def wb_get_receiver_list(self, language):
     receiver_list = yield wbtip.get_receiver_list_wb(self.wb_tip_id, language)
     self.assertEqual(len(receiver_list), 2)
     self.assertEqual(receiver_list[0]['access_counter'] + receiver_list[1]['access_counter'], 2)