def setUp(self): super(TestContractTransition, self).setUp() self.stage1 = StageFactory.build(name="stage 1") self.stage2 = StageFactory.build(name="stage 2") self.stage3 = StageFactory.build(name="stage 3") self.flow1 = FlowFactory.build(flow_name="flow 1", stage_order=[self.stage1.id, self.stage2.id, self.stage3.id]) self.flow2 = FlowFactory.build(flow_name="flow 2", stage_order=[self.stage1.id, self.stage2.id, self.stage3.id]) self.user = UserFactory.build() self.active_contract.flow = self.flow1
def setUp(self): super(TestContractTransition, self).setUp() self.stage1 = StageFactory.build(name='stage 1') self.stage2 = StageFactory.build(name='stage 2') self.stage3 = StageFactory.build(name='stage 3') self.flow1 = FlowFactory.build( flow_name='flow 1', stage_order=[self.stage1.id, self.stage2.id, self.stage3.id]) self.flow2 = FlowFactory.build( flow_name='flow 2', stage_order=[self.stage1.id, self.stage2.id, self.stage3.id]) self.user = UserFactory.build() self.active_contract.flow = self.flow1
def insert_a_flow(name="test", stage_ids=None): try: flow = FlowFactory.create(**{"flow_name": name, "stage_order": stage_ids}) return flow except IntegrityError: db.session.rollback() return Flow.query.filter(Flow.name == name).first()
def setUp(self): super(TestContractStageSort, self).setUp() now = datetime.datetime.now().replace(second=0, microsecond=0) old = now - datetime.timedelta(minutes=1) older = now - datetime.timedelta(minutes=2) new = now + datetime.timedelta(minutes=1) newer = now + datetime.timedelta(minutes=2) stage1, stage2 = StageFactory.build(), StageFactory.build() flow = FlowFactory.build(stage_order=[stage1.id, stage2.id]) self.contract = ContractBaseFactory.build(current_stage_id=stage2.id) contract_stage1 = ContractStageFactory.build( stage=stage1, stage_id=stage1.id, flow=flow ) contract_stage2 = ContractStageFactory.build( stage=stage2, stage_id=stage2.id, flow=flow ) self.contract.build_complete_action_log = Mock() self.enter_one = ContractStageActionItemFactory.build( action_type='entered', taken_at=older, contract_stage=contract_stage1, action_detail={'timestamp': older.isoformat()} ) self.exit_one = ContractStageActionItemFactory.build( action_type='exited', taken_at=old, contract_stage=contract_stage1, action_detail={'timestamp': old.isoformat()} ) self.enter_two = ContractStageActionItemFactory.build( action_type='entered', taken_at=old.replace(second=1), contract_stage=contract_stage2, action_detail={'timestamp': old.isoformat()} ) self.revert_one = ContractStageActionItemFactory.build( action_type='reversion', taken_at=now, contract_stage=contract_stage1, action_detail={'timestamp': now.isoformat()} ) self.exit_one_post_revert = ContractStageActionItemFactory.build( action_type='exited', taken_at=new, contract_stage=contract_stage1, action_detail={'timestamp': new.isoformat()} ) self.enter_two_post_revert = ContractStageActionItemFactory.build( action_type='entered', taken_at=new.replace(second=1), contract_stage=contract_stage2, action_detail={'timestamp': new.isoformat()} ) self.note = ContractStageActionItemFactory.build( action_type='note', taken_at=newer, contract_stage=contract_stage2, action_detail={'timestamp': newer.isoformat()} )
def insert_a_flow(name='test', stage_ids=None): try: flow = FlowFactory.create(**{ 'flow_name': name, 'stage_order': stage_ids }) return flow except IntegrityError: db.session.rollback() return Flow.query.filter(Flow.name == name).first()
def setUp(self): super(TestContractStageSort, self).setUp() now = datetime.datetime.now().replace(second=0, microsecond=0) old = now - datetime.timedelta(minutes=1) older = now - datetime.timedelta(minutes=2) new = now + datetime.timedelta(minutes=1) newer = now + datetime.timedelta(minutes=2) stage1, stage2 = StageFactory.build(), StageFactory.build() flow = FlowFactory.build(stage_order=[stage1.id, stage2.id]) self.contract = ContractBaseFactory.build(current_stage_id=stage2.id) contract_stage1 = ContractStageFactory.build(stage=stage1, stage_id=stage1.id, flow=flow) contract_stage2 = ContractStageFactory.build(stage=stage2, stage_id=stage2.id, flow=flow) self.contract.build_complete_action_log = Mock() self.enter_one = ContractStageActionItemFactory.build( action_type="entered", taken_at=older, contract_stage=contract_stage1, action_detail={"timestamp": older.isoformat()}, ) self.exit_one = ContractStageActionItemFactory.build( action_type="exited", taken_at=old, contract_stage=contract_stage1, action_detail={"timestamp": old.isoformat()}, ) self.enter_two = ContractStageActionItemFactory.build( action_type="entered", taken_at=old.replace(second=1), contract_stage=contract_stage2, action_detail={"timestamp": old.isoformat()}, ) self.revert_one = ContractStageActionItemFactory.build( action_type="reversion", taken_at=now, contract_stage=contract_stage1, action_detail={"timestamp": now.isoformat()}, ) self.exit_one_post_revert = ContractStageActionItemFactory.build( action_type="exited", taken_at=new, contract_stage=contract_stage1, action_detail={"timestamp": new.isoformat()}, ) self.enter_two_post_revert = ContractStageActionItemFactory.build( action_type="entered", taken_at=new.replace(second=1), contract_stage=contract_stage2, action_detail={"timestamp": new.isoformat()}, ) self.note = ContractStageActionItemFactory.build( action_type="note", taken_at=newer, contract_stage=contract_stage2, action_detail={"timestamp": newer.isoformat()}, )