Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nofails_funcs(self):
funk = import_and_get_task("tests.test_app.async_me")
get_func_task_path(funk)
self.assertEqual(funk.__name__, 'async_me')
def test_sync_call(self):
funk = import_and_get_task("tests.test_app.async_me")
self.assertEqual(funk.sync('123'), "run async when on lambda 123")
def test_async_call_with_defaults(self):
"""Change a task's asynchronousity at runtime."""
# Import the task first to make sure it is decorated whilst the
# environment is unpatched.
async_me = import_and_get_task("tests.test_app.async_me")
lambda_async_mock = mock.Mock()
lambda_async_mock.return_value.send.return_value = "Running async!"
with mock.patch.dict('zappa.asynchronous.ASYNC_CLASSES',
{'lambda': lambda_async_mock}):
# First check that it still runs synchronously by default
self.assertEqual(async_me("123"),
"run async when on lambda 123")
# Now patch the environment to make it look like we are running on
# AWS Lambda
options = {
'AWS_LAMBDA_FUNCTION_NAME': 'MyLambda',
'AWS_REGION': 'us-east-1'
}
with mock.patch.dict(os.environ, options):
self.assertEqual(async_me("qux"),