Beispiel #1
0
    def test_deque_returns_none_when_contact_person_no_pending_runs(self):
        contact_person_id = 'id'
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started)
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started,
                        run_delay=1000.0)

        self.assertEqual(RunQueue.dequeue(contact_person_id), None)
Beispiel #2
0
    def test_can_deque_next_run_for_a_particular_contact_person(self):
        contact_person_id = 'id'
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started)
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.not_started, run_delay=1000.0)
        run_queue = RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.not_started,
                                    run_delay=1500.0)

        self.assertEqual(RunQueue.dequeue(contact_person_id), run_queue)
Beispiel #3
0
def expire_overdue_runs():
    overdue_runs = Run.overdue_runs()
    for overdue_run in overdue_runs:
        overdue_run.update_status(Run.STATUS.expired)
        next_run = RunQueue.dequeue(overdue_run.runnable.contact_person_id)
        if next_run:
            schedule_run_for(next_run.runnable)
            next_run.update_status(RunQueue.STATUS.started)
Beispiel #4
0
    def test_can_deque_next_run_for_a_particular_contact_person(self):
        contact_person_id = 'id'
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started)
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.not_started, run_delay=1000.0)
        run_queue = RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.not_started,
                                    run_delay=1500.0)

        self.assertEqual(RunQueue.dequeue(contact_person_id), run_queue)
Beispiel #5
0
def expire_overdue_runs():
    overdue_runs = Run.overdue_runs()
    for overdue_run in overdue_runs:
        overdue_run.update_status(Run.STATUS.expired)
        next_run = RunQueue.dequeue(overdue_run.runnable.contact_person_id)
        if next_run:
            schedule_run_for(next_run.runnable)
            next_run.update_status(RunQueue.STATUS.started)
Beispiel #6
0
def expire_overdue_runs():
    overdue_runs = Run.overdue_runs()
    for overdue_run in overdue_runs:
        overdue_run.status = Run.STATUS.expired
        overdue_run.save()
        next_run = RunQueue.dequeue(overdue_run.node.contact_person_id)
        if next_run:
            schedule_run_for(next_run.node)
            next_run.status = RunQueue.STATUS.started
            next_run.save()
Beispiel #7
0
def expire_overdue_runs():
    overdue_runs = NodeLineItemRun.overdue_runs()
    for overdue_run in overdue_runs:
        overdue_run.status = NodeLineItemRun.STATUS.expired
        overdue_run.save()
        next_run = RunQueue.dequeue(overdue_run.node_line_item.distribution_plan_node.contact_person_id)
        if next_run:
            schedule_run_for(next_run.node_line_item)
            next_run.status = RunQueue.STATUS.started
            next_run.save()
Beispiel #8
0
    def test_can_deque_next_run_for_a_particular_contact_person(self):
        contact_person_id = 'id'
        date_first = datetime.datetime(2016, 2, 1, 9, 0, 0, 0)
        date_second = datetime.datetime(2016, 2, 2, 9, 0, 0, 0)
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started, start_time=date_second)
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.not_started, start_time=date_first)
        run_queue = RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.not_started,
                                    start_time=date_first)

        self.assertEqual(RunQueue.dequeue(contact_person_id).start_time, run_queue.start_time)
Beispiel #9
0
    def test_queues_run_for_particular_line_item_node(self):
        contact_person_id = 'id'
        run_delay = 1000

        node = DistributionPlanNodeFactory(contact_person_id=contact_person_id)

        RunQueue.enqueue(node, run_delay)
        queued_run = RunQueue.dequeue(contact_person_id)

        self.assertEqual(queued_run.status, RunQueue.STATUS.not_started)
        self.assertEqual(queued_run.contact_person_id, contact_person_id)
Beispiel #10
0
    def test_queues_run_for_particular_line_item_node(self):
        contact_person_id = 'id'
        run_delay = 1000

        node = DeliveryNodeFactory(contact_person_id=contact_person_id)

        RunQueue.enqueue(node, run_delay)
        queued_run = RunQueue.dequeue(contact_person_id)

        self.assertEqual(queued_run.status, RunQueue.STATUS.not_started)
        self.assertEqual(queued_run.contact_person_id, contact_person_id)
Beispiel #11
0
def _dequeue_next_run(contact_person_id, run_delay):
    next_run_queue = RunQueue.dequeue(contact_person_id=contact_person_id)
    if next_run_queue:
        schedule_run_for(next_run_queue.runnable, run_delay)
        next_run_queue.update_status(RunQueue.STATUS.started)
Beispiel #12
0
def _dequeue_next_run(line_item_run):
    next_run = RunQueue.dequeue(contact_person_id=line_item_run.node_line_item.distribution_plan_node.contact_person_id)
    _schedule_next_run(line_item_run.node_line_item)
    next_run.status = RunQueue.STATUS.started
    next_run.save()
Beispiel #13
0
def _dequeue_next_run(contact_person_id):
    next_run_queue = RunQueue.dequeue(contact_person_id=contact_person_id)
    if next_run_queue:
        _schedule_next_run(next_run_queue.runnable)
        next_run_queue.update_status(RunQueue.STATUS.started)
Beispiel #14
0
def _dequeue_next_run_for(runnable):
    next_run = RunQueue.dequeue(contact_person_id=runnable.contact_person_id)
    logger.info("next run is %s" % next_run)
    if next_run:
        schedule_run_for(next_run.runnable)
        next_run.update_status(RunQueue.STATUS.started)
Beispiel #15
0
def _dequeue_next_run(run):
    next_run = RunQueue.dequeue(contact_person_id=run.node.contact_person_id)
    if next_run:
        _schedule_next_run(next_run.node)
        next_run.status = RunQueue.STATUS.started
        next_run.save()
Beispiel #16
0
def _dequeue_next_run_for(runnable):
    next_run = RunQueue.dequeue(contact_person_id=runnable.contact_person_id)
    logger.info("next run is %s" % next_run)
    if next_run:
        schedule_run_for(next_run.runnable)
        next_run.update_status(RunQueue.STATUS.started)
Beispiel #17
0
    def test_deque_returns_none_when_contact_person_no_pending_runs(self):
        contact_person_id = 'id'
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started)
        RunQueueFactory(contact_person_id=contact_person_id, status=RunQueue.STATUS.started, run_delay=1000.0)

        self.assertEqual(RunQueue.dequeue(contact_person_id), None)