def test_notification_schedule_failure(self): count = yield get_scheduled_email_count() self.assertEqual(count, 0) yield DeliverySchedule().run() notification_schedule = NotificationSchedule() notification_schedule.skip_sleep = True def sendmail_failure(x): # simulate the failure just returning with no action return succeed(None) notification_schedule.sendmail = sendmail_failure for i in range(0, 10): yield notification_schedule.run() count = yield get_scheduled_email_count() self.assertEqual(count, 28) yield notification_schedule.run() count = yield get_scheduled_email_count() self.assertEqual(count, 0)
def test_keywords_conversion(self): yield self.perform_full_submission_actions() yield DeliverySchedule().operation() data = {} data['type'] = 'tip' data['receiver'] = yield admin.receiver.get_receiver( self.dummyReceiver_1['id'], 'en') data['context'] = yield admin.context.get_context( self.dummyContext['id'], 'en') data['notification'] = yield admin.notification.get_notification('en') data['node'] = yield admin.node.admin_serialize_node('en') data['tip'] = self.dummyRTips[0] comments = yield rtip.get_comment_list(self.dummyReceiver_1['id'], data['tip']['id']) data['comment'] = comments[0] messages = yield rtip.get_message_list(self.dummyReceiver_1['id'], data['tip']['id']) data['message'] = messages[0] files = yield rtip.get_files_receiver(self.dummyReceiver_1['id'], data['tip']['id']) data['file'] = files[0] for key in ['tip', 'comment', 'message', 'file']: data['type'] = key template = ''.join(supported_template_types[key].keyword_list) ret = Templating().format_template(template, data)
def test_notification_schedule(self): yield DeliverySchedule().operation() yield NotificationSchedule().operation() mail_schedule = MailflushSchedule() mail_schedule.skip_sleep = True yield mail_schedule.operation()
def test_keywords_conversion(self): yield self.perform_full_submission_actions() yield DeliverySchedule().run() data = {} data['type'] = 'tip' data['user'] = yield admin.user.get_user(self.dummyReceiver_1['id'], u'en') data['context'] = yield admin.context.get_context( self.dummyContext['id'], u'en') data['notification'] = yield admin.notification.get_notification(u'en') data['node'] = yield admin.node.admin_serialize_node(u'en') if self.dummyRTips[0]['receiver_id'] == self.dummyReceiver_1['id']: tip_id = self.dummyRTips[0]['id'] else: tip_id = self.dummyRTips[1]['id'] data['tip'] = yield rtip.get_rtip(self.dummyReceiver_1['id'], tip_id, u'en') data['comments'] = data['tip']['comments'] data['comment'] = data['comments'][0] data['messages'] = data['tip']['messages'] data['message'] = data['messages'][0] files = yield rtip.receiver_get_rfile_list(data['tip']['id']) data['file'] = files[0] for key in ['tip', 'comment', 'message', 'file']: data['type'] = key template = ''.join(supported_template_types[key].keyword_list) Templating().format_template(template, data)
def setUp(self): yield helpers.TestHandlerWithPopulatedDB.setUp(self) yield self.perform_full_submission_actions() # populates alarms conditions self.pollute_events(10) # creates the receiver files yield DeliverySchedule().run()
def test_submission_file_delivery_pgp(self): new_fields = MockDict().dummyFields new_context = MockDict().dummyContext new_context['name'] = "Context Name" new_context_output = yield create_context(new_context, 'en') self.context_assertions(new_context, new_context_output) doubletest = yield get_context_list('en') self.assertEqual(len(doubletest), 2) yanr = self.get_dummy_receiver("antani1") yanr['pgp_key_public'] = unicode(VALID_PGP_KEY1) yanr['contexts'] = [new_context_output['id']] yanr_output = yield receiver.create_receiver(yanr, 'en') self.receiver_assertions(yanr, yanr_output) asdr = self.get_dummy_receiver("antani2") asdr['pgp_key_public'] = unicode(VALID_PGP_KEY1) asdr['contexts'] = [new_context_output['id']] asdr_output = yield receiver.create_receiver(asdr, 'en') self.receiver_assertions(asdr, asdr_output) new_subm = dict(MockDict().dummySubmission) new_subm['finalize'] = False new_subm['context_id'] = new_context_output['id'] new_subm['receivers'] = [asdr_output['id'], yanr_output['id']] new_subm['identity_provided'] = False new_subm['answers'] = yield self.fill_random_answers( new_context_output['id']) token = Token('submission') token.proof_of_work = False yield self.emulate_file_upload(token, 3) new_subm_output = yield submission.create_submission( token.id, new_subm, False, 'en') yield DeliverySchedule().operation() # now get a lots of receivertips/receiverfiles and check! ifilist = yield self.get_internalfiles_by_wbtip(new_subm_output['id']) self.assertTrue(isinstance(ifilist, list)) self.assertEqual(len(ifilist), 3) rfilist = yield self.get_receiverfiles_by_wbtip(new_subm_output['id']) self.assertTrue(isinstance(ifilist, list)) self.assertEqual(len(rfilist), 6) for i in range(0, 3): self.assertLess(ifilist[0]['size'], rfilist[i]['size']) self.assertEqual(rfilist[0]['status'], u"encrypted")
def test_submission_file_delivery_pgp(self): new_fields = MockDict().dummyFields new_context = MockDict().dummyContext new_context['name'] = "this uniqueness is no more checked due to the lang" new_context_output = yield create_context(new_context, 'en') self.context_assertions(new_context, new_context_output) doubletest = yield get_context_list('en') self.assertEqual(len(doubletest), 2) yanr = dict(MockDict().dummyReceiver) yanr['name'] = u"Receiver1" yanr['pgp_key_public'] = unicode(VALID_PGP_KEY1) yanr['contexts'] = [ new_context_output['id']] yanr_output = yield create_receiver(yanr, 'en') self.receiver_assertions(yanr, yanr_output) asdr = dict(MockDict().dummyReceiver) asdr['name'] = u"Receiver2" asdr['pgp_key_public'] = unicode(VALID_PGP_KEY1) asdr['contexts'] = [ new_context_output['id']] asdr_output = yield create_receiver(asdr, 'en') self.receiver_assertions(asdr, asdr_output) new_subm = dict(MockDict().dummySubmission) new_subm['finalize'] = False new_subm['context_id'] = new_context_output['id'] new_subm['receivers'] = [ asdr_output['id'], yanr_output['id'] ] new_subm['wb_steps'] = yield self.fill_random_answers(new_context_output['id']) token = Token('submission') yield self.emulate_file_upload(token, 3) new_subm_output = yield submission.create_submission(token.id, new_subm, False, 'en') yield DeliverySchedule().operation() # now get a lots of receivertips/receiverfiles and check! ifilist = yield get_files_by_itip(new_subm_output['id']) self.assertTrue(isinstance(ifilist, list)) self.assertEqual(len(ifilist), 3) rfilist = yield get_receiverfile_by_itip(new_subm_output['id']) self.assertTrue(isinstance(ifilist, list)) self.assertEqual(len(rfilist), 6) for i in range(0, 3): self.assertLess(ifilist[0]['size'], rfilist[i]['size']) self.assertEqual(rfilist[0]['status'], u"encrypted" )
def test_post(self): yield self.perform_full_submission_actions() yield DeliverySchedule().operation() rtips_desc = yield self.get_rtips() for rtip_desc in rtips_desc: rfiles_desc = yield self.get_rfiles(rtip_desc['id']) for rfile_desc in rfiles_desc: handler = self.request(role='receiver', user_id = rtip_desc['receiver_id']) yield handler.post(rtip_desc['id'], rfile_desc['id'])
def test_get(self): yield self.perform_minimal_submission() yield DeliverySchedule().run() rtip_descs = yield self.get_rtips() for rtip_desc in rtip_descs: rfiles_desc = yield self.get_rfiles(rtip_desc['id']) for rfile_desc in rfiles_desc: handler = self.request(role='receiver', user_id = rtip_desc['receiver_id']) yield handler.get(rfile_desc['id']) self.assertNotEqual(handler.request.getResponseBody(), '')
def test_get(self): yield self.perform_minimal_submission() yield DeliverySchedule().run() rtips_desc = yield self.get_rtips() for rtip_desc in rtips_desc: rfiles_desc = yield self.get_rfiles(rtip_desc['id']) for rfile_desc in rfiles_desc: handler = self.request(role='receiver', user_id=rtip_desc['receiver_id']) yield handler.get(rfile_desc['id'])
def test_notification_schedule_success(self): count = yield get_scheduled_email_count() self.assertEqual(count, 0) yield DeliverySchedule().run() notification_schedule = NotificationSchedule() notification_schedule.skip_sleep = True yield notification_schedule.run() count = yield get_scheduled_email_count() self.assertEqual(count, 0)
def test_notification_schedule_failure(self): count = yield get_scheduled_email_count() self.assertEqual(count, 0) yield DeliverySchedule().run() notification_schedule = NotificationSchedule() notification_schedule.skip_sleep = True def sendmail(x, y, z): return fail(True) notification_schedule.sendmail = sendmail for i in range(0, 10): yield notification_schedule.run() count = yield get_scheduled_email_count() self.assertEqual(count, 28) yield notification_schedule.run() count = yield get_scheduled_email_count() self.assertEqual(count, 0)
def setUp(self): yield helpers.TestHandlerWithPopulatedDB.setUp(self) yield self.perform_full_submission_actions() yield DeliverySchedule().operation()
def test_submission_file_delivery_gpg(self): new_fields = MockDict().dummyFields new_context = MockDict().dummyContext new_context['steps'][0]['children'] = [] new_context[ 'name'] = "this uniqueness is no more checked due to the lang" new_context_output = yield create_context(new_context, 'en') self.context_assertion(new_context, new_context_output) doubletest = yield get_context_list('en') self.assertEqual(len(doubletest), 2) yanr = dict(MockDict().dummyReceiver) yanr['name'] = yanr['mail_address'] = u"*****@*****.**" yanr['gpg_key_armor'] = unicode(VALID_PGP_KEY1) yanr['contexts'] = [new_context_output['id']] yanr_output = yield create_receiver(yanr, 'en') self.receiver_assertion(yanr, yanr_output) asdr = dict(MockDict().dummyReceiver) asdr['name'] = asdr['mail_address'] = u"*****@*****.**" asdr['gpg_key_armor'] = unicode(VALID_PGP_KEY1) asdr['contexts'] = [new_context_output['id']] asdr_output = yield create_receiver(asdr, 'en') self.receiver_assertion(asdr, asdr_output) new_subm = dict(MockDict().dummySubmission) new_subm['finalize'] = False new_subm['context_id'] = new_context_output['id'] new_subm['receivers'] = [asdr_output['id'], yanr_output['id']] new_subm['wb_steps'] = yield fill_random_fields( new_context_output['id']) new_subm_output = yield create_submission(new_subm, False, 'en') # self.submission_assertion(new_subm, new_subm_output) self.emulate_file_upload(new_subm_output['id']) new_file = self.get_dummy_file() new_subm['id'] = new_subm_output['id'] new_subm['finalize'] = True new_subm_output = yield update_submission(new_subm['id'], new_subm, True, 'en') yield DeliverySchedule().operation() # now get a lots of receivertips/receiverfiles and check! ifilist = yield get_files_by_itip(new_subm_output['id']) self.assertTrue(isinstance(ifilist, list)) self.assertEqual(len(ifilist), 2) self.assertEqual(ifilist[0]['mark'], u'delivered') rfilist = yield get_receiverfile_by_itip(new_subm_output['id']) self.assertTrue(isinstance(ifilist, list)) self.assertEqual(len(rfilist), 2) for i in range(0, 2): self.assertLess(ifilist[0]['size'], rfilist[i]['size']) self.assertEqual(rfilist[0]['status'], u"encrypted")
def test_notification_schedule(self): yield DeliverySchedule().operation() notification_schedule = NotificationSchedule() notification_schedule.skip_sleep = True yield notification_schedule.operation()