Ejemplo n.º 1
0
 def test_lambda_handler__logger_level(self, logger_set_level, client_mock):
     global_vars = LambdaGlobals()
     lambda_handler = get_lambda_handler(self.Child, global_vars,
                                         self.TEST_CONFIG)
     event = {'k': 'm', 'logging_level': 20}
     lambda_handler(event=event, context={'context': 'test'})
     logger_set_level.assert_called_once_with(20)
Ejemplo n.º 2
0
    def test_lambda_handler(self):

        global_vars = LambdaGlobals()
        self.assertIsNone(global_vars.processor)
        self.assertIsNone(global_vars.lambda_context)

        lambda_handler = get_lambda_handler(self.Child, global_vars,
                                            self.TEST_CONFIG)
        self.assertIsNotNone(lambda_handler)

        for i in range(3):
            result = lambda_handler(event={'k': 'success'},
                                    context={'context': 'test'})
            self.assertEqual(type(global_vars.processor), self.Child)
            self.assertEqual(global_vars.lambda_context, {'context': 'test'})
            self.assertEqual(result, 'success')
            self.assertEqual(
                global_vars.processor.stats['total_processor_calls'], i + 1)
            self.assertEqual(
                global_vars.processor.stats['total_calls_register_clients'], 1)
Ejemplo n.º 3
0
"""Sosw Essential Scavenger
"""

import logging

from sosw.scavenger import Scavenger
from sosw.app import LambdaGlobals, get_lambda_handler

logger = logging.getLogger()
logger.setLevel(logging.INFO)


class Essential(Scavenger):
    pass


global_vars = LambdaGlobals()
lambda_handler = get_lambda_handler(Essential, global_vars)
Ejemplo n.º 4
0
Archivo: app.py Proyecto: sosw/sosw
"""Sosw Essential Orchestrator
"""

import logging

from sosw.orchestrator import Orchestrator
from sosw.app import LambdaGlobals, get_lambda_handler

logger = logging.getLogger()
logger.setLevel(logging.INFO)


class EssentialOrchestrator(Orchestrator):
    pass


global_vars = LambdaGlobals()
lambda_handler = get_lambda_handler(EssentialOrchestrator, global_vars)
Ejemplo n.º 5
0
Archivo: app.py Proyecto: sosw/sosw
"""Sosw Essential Scavenger
"""

import logging

from sosw.scavenger import Scavenger
from sosw.app import LambdaGlobals, get_lambda_handler

logger = logging.getLogger()
logger.setLevel(logging.INFO)


class EssentialScavenger(Scavenger):
    pass


global_vars = LambdaGlobals()
lambda_handler = get_lambda_handler(EssentialScavenger, global_vars)
Ejemplo n.º 6
0
Archivo: app.py Proyecto: ngr/lovemath
               self.dynamo_db_client.get_by_query({"session": session}, return_count=True)

    def get_results(self, **kwargs):
        session = kwargs['session']
        results = self.dynamo_db_client.get_by_query({"session": session},
                                                     fetch_all_fields=True)
        return results

    def is_authenticated(self, api_token=None, env='production'):
        """
        Need to implement with Cognito.
        LambdaAPI currently supports only the external proprietary auth endpoint.

        Current version for my Mark bypasses auth mechanism.
        """
        return True

    def generate_number(self, session):
        """ Supposed to get complexity based on user skills identified by ``session`` and generate a number. """
        return random.randint(0, 20)
        raise NotImplementedError()

    def get_operator(self, session):
        """ Supposed to get complexity based on user skills identified by ``session`` and return an operator. """
        return random.choice(self.config['supported_operators'])
        raise NotImplementedError()


global_vars = LambdaGlobals()
lambda_handler = get_lambda_handler(Processor, global_vars)
Ejemplo n.º 7
0
"""Sosw Essential WorkerAssistant
"""

import logging

from sosw.worker_assistant import WorkerAssistant
from sosw.app import LambdaGlobals, get_lambda_handler

logger = logging.getLogger()
logger.setLevel(logging.INFO)


class EssentialWorkerAssistant(WorkerAssistant):
    pass


global_vars = LambdaGlobals()
lambda_handler = get_lambda_handler(EssentialWorkerAssistant, global_vars)
Ejemplo n.º 8
0
Archivo: app.py Proyecto: sosw/sosw
"""Sosw Essential Scheduler
"""

import logging

from sosw.scheduler import Scheduler
from sosw.app import LambdaGlobals, get_lambda_handler

logger = logging.getLogger()
logger.setLevel(logging.INFO)


class EssentialScheduler(Scheduler):
    pass


global_vars = LambdaGlobals()
lambda_handler = get_lambda_handler(EssentialScheduler, global_vars)