def do_finalize_submission(self): self.submission_desc['finalize'] = True self.submission_desc['wb_fields'] = helpers.fill_random_fields(self.context_desc) self.submission_desc = yield submission.update_submission( self.submission_desc['id'], self.submission_desc, finalize=True) self.assertEqual(self.submission_desc['mark'], models.InternalTip._marker[1]) submission.create_whistleblower_tip(self.submission_desc)
def test_003_create_submission_attach_files_finalize_and_access_wbtip(self): submission_desc = dict(self.dummySubmission) submission_desc['finalize'] = True del submission_desc['id'] status = yield submission.create_submission(submission_desc, finalize=False) yield self.emulate_file_upload(self.dummySubmission['id']) status = yield submission.update_submission(status['id'], status, finalize=True) self.assertEqual(status['mark'], u'finalize') receipt = yield submission.create_whistleblower_tip(status) self.assertTrue(re.match(self.dummyNode['receipt_regexp'], receipt)) wb_access_id = yield authentication.login_wb(receipt) # remind: return a tuple (serzialized_itip, wb_itip) wb_tip = yield wbtip.get_internaltip_wb(wb_access_id) # In the WB/Receiver Tip interface, wb_fields are called fields. # This can be uniformed when API would be cleaned of the _id self.assertTrue(wb_tip.has_key('fields'))
def test_003_create_submission_attach_files_finalize_and_access_wbtip( self): submission_desc = dict(self.dummySubmission) submission_desc['finalize'] = True del submission_desc['id'] status = yield submission.create_submission(submission_desc, finalize=False) yield self.emulate_file_upload(self.dummySubmission['id']) status = yield submission.update_submission(status['id'], status, finalize=True) self.assertEqual(status['mark'], u'finalize') receipt = yield submission.create_whistleblower_tip(status) self.assertTrue(re.match(self.dummyNode['receipt_regexp'], receipt)) wb_access_id = yield authentication.login_wb(receipt) # remind: return a tuple (serzialized_itip, wb_itip) wb_tip = yield wbtip.get_internaltip_wb(wb_access_id) # In the WB/Receiver Tip interface, wb_fields are called fields. # This can be uniformed when API would be cleaned of the _id self.assertTrue(wb_tip.has_key('fields'))
def get_wb_receipt_on_finalized(self): """ emulate auth, get wb_tip.id, get the data like GET /tip/xxx """ if not self.receipt: self.receipt = yield submission.create_whistleblower_tip(self.submission_desc) self.assertGreater(len(self.receipt), 5)
def get_wb_receipt_on_finalized(self): """ emulate auth, get wb_tip.id, get the data like GET /tip/xxx """ if not self.receipt: self.receipt = yield submission.create_whistleblower_tip(self.submission_desc) self.assertGreater(len(self.receipt), 5) self.assertTrue(re.match(GLSetting.defaults.receipt_regexp, self.receipt) )
def test_create_submission(self): submission_desc = dict(self.dummySubmission) submission_desc["finalize"] = True del submission_desc["submission_gus"] status = yield submission.create_submission(submission_desc, finalize=True) receipt = yield submission.create_whistleblower_tip(status) retval = re.match(self.dummyContext["receipt_regexp"], receipt) self.assertTrue(retval)
def test_create_submission_attach_files_finalize_and_access_wbtip(self): self.submission_desc = yield self.get_dummy_submission(self.dummyContext['id']) self.submission_desc = yield self.create_submission_with_files(self.submission_desc) receipt = yield create_whistleblower_tip(self.submission_desc) wb_access_id = yield authentication.login_wb(receipt) # remind: return a tuple (serzialized_itip, wb_itip) wb_tip = yield wbtip.get_tip(wb_access_id, 'en') self.assertTrue('wb_steps' in wb_tip)
def test_update_submission(self): self.submission_desc = yield self.get_dummy_submission(self.dummyContext['id']) self.submission_desc['wb_steps'] = yield self.fill_random_fields(self.dummyContext['id']) self.submission_desc = yield self.create_submission(self.submission_desc) receipt = yield create_whistleblower_tip(self.submission_desc) wb_access_id = yield authentication.login_wb(receipt) wb_tip = yield wbtip.get_tip(wb_access_id, 'en') self.assertTrue('wb_steps' in wb_tip)
def test_access_from_receipt(self): submission_desc = dict(self.dummySubmission) submission_desc["finalize"] = True del submission_desc["submission_gus"] status = yield submission.create_submission(submission_desc, finalize=True) receipt = yield submission.create_whistleblower_tip(status) wb_access_id = yield authentication.login_wb(receipt) # remind: return a tuple (serzialized_itip, wb_itip) wb_tip = yield tip.get_internaltip_wb(wb_access_id) # In the WB/Receiver Tip interface, wb_fields are called fields. # This can be uniformed when API would be cleaned of the _gus self.assertTrue(wb_tip.has_key("fields"))
def perform_submission(self): self.dummySubmission['context_id'] = self.dummyContext['id'] self.dummySubmission['receivers'] = self.dummyContext['receivers'] self.dummySubmission['wb_steps'] = yield fill_random_fields(self.dummyContext['id']) self.dummySubmission = yield create_submission(self.dummySubmission, False, 'en') yield self.emulate_file_upload(self.dummySubmission['id']) submission = yield update_submission(self.dummySubmission['id'], self.dummySubmission, True, 'en') self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission) yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation() commentCreation = { 'content': 'comment!', } messageCreation = { 'content': 'message!', } rtips_desc = yield self.get_rtips() for rtip_desc in rtips_desc: yield rtip.create_comment_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], commentCreation) yield rtip.create_message_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], messageCreation) wbtips_desc = yield self.get_wbtips() for wbtip_desc in wbtips_desc: yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'], commentCreation) for receiver_id in wbtip_desc['wbtip_receivers']: yield wbtip.create_message_wb(wbtip_desc['wbtip_id'], receiver_id, messageCreation) yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation()
def test_update_submission(self): submission_desc = dict(self.dummySubmission) submission_desc["finalize"] = False submission_desc["context_gus"] = self.dummyContext["context_gus"] submission_desc["submission_gus"] = submission_desc["id"] = submission_desc["mark"] = None status = yield submission.create_submission(submission_desc, finalize=False) status["wb_fields"] = helpers.fill_random_fields(self.dummyContext) status["finalize"] = True status = yield submission.update_submission(status["submission_gus"], status, finalize=True) receipt = yield submission.create_whistleblower_tip(status) wb_access_id = yield authentication.login_wb(receipt) wb_tip = yield tip.get_internaltip_wb(wb_access_id) self.assertTrue(wb_tip.has_key("fields"))
def test_008_update_submission(self): submission_desc = dict(self.dummySubmission) submission_desc['finalize'] = False submission_desc['context_id'] = self.dummyContext['id'] submission_desc['id'] = submission_desc['mark'] = None status = yield submission.create_submission(submission_desc, finalize=False) status['wb_fields'] = helpers.fill_random_fields(self.dummyContext) status['finalize'] = True status = yield submission.update_submission(status['id'], status, finalize=True) receipt = yield submission.create_whistleblower_tip(status) wb_access_id = yield authentication.login_wb(receipt) wb_tip = yield wbtip.get_internaltip_wb(wb_access_id) self.assertTrue(wb_tip.has_key('fields'))
def test_create_submission_attach_files_finalize_and_access_wbtip(self): submission_desc = dict(self.dummySubmission) submission_desc['finalize'] = True del submission_desc['id'] status = yield submission.create_submission(submission_desc, finalize=False) yield self.emulate_file_upload(self.dummySubmission['id']) status = yield submission.update_submission(status['id'], status, finalize=True) self.assertEqual(status['mark'], u'finalize') receipt = yield submission.create_whistleblower_tip(status) self.assertTrue(re.match(GLSetting.defaults.receipt_regexp, receipt)) wb_access_id = yield authentication.login_wb(receipt) # remind: return a tuple (serzialized_itip, wb_itip) wb_tip = yield wbtip.get_internaltip_wb(wb_access_id) self.assertTrue(wb_tip.has_key('wb_steps'))
def fill_data(self): try: receiver = yield create_receiver(self.dummyReceiver) self.dummyReceiver['receiver_gus'] = receiver['receiver_gus'] self.receiver_assertion(self.dummyReceiver, receiver) except Exception as excp: print "Fail fill_data/create_receiver: %s" % excp try: self.dummyContext['receivers'] = [ self.dummyReceiver['receiver_gus'] ] context = yield create_context(self.dummyContext) self.dummyContext['context_gus'] = context['context_gus'] except Exception as excp: print "Fail fill_data/create_context: %s" % excp self.dummySubmission['context_gus'] = self.dummyContext['context_gus'] self.dummySubmission['receivers'] = [ self.dummyReceiver['receiver_gus'] ] self.dummySubmission['wb_fields'] = fill_random_fields(self.dummyContext) try: submission = yield create_submission(self.dummySubmission, finalize=True) self.dummySubmission['id'] = submission['id'] self.dummySubmission['submission_gus'] = submission['submission_gus'] except Exception as excp: print "Fail fill_data/create_submission: %s" % excp try: self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission) except Exception as excp: print "Fail fill_data/create_whistleblower: %s" % excp assert self.dummyContext.has_key('context_gus') assert self.dummyReceiver.has_key('receiver_gus') assert self.dummySubmission.has_key('submission_gus')
def fill_data(self): try: yield do_appdata_init() except Exception as excp: print "Fail fill_data/do_appdata_init: %s" % excp raise excp receivers_ids = [] try: self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1) receivers_ids.append(self.dummyReceiver_1['id']) self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2) receivers_ids.append(self.dummyReceiver_2['id']) except Exception as excp: print "Fail fill_data/create_receiver: %s" % excp raise excp try: self.dummyContext['receivers'] = receivers_ids self.dummyContext = yield create_context(self.dummyContext) except Exception as excp: print "Fail fill_data/create_context: %s" % excp raise excp self.dummySubmission['context_id'] = self.dummyContext['id'] self.dummySubmission['receivers'] = receivers_ids self.dummySubmission['wb_fields'] = fill_random_fields( self.dummyContext) try: self.dummySubmissionNotFinalized = yield create_submission( self.dummySubmission, finalize=False) except Exception as excp: print "Fail fill_data/create_submission: %s" % excp raise excp try: self.dummySubmission = yield create_submission( self.dummySubmission, finalize=False) except Exception as excp: print "Fail fill_data/create_submission: %s" % excp raise excp yield self.emulate_file_upload(self.dummySubmission['id']) try: submission = yield update_submission(self.dummySubmission['id'], self.dummySubmission, finalize=True) except Exception as excp: print "Fail fill_data/update_submission: %s" % excp raise excp try: self.dummyWBTip = yield create_whistleblower_tip( self.dummySubmission) except Exception as excp: print "Fail fill_data/create_whistleblower: %s" % excp raise excp assert self.dummyReceiver_1.has_key('id') assert self.dummyReceiver_2.has_key('id') assert self.dummyContext.has_key('id') assert self.dummySubmission.has_key('id') yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation() commentCreation = { 'content': 'comment!', } messageCreation = { 'content': 'message!', } rtips_desc = yield self.get_rtips() for rtip_desc in rtips_desc: yield rtip.create_comment_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], commentCreation) yield rtip.create_message_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], messageCreation) wbtips_desc = yield self.get_wbtips() for wbtip_desc in wbtips_desc: yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'], commentCreation) for receiver_id in wbtip_desc['wbtip_receivers']: yield wbtip.create_message_wb(wbtip_desc['wbtip_id'], receiver_id, messageCreation) yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation()
def fill_data(self): try: yield do_appdata_init() except Exception as excp: print "Fail fill_data/do_appdata_init: %s" % excp raise excp receivers_ids = [] try: self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1) receivers_ids.append(self.dummyReceiver_1['id']) self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2) receivers_ids.append(self.dummyReceiver_2['id']) except Exception as excp: print "Fail fill_data/create_receiver: %s" % excp raise excp try: self.dummyContext['receivers'] = receivers_ids self.dummyContext = yield create_context(self.dummyContext) except Exception as excp: print "Fail fill_data/create_context: %s" % excp raise excp self.dummySubmission['context_id'] = self.dummyContext['id'] self.dummySubmission['receivers'] = receivers_ids self.dummySubmission['wb_fields'] = fill_random_fields(self.dummyContext) try: self.dummySubmissionNotFinalized = yield create_submission(self.dummySubmission, finalize=False) except Exception as excp: print "Fail fill_data/create_submission: %s" % excp raise excp try: self.dummySubmission = yield create_submission(self.dummySubmission, finalize=False) except Exception as excp: print "Fail fill_data/create_submission: %s" % excp raise excp yield self.emulate_file_upload(self.dummySubmission['id']) try: submission = yield update_submission(self.dummySubmission['id'], self.dummySubmission, finalize=True) except Exception as excp: print "Fail fill_data/update_submission: %s" % excp raise excp try: self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission) except Exception as excp: print "Fail fill_data/create_whistleblower: %s" % excp raise excp assert self.dummyReceiver_1.has_key('id') assert self.dummyReceiver_2.has_key('id') assert self.dummyContext.has_key('id') assert self.dummySubmission.has_key('id') yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation() commentCreation = { 'content': 'comment!', } messageCreation = { 'content': 'message!', } rtips_desc = yield self.get_rtips() for rtip_desc in rtips_desc: yield rtip.create_comment_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], commentCreation) yield rtip.create_message_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], messageCreation) wbtips_desc = yield self.get_wbtips() for wbtip_desc in wbtips_desc: yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'], commentCreation) for receiver_id in wbtip_desc['wbtip_receivers']: yield wbtip.create_message_wb(wbtip_desc['wbtip_id'], receiver_id, messageCreation) yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation()
def fill_data(self): yield do_appdata_init() receivers_ids = [] # fill_data/create_receiver self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1) receivers_ids.append(self.dummyReceiver_1['id']) self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2) receivers_ids.append(self.dummyReceiver_2['id']) # fill_data/create_context self.dummyContext['receivers'] = receivers_ids self.dummyContext = yield create_context(self.dummyContext) # fill_data: create cield templates for idx, field in enumerate(self.dummyFieldTemplates): f = yield create_field(field, 'en') self.dummyFieldTemplates[idx]['id'] = f['id'] # fill_data: create fields and associate them to the context steps for idx, field in enumerate(self.dummyFields): field['is_template'] = False if idx <= 2: # "Field 1", "Field 2" and "Generalities" are associated to the first step field['step_id'] = self.dummyContext['steps'][0]['id'] else: # Name, Surname, Gender" are associated to field "Generalities" # "Field 1" and "Field 2" are associated to the first step field['fieldgroup_id'] = self.dummyFields[2]['id'] f = yield create_field(field, 'en') self.dummyFields[idx]['id'] = f['id'] self.dummyContext['steps'][0]['children'] = [ self.dummyFields[0], # Field 1 self.dummyFields[1], # Field 2 self.dummyFields[2] # Generalities ] yield update_context(self.dummyContext['id'], self.dummyContext) # fill_data/create_submission self.dummySubmission['context_id'] = self.dummyContext['id'] self.dummySubmission['receivers'] = receivers_ids self.dummySubmission['wb_steps'] = yield fill_random_fields(self.dummyContext['id']) self.dummySubmissionNotFinalized = yield create_submission(self.dummySubmission, finalize=False) self.dummySubmission = yield create_submission(self.dummySubmission, finalize=False) yield self.emulate_file_upload(self.dummySubmission['id']) # fill_data/update_submssion submission = yield update_submission(self.dummySubmission['id'], self.dummySubmission, finalize=True) # fill_data/create_whistleblower self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission) assert self.dummyReceiver_1.has_key('id') assert self.dummyReceiver_2.has_key('id') assert self.dummyContext.has_key('id') assert self.dummySubmission.has_key('id') yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation() commentCreation = { 'content': 'comment!', } messageCreation = { 'content': 'message!', } rtips_desc = yield self.get_rtips() for rtip_desc in rtips_desc: yield rtip.create_comment_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], commentCreation) yield rtip.create_message_receiver(rtip_desc['receiver_id'], rtip_desc['rtip_id'], messageCreation) wbtips_desc = yield self.get_wbtips() for wbtip_desc in wbtips_desc: yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'], commentCreation) for receiver_id in wbtip_desc['wbtip_receivers']: yield wbtip.create_message_wb(wbtip_desc['wbtip_id'], receiver_id, messageCreation) yield delivery_sched.DeliverySchedule().operation() yield notification_sched.NotificationSchedule().operation()