| 
									
										
										
										
											2021-10-04 13:47:40 +00:00
										 |  |  | import boto3 | 
					
						
							|  |  |  | import json | 
					
						
							| 
									
										
										
										
											2021-10-18 19:44:29 +00:00
										 |  |  | import sure  # noqa # pylint: disable=unused-import | 
					
						
							| 
									
										
										
										
											2021-10-04 13:47:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-09 16:57:25 -01:00
										 |  |  | from moto import mock_cloudformation, mock_dynamodb | 
					
						
							| 
									
										
										
										
											2021-10-04 13:47:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template_create_table = { | 
					
						
							|  |  |  |     "AWSTemplateFormatVersion": "2010-09-09", | 
					
						
							|  |  |  |     "Resources": { | 
					
						
							|  |  |  |         "myDynamoDBTable": { | 
					
						
							|  |  |  |             "Type": "AWS::DynamoDB::Table", | 
					
						
							|  |  |  |             "Properties": { | 
					
						
							|  |  |  |                 "AttributeDefinitions": [ | 
					
						
							|  |  |  |                     {"AttributeName": "Name", "AttributeType": "S"}, | 
					
						
							|  |  |  |                     {"AttributeName": "Age", "AttributeType": "S"}, | 
					
						
							|  |  |  |                 ], | 
					
						
							|  |  |  |                 "KeySchema": [ | 
					
						
							|  |  |  |                     {"AttributeName": "Name", "KeyType": "HASH"}, | 
					
						
							|  |  |  |                     {"AttributeName": "Age", "KeyType": "RANGE"}, | 
					
						
							|  |  |  |                 ], | 
					
						
							|  |  |  |                 "ProvisionedThroughput": { | 
					
						
							|  |  |  |                     "ReadCapacityUnits": 5, | 
					
						
							|  |  |  |                     "WriteCapacityUnits": 5, | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |                 "TableName": "Person", | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-09 16:57:25 -01:00
										 |  |  | @mock_dynamodb | 
					
						
							| 
									
										
										
										
											2021-10-04 13:47:40 +00:00
										 |  |  | @mock_cloudformation | 
					
						
							|  |  |  | def test_delete_stack_dynamo_template_boto3(): | 
					
						
							|  |  |  |     conn = boto3.client("cloudformation", region_name="us-east-1") | 
					
						
							|  |  |  |     dynamodb_client = boto3.client("dynamodb", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     conn.create_stack( | 
					
						
							|  |  |  |         StackName="test_stack", TemplateBody=json.dumps(template_create_table) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     table_desc = dynamodb_client.list_tables() | 
					
						
							|  |  |  |     len(table_desc.get("TableNames")).should.equal(1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     conn.delete_stack(StackName="test_stack") | 
					
						
							|  |  |  |     table_desc = dynamodb_client.list_tables() | 
					
						
							|  |  |  |     len(table_desc.get("TableNames")).should.equal(0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     conn.create_stack( | 
					
						
							|  |  |  |         StackName="test_stack", TemplateBody=json.dumps(template_create_table) | 
					
						
							|  |  |  |     ) |