Example #1
0
 def test_lambda_client_error_wording_for_update(self):
     lambda_error = LambdaClientError(
         Exception('My Exception'),
         context=LambdaErrorContext(
             function_name='foo',
             client_method_name='update_function_code',
             deployment_size=1024**2))
     deploy_error = ChaliceDeploymentError(lambda_error)
     deploy_error_msg = str(deploy_error)
     assert ('sending your chalice handler code to '
             'Lambda to update function' in deploy_error_msg)
Example #2
0
 def test_lambda_client_error(self):
     lambda_error = LambdaClientError(
         Exception('My Exception'),
         context=LambdaErrorContext(function_name='foo',
                                    client_method_name='create_function',
                                    deployment_size=1024**2))
     deploy_error = ChaliceDeploymentError(lambda_error)
     deploy_error_msg = str(deploy_error)
     assert ('ERROR - While sending your chalice handler code to '
             'Lambda to create function \n"foo"' in deploy_error_msg)
     assert 'My Exception' in deploy_error_msg
Example #3
0
 def test_simplifies_error_msg_for_timeout(self):
     lambda_error = DeploymentPackageTooLargeError(
         RequestsConnectionError(
             Exception('Connection aborted.',
                       socket.timeout('The write operation timed out'))),
         context=LambdaErrorContext(function_name='foo',
                                    client_method_name='create_function',
                                    deployment_size=1024**2))
     deploy_error = ChaliceDeploymentError(lambda_error)
     deploy_error_msg = str(deploy_error)
     assert ('Connection aborted. Timed out sending your app to Lambda.'
             in deploy_error_msg)
Example #4
0
 def test_simplifies_error_msg_for_broken_pipe(self):
     lambda_error = DeploymentPackageTooLargeError(
         RequestsConnectionError(
             Exception('Connection aborted.',
                       socket.error(32, 'Broken pipe'))),
         context=LambdaErrorContext(function_name='foo',
                                    client_method_name='create_function',
                                    deployment_size=1024**2))
     deploy_error = ChaliceDeploymentError(lambda_error)
     deploy_error_msg = str(deploy_error)
     assert ('Connection aborted. Lambda closed the connection'
             in deploy_error_msg)
Example #5
0
 def test_error_msg_for_general_connection(self):
     lambda_error = DeploymentPackageTooLargeError(
         RequestsConnectionError(
             Exception('Connection aborted.',
                       socket.error('Some vague reason'))),
         context=LambdaErrorContext(function_name='foo',
                                    client_method_name='create_function',
                                    deployment_size=1024**2))
     deploy_error = ChaliceDeploymentError(lambda_error)
     deploy_error_msg = str(deploy_error)
     assert 'Connection aborted.' in deploy_error_msg
     assert 'Some vague reason' not in deploy_error_msg
Example #6
0
 def test_include_size_context_for_too_large_deployment_error(self):
     too_large_error = DeploymentPackageTooLargeError(
         Exception('Too large of deployment pacakge'),
         context=LambdaErrorContext(
             function_name='foo',
             client_method_name='create_function',
             deployment_size=58 * (1024**2),
         ))
     deploy_error = ChaliceDeploymentError(too_large_error)
     deploy_error_msg = str(deploy_error)
     print(repr(deploy_error_msg))
     assert 'deployment package is 58.0 MB' in deploy_error_msg
     assert '50.0 MB or less' in deploy_error_msg
     assert 'To avoid this error' in deploy_error_msg
Example #7
0
 def test_gives_where_and_suggestion_for_too_large_deployment_error(self):
     too_large_error = DeploymentPackageTooLargeError(
         Exception('Too large of deployment pacakge'),
         context=LambdaErrorContext(
             function_name='foo',
             client_method_name='create_function',
             deployment_size=1024**2,
         ))
     deploy_error = ChaliceDeploymentError(too_large_error)
     deploy_error_msg = str(deploy_error)
     assert ('ERROR - While sending your chalice handler code to '
             'Lambda to create function \n"foo"' in deploy_error_msg)
     assert 'Too large of deployment pacakge' in deploy_error_msg
     assert ('To avoid this error, decrease the size of your chalice '
             'application ' in deploy_error_msg)