示例#1
0
    def test_transmit_order(self):
        organisation = Organisation.objects.create()
        person = Person.objects.create()

        start = erp_order_flow.get_start_activity()
        start.start()
        start.finish()
        process = start.process

        match_organisation = next(get_current_activities_in_process(process))
        match_organisation.start()
        process.organisation = organisation
        process.save()
        match_organisation.finish()

        match_person = next(get_current_activities_in_process(process))
        match_person.start()
        process.person = person
        process.save()
        match_person.finish()

        process.refresh_from_db()

        self.assertIsNotNone(
            process.activity_instances.get(activity_name='transmit_order').finished_at
        )
        self.assertEqual(process.erp_order_id, '1337')
示例#2
0
    def test_undo_organisation(self):
        organisation = Organisation.objects.create()

        start = erp_order_flow.get_start_activity()
        start.start()
        start.finish()

        process = DemoOrderProcess.objects.get()
        match_organisation = next(get_current_activities_in_process(process))

        match_organisation.start()
        match_organisation.process.organisation = organisation
        match_organisation.finish()

        self.assertEqual(next(get_current_activities_in_process(process)).name, 'match_person')

        next(get_current_activities_in_process(process)).cancel()
        match_organisation.undo()

        self.assertEqual(next(get_current_activities_in_process(process)).name, 'match_organisation')
示例#3
0
    def test_skip_organisation(self):
        organisation = Organisation.objects.create()

        start = erp_order_flow.get_start_activity(
            process_kwargs={'organisation' :organisation},
        )
        start.start()
        start.finish()

        process = DemoOrderProcess.objects.get()

        up_next = list(get_current_activities_in_process(process))

        self.assertSetEqual({a.name for a in up_next}, {'match_person', 'matching_done'})
示例#4
0
 def test_parallel_activities_allowed(self):
     start = erp_order_flow.get_start_activity()
     start.start()
     start.finish()
     up_next = {a.name for a in get_current_activities_in_process(start.process)}
     self.assertSetEqual(up_next, {'match_person', 'match_organisation'})
def get_current_activities_in_process(process):
    return services.get_current_activities_in_process(process)