Beispiel #1
0
    def create_receivers_tip(self):
        receiver_tips = yield delivery_sched.tip_creation()

        self.assertEqual(len(receiver_tips), 2)
        self.assertTrue(re.match(requests.uuid_regexp, receiver_tips[0]))
        self.assertTrue(re.match(requests.uuid_regexp, receiver_tips[1]))

        tips_receiver_1 = yield receiver.get_receiver_tip_list(self.receiver1_desc['id'], 'en')
        tips_receiver_2 = yield receiver.get_receiver_tip_list(self.receiver2_desc['id'], 'en')
        self.rtip1_id = tips_receiver_1[0]['id']
        self.rtip2_id = tips_receiver_2[0]['id']
Beispiel #2
0
    def receiver1_get_tip_list(self):
        tiplist = yield receiver.get_receiver_tip_list(self.receiver1_desc['id'], 'en')

        # this test has been added to test issue/515
        self.assertTrue(isinstance(tiplist, list))
        self.assertTrue(isinstance(tiplist[0], dict))
        self.assertTrue(isinstance(tiplist[0]['preview'], list))
Beispiel #3
0
    def receiver1_get_tip_list(self):
        tiplist = yield receiver.get_receiver_tip_list(self.receiver1_desc['id'])

        # this test has been added to test issue/515
        self.assertTrue(isinstance(tiplist, list))
        self.assertTrue(isinstance(tiplist[0], dict))
        self.assertTrue(isinstance(tiplist[0]['preview'], list))
Beispiel #4
0
    def postpone_tip_expiration(self):
        recv_desc = yield admin.get_receiver_list()
        self.assertEqual(len(recv_desc), 2)
        rtip_desc = yield receiver.get_receiver_tip_list(recv_desc[0]['id'])
        self.assertEqual(len(rtip_desc), 1)
        tip_list = yield cleaning_sched.get_tiptime_by_marker(models.InternalTip._marker[2])
        self.assertEqual(len(tip_list), 1)
        rtip.postpone_expiration_date(recv_desc[0]['id'], rtip_desc[0]['id'])

        yield cleaning_sched.CleaningSchedule().operation()
Beispiel #5
0
    def test_tip_creation(self):

        receivers = yield get_public_receiver_list('en')
        contexts = yield get_public_context_list('en')

        yield create_submission(self.dummySubmission, finalize=True)
        created_tips = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_tips), 2) # this createSubmission and the helpers one

        receiver_tips = yield get_receiver_tip_list(self.dummyReceiver['receiver_gus'])

        expected_keys = ['access_counter', 'creation_date', 'expressed_pertinence', 'id', 'files_number', 'last_access', 'preview']
        self.assertEqual(set(receiver_tips[0].keys()), set(expected_keys))
Beispiel #6
0
    def do_receivers_messages_and_unread_verification(self):

        # Receiver1 check the presence of the whistleblower message (only 1)
        x = yield receiver.get_receiver_tip_list(self.receiver1_desc['id'])
        self.assertEqual(x[0]['unread_messages'], 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)

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

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

        # 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'}
        a1 = yield rtip.create_message_receiver(self.receiver2_desc['id'],
                                                self.rtip2_id, msgrequest)
        msgrequest = {'content': u'Receiver2 send #2/2 message to WB'}
        a2 = 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)

        for recv in end:
            if recv['id'] == self.receiver2_desc['id']:
                self.assertEqual(recv['unread_messages'], 0)
            else:
                self.assertEqual(recv['unread_messages'], 1)
Beispiel #7
0
    def do_receivers_messages_and_unread_verification(self):

        # Receiver1 check the presence of the whistleblower message (only 1)
        x = yield receiver.get_receiver_tip_list(self.receiver1_desc['id'])
        self.assertEqual(x[0]['unread_messages'], 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)

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

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

        # 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' }
        a1 = yield rtip.create_message_receiver(self.receiver2_desc['id'],
                                                self.rtip2_id, msgrequest)
        msgrequest = { 'content': u'Receiver2 send #2/2 message to WB' }
        a2 = 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)
        

        for recv in end:
            if recv['id'] == self.receiver2_desc['id']:
                self.assertEqual(recv['unread_messages'], 0)
            else:
                self.assertEqual(recv['unread_messages'], 1)