示例#1
0
    def test_async_function_scheduling(self):
        # Check the message on the queue.
        sqs_connection = boto.connect_sqs('', '')
        sqs_connection.create_queue(self.queue_name)
        queue = sqs_connection.get_queue(self.queue_name)
        messages = queue.get_messages()
        self.assertEquals(len(messages), 0)

        # Schedule a function.
        schedule_function(self.queue_name,
                          'a-function',
                          '1',
                          '2',
                          kwarg1=1,
                          kwarg2=2)

        messages = queue.get_messages()
        self.assertEquals(len(messages), 1)

        # For some reason, boto base64-encodes the messages, but moto does
        # not.  Life.
        self.assertEquals(
            json.loads(messages[0].get_body()), {
                FUNCTION: 'a-function',
                ARGS: ['1', '2'],
                KWARGS: {
                    'kwarg1': 1,
                    'kwarg2': 2
                }
            })
 def schedule(self, project_id, step_slug):
     if not settings.PRODUCTION and not settings.STAGING:
         scheduler = SynchronousMachineStepScheduler()
         scheduler.schedule(project_id, step_slug)
     else:
         schedule_function(settings.WORK_QUEUE, 'machine_task_executor',
                           project_id, step_slug)
示例#3
0
    def test_function_scheduling(self):
        # Check the message on the queue.
        sqs_connection = boto.connect_sqs('', '')
        sqs_connection.create_queue(self.queue_name)
        queue = sqs_connection.get_queue(self.queue_name)
        messages = queue.get_messages()
        self.assertEquals(len(messages), 0)

        # Schedule a function.
        schedule_function(
            self.queue_name, 'a-function', '1', '2', kwarg1=1, kwarg2=2)

        messages = queue.get_messages()
        self.assertEquals(len(messages), 1)

        # For some reason, boto base64-encodes the messages, but moto does
        # not.  Life.
        self.assertEquals(
            json.loads(messages[0].get_body()),
            {FUNCTION: 'a-function', ARGS: ['1', '2'], KWARGS: {
                'kwarg1': 1, 'kwarg2': 2}})
示例#4
0
    def test_sync_function_scheduling(self):
        # Schedule a function.
        schedule_function(self.queue_name, 'the_counter', 1, second_arg=5)

        self.assertEquals(CALL_COUNTER, 6)
示例#5
0
    def test_sync_function_scheduling(self):
        # Schedule a function.
        schedule_function(self.queue_name, 'the_counter', 1, second_arg=5)

        self.assertEquals(CALL_COUNTER, 6)
 def schedule(self, project_id, step_slug):
     if not settings.PRODUCTION and not settings.STAGING:
         scheduler = SynchronousMachineStepScheduler()
         scheduler.schedule(project_id, step_slug)
     else:
         schedule_function(settings.WORK_QUEUE, "machine_task_executor", project_id, step_slug)