bringing up test percentage
This commit is contained in:
		
							parent
							
								
									20dc8ae5c4
								
							
						
					
					
						commit
						dff24cb032
					
				| @ -296,9 +296,6 @@ class LambdaFunction(BaseModel): | |||||||
|         if 'DryRun' in updated_spec and updated_spec['DryRun']: |         if 'DryRun' in updated_spec and updated_spec['DryRun']: | ||||||
|             return self.get_configuration() |             return self.get_configuration() | ||||||
| 
 | 
 | ||||||
|         if 'Publish' in updated_spec and updated_spec['Publish']: |  | ||||||
|             self.set_version(self.version + 1) |  | ||||||
| 
 |  | ||||||
|         if 'ZipFile' in updated_spec: |         if 'ZipFile' in updated_spec: | ||||||
|             self.code['ZipFile'] = updated_spec['ZipFile'] |             self.code['ZipFile'] = updated_spec['ZipFile'] | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -342,6 +342,9 @@ class LambdaResponse(BaseResponse): | |||||||
|         fn = self.lambda_backend.get_function(function_name, qualifier) |         fn = self.lambda_backend.get_function(function_name, qualifier) | ||||||
| 
 | 
 | ||||||
|         if fn: |         if fn: | ||||||
|  |             if self.json_body.get('Publish', False): | ||||||
|  |                 fn = self.lambda_backend.publish_function(function_name) | ||||||
|  | 
 | ||||||
|             config = fn.update_function_code(self.json_body) |             config = fn.update_function_code(self.json_body) | ||||||
|             return 200, {}, json.dumps(config) |             return 200, {}, json.dumps(config) | ||||||
|         else: |         else: | ||||||
|  | |||||||
| @ -1295,13 +1295,13 @@ def test_update_configuration(): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @mock_lambda | @mock_lambda | ||||||
| def test_update_function(): | def test_update_function_zip(): | ||||||
|     conn = boto3.client('lambda', 'us-west-2') |     conn = boto3.client('lambda', 'us-west-2') | ||||||
| 
 | 
 | ||||||
|     zip_content_one = get_test_zip_file1() |     zip_content_one = get_test_zip_file1() | ||||||
| 
 | 
 | ||||||
