11"""Generic setup and teardown for ACK backend tests"""
22
3- from unittest .mock import patch
4-
5- from tests .utils .mock_environment_variables import BucketNames , MOCK_ENVIRONMENT_DICT , Firehose
6-
7- # Ensure environment variables are mocked before importing from src files
8- with patch .dict ("os.environ" , MOCK_ENVIRONMENT_DICT ):
9- from clients import REGION_NAME
10- from constants import AuditTableKeys , AUDIT_TABLE_NAME , AUDIT_TABLE_QUEUE_NAME_GSI , AUDIT_TABLE_FILENAME_GSI
3+ from tests .utils .mock_environment_variables import BucketNames , Firehose , REGION_NAME
114
125
136class GenericSetUp :
@@ -18,7 +11,7 @@ class GenericSetUp:
1811 * If firehose_client is provided, creates a firehose delivery stream
1912 """
2013
21- def __init__ (self , s3_client = None , firehose_client = None , dynamodb_client = None ):
14+ def __init__ (self , s3_client = None , firehose_client = None ):
2215
2316 if s3_client :
2417 for bucket_name in [BucketNames .SOURCE , BucketNames .DESTINATION , BucketNames .MOCK_FIREHOSE ]:
@@ -37,41 +30,11 @@ def __init__(self, s3_client=None, firehose_client=None, dynamodb_client=None):
3730 },
3831 )
3932
40- if dynamodb_client :
41- dynamodb_client .create_table (
42- TableName = AUDIT_TABLE_NAME ,
43- KeySchema = [{"AttributeName" : AuditTableKeys .MESSAGE_ID , "KeyType" : "HASH" }],
44- AttributeDefinitions = [
45- {"AttributeName" : AuditTableKeys .MESSAGE_ID , "AttributeType" : "S" },
46- {"AttributeName" : AuditTableKeys .FILENAME , "AttributeType" : "S" },
47- {"AttributeName" : AuditTableKeys .QUEUE_NAME , "AttributeType" : "S" },
48- {"AttributeName" : AuditTableKeys .STATUS , "AttributeType" : "S" },
49- ],
50- ProvisionedThroughput = {"ReadCapacityUnits" : 5 , "WriteCapacityUnits" : 5 },
51- GlobalSecondaryIndexes = [
52- {
53- "IndexName" : AUDIT_TABLE_FILENAME_GSI ,
54- "KeySchema" : [{"AttributeName" : AuditTableKeys .FILENAME , "KeyType" : "HASH" }],
55- "Projection" : {"ProjectionType" : "KEYS_ONLY" },
56- "ProvisionedThroughput" : {"ReadCapacityUnits" : 5 , "WriteCapacityUnits" : 5 },
57- },
58- {
59- "IndexName" : AUDIT_TABLE_QUEUE_NAME_GSI ,
60- "KeySchema" : [
61- {"AttributeName" : AuditTableKeys .QUEUE_NAME , "KeyType" : "HASH" },
62- {"AttributeName" : AuditTableKeys .STATUS , "KeyType" : "RANGE" },
63- ],
64- "Projection" : {"ProjectionType" : "ALL" },
65- "ProvisionedThroughput" : {"ReadCapacityUnits" : 5 , "WriteCapacityUnits" : 5 },
66- },
67- ],
68- )
69-
7033
7134class GenericTearDown :
7235 """Performs generic tear down of mock resources"""
7336
74- def __init__ (self , s3_client = None , firehose_client = None , dynamodb_client = None ):
37+ def __init__ (self , s3_client = None , firehose_client = None ):
7538
7639 if s3_client :
7740 for bucket_name in [BucketNames .SOURCE , BucketNames .DESTINATION , BucketNames .MOCK_FIREHOSE ]:
@@ -80,7 +43,4 @@ def __init__(self, s3_client=None, firehose_client=None, dynamodb_client=None):
8043 s3_client .delete_bucket (Bucket = bucket_name )
8144
8245 if firehose_client :
83- firehose_client .delete_delivery_stream (DeliveryStreamName = Firehose .STREAM_NAME )
84-
85- if dynamodb_client :
86- dynamodb_client .delete_table (TableName = AUDIT_TABLE_NAME )
46+ firehose_client .delete_delivery_stream (DeliveryStreamName = Firehose .STREAM_NAME )
0 commit comments