|     fxn = conn.create_function( |     fxn = conn.create_function( | ||||||
|         FunctionName='testFunction', |         FunctionName='testFunctionZip', | ||||||
|         Runtime='python2.7', |         Runtime='python2.7', | ||||||
|         Role='test-iam-role', |         Role='test-iam-role', | ||||||
|         Handler='lambda_function.lambda_handler', |         Handler='lambda_function.lambda_handler', | ||||||
| @ -1317,13 +1317,14 @@ def test_update_function(): | |||||||
|     zip_content_two = get_test_zip_file2() |     zip_content_two = get_test_zip_file2() | ||||||
| 
 | 
 | ||||||
|     fxn_updated = conn.update_function_code( |     fxn_updated = conn.update_function_code( | ||||||
|         FunctionName='testFunction', |         FunctionName='testFunctionZip', | ||||||
|         ZipFile=zip_content_two, |         ZipFile=zip_content_two, | ||||||
|         Publish=True |         Publish=True | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     response = conn.get_function( |     response = conn.get_function( | ||||||
|         FunctionName='testFunction' |         FunctionName='testFunctionZip', | ||||||
|  |         Qualifier='2' | ||||||
|     ) |     ) | ||||||
|     response['Configuration'].pop('LastModified') |     response['Configuration'].pop('LastModified') | ||||||
| 
 | 
 | ||||||
| @ -1336,14 +1337,80 @@ def test_update_function(): | |||||||
|             "CodeSha256": hashlib.sha256(zip_content_two).hexdigest(), |             "CodeSha256": hashlib.sha256(zip_content_two).hexdigest(), | ||||||
|             "CodeSize": len(zip_content_two), |             "CodeSize": len(zip_content_two), | ||||||
|             "Description": "test lambda function", |             "Description": "test lambda function", | ||||||
|             "FunctionArn": 'arn:aws:lambda:{}:123456789012:function:testFunction:2'.format(_lambda_region), |             "FunctionArn": 'arn:aws:lambda:{}:123456789012:function:testFunctionZip:2'.format(_lambda_region), | ||||||
|             "FunctionName": "testFunction", |             "FunctionName": "testFunctionZip", | ||||||
|             "Handler": "lambda_function.lambda_handler", |             "Handler": "lambda_function.lambda_handler", | ||||||
|             "MemorySize": 128, |             "MemorySize": 128, | ||||||
|             "Role": "test-iam-role", |             "Role": "test-iam-role", | ||||||
|             "Runtime": "python2.7", |             "Runtime": "python2.7", | ||||||
|             "Timeout": 3, |             "Timeout": 3, | ||||||
|             "Version": '$LATEST', |             "Version": '2', | ||||||
|  |             "VpcConfig": { | ||||||
|  |                 "SecurityGroupIds": [], | ||||||
|  |                 "SubnetIds": [], | ||||||
|  |             } | ||||||
|  |         }, | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  | @mock_lambda | ||||||
|  | @mock_s3 | ||||||
|  | def test_update_function_s3(): | ||||||
|  |     s3_conn = boto3.client('s3', 'us-west-2') | ||||||
|  |     s3_conn.create_bucket(Bucket='test-bucket') | ||||||
|  | 
 | ||||||
|  |     zip_content = get_test_zip_file1() | ||||||
|  |     s3_conn.put_object(Bucket='test-bucket', Key='test.zip', Body=zip_content) | ||||||
|  | 
 | ||||||
|  |     conn = boto3.client('lambda', 'us-west-2') | ||||||
|  | 
 | ||||||
|  |     fxn = conn.create_function( | ||||||
|  |         FunctionName='testFunctionS3', | ||||||
|  |         Runtime='python2.7', | ||||||
|  |         Role='test-iam-role', | ||||||
|  |         Handler='lambda_function.lambda_handler', | ||||||
|  |         Code={ | ||||||
|  |             'S3Bucket': 'test-bucket', | ||||||
|  |             'S3Key': 'test.zip', | ||||||
|  |         }, | ||||||
|  |         Description='test lambda function', | ||||||
|  |         Timeout=3, | ||||||
|  |         MemorySize=128, | ||||||
|  |         Publish=True, | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     zip_content_two = get_test_zip_file2() | ||||||
|  |     s3_conn.put_object(Bucket='test-bucket', Key='test2.zip', Body=zip_content_two) | ||||||
|  | 
 | ||||||
|  |     fxn_updated = conn.update_function_code( | ||||||
|  |         FunctionName='testFunctionS3', | ||||||
|  |         S3Bucket='test-bucket', | ||||||
|  |         S3Key='test2.zip', | ||||||
|  |         Publish=True | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     response = conn.get_function( | ||||||
|  |         FunctionName='testFunctionS3', | ||||||
|  |         Qualifier='2' | ||||||
|  |     ) | ||||||
|  |     response['Configuration'].pop('LastModified') | ||||||
|  | 
 | ||||||
|  |     response['ResponseMetadata']['HTTPStatusCode'].should.equal(200) | ||||||
|  |     assert len(response['Code']) == 2 | ||||||
|  |     assert response['Code']['RepositoryType'] == 'S3' | ||||||
|  |     assert response['Code']['Location'].startswith('s3://awslambda-{0}-tasks.s3-{0}.amazonaws.com'.format(_lambda_region)) | ||||||
|  |     response['Configuration'].should.equal( | ||||||
|  |         { | ||||||
|  |             "CodeSha256": hashlib.sha256(zip_content_two).hexdigest(), | ||||||
|  |             "CodeSize": len(zip_content_two), | ||||||
|  |             "Description": "test lambda function", | ||||||
|  |             "FunctionArn": 'arn:aws:lambda:{}:123456789012:function:testFunctionS3:2'.format(_lambda_region), | ||||||
|  |             "FunctionName": "testFunctionS3", | ||||||
|  |             "Handler": "lambda_function.lambda_handler", | ||||||
|  |             "MemorySize": 128, | ||||||
|  |             "Role": "test-iam-role", | ||||||
|  |             "Runtime": "python2.7", | ||||||
|  |             "Timeout": 3, | ||||||
|  |             "Version": '2', | ||||||
|             "VpcConfig": { |             "VpcConfig": { | ||||||
|                 "SecurityGroupIds": [], |                 "SecurityGroupIds": [], | ||||||
|                 "SubnetIds": [], |                 "SubnetIds": [], | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user