@@ -97,6 +97,16 @@ def s3_client(boto3_session: Session, localstack: URL) -> BaseClient:
9797 return boto3_session .client ("s3" , endpoint_url = str (localstack ))
9898
9999
100+ @pytest .fixture (scope = "session" )
101+ def firehose_client (boto3_session : Session , localstack : URL ) -> BaseClient :
102+ return boto3_session .client ("firehose" , endpoint_url = str (localstack ))
103+
104+
105+ @pytest .fixture (autouse = True )
106+ def firehose_delivery_stream (firehose_client : BaseClient ) -> dict [str , Any ]:
107+ return firehose_client .create_delivery_stream (DeliveryStreamName = "eligibility-signposting-audit-stream" )
108+
109+
100110@pytest .fixture (scope = "session" )
101111def iam_role (iam_client : BaseClient ) -> Generator [str ]:
102112 role_name = "LambdaExecutionRole"
@@ -190,6 +200,7 @@ def flask_function(lambda_client: BaseClient, iam_role: str, lambda_zip: Path) -
190200 "Variables" : {
191201 "DYNAMODB_ENDPOINT" : os .getenv ("LOCALSTACK_INTERNAL_ENDPOINT" , "http://localstack:4566/" ),
192202 "S3_ENDPOINT" : os .getenv ("LOCALSTACK_INTERNAL_ENDPOINT" , "http://localstack:4566/" ),
203+ "FIREHOSE_ENDPOINT" : os .getenv ("LOCALSTACK_INTERNAL_ENDPOINT" , "http://localstack:4566/" ),
193204 "AWS_REGION" : AWS_REGION ,
194205 "LOG_LEVEL" : "DEBUG" ,
195206 }
@@ -372,15 +383,23 @@ def persisted_person_pc_sw19(person_table: Any, faker: Faker) -> Generator[eligi
372383
373384
374385@pytest .fixture (scope = "session" )
375- def bucket (s3_client : BaseClient ) -> Generator [BucketName ]:
386+ def rules_bucket (s3_client : BaseClient ) -> Generator [BucketName ]:
376387 bucket_name = BucketName (os .getenv ("RULES_BUCKET_NAME" , "test-rules-bucket" ))
377388 s3_client .create_bucket (Bucket = bucket_name , CreateBucketConfiguration = {"LocationConstraint" : AWS_REGION })
378389 yield bucket_name
379390 s3_client .delete_bucket (Bucket = bucket_name )
380391
381392
393+ @pytest .fixture (scope = "session" )
394+ def audit_bucket (s3_client : BaseClient ) -> Generator [BucketName ]:
395+ bucket_name = BucketName (os .getenv ("AUDIT_BUCKET_NAME" , "test-audit-bucket" ))
396+ s3_client .create_bucket (Bucket = bucket_name , CreateBucketConfiguration = {"LocationConstraint" : AWS_REGION })
397+ yield bucket_name
398+ s3_client .delete_bucket (Bucket = bucket_name )
399+
400+
382401@pytest .fixture (scope = "class" )
383- def campaign_config (s3_client : BaseClient , bucket : BucketName ) -> Generator [rules .CampaignConfig ]:
402+ def campaign_config (s3_client : BaseClient , rules_bucket : BucketName ) -> Generator [rules .CampaignConfig ]:
384403 campaign : rules .CampaignConfig = rule .CampaignConfigFactory .build (
385404 target = "RSV" ,
386405 iterations = [
@@ -402,14 +421,16 @@ def campaign_config(s3_client: BaseClient, bucket: BucketName) -> Generator[rule
402421 )
403422 campaign_data = {"CampaignConfig" : campaign .model_dump (by_alias = True )}
404423 s3_client .put_object (
405- Bucket = bucket , Key = f"{ campaign .name } .json" , Body = json .dumps (campaign_data ), ContentType = "application/json"
424+ Bucket = rules_bucket , Key = f"{ campaign .name } .json" , Body = json .dumps (campaign_data ), ContentType = "application/json"
406425 )
407426 yield campaign
408- s3_client .delete_object (Bucket = bucket , Key = f"{ campaign .name } .json" )
427+ s3_client .delete_object (Bucket = rules_bucket , Key = f"{ campaign .name } .json" )
409428
410429
411430@pytest .fixture (scope = "class" )
412- def campaign_config_with_magic_cohort (s3_client : BaseClient , bucket : BucketName ) -> Generator [rules .CampaignConfig ]:
431+ def campaign_config_with_magic_cohort (
432+ s3_client : BaseClient , rules_bucket : BucketName
433+ ) -> Generator [rules .CampaignConfig ]:
413434 campaign : rules .CampaignConfig = rule .CampaignConfigFactory .build (
414435 target = "COVID" ,
415436 iterations = [
@@ -424,15 +445,15 @@ def campaign_config_with_magic_cohort(s3_client: BaseClient, bucket: BucketName)
424445 )
425446 campaign_data = {"CampaignConfig" : campaign .model_dump (by_alias = True )}
426447 s3_client .put_object (
427- Bucket = bucket , Key = f"{ campaign .name } .json" , Body = json .dumps (campaign_data ), ContentType = "application/json"
448+ Bucket = rules_bucket , Key = f"{ campaign .name } .json" , Body = json .dumps (campaign_data ), ContentType = "application/json"
428449 )
429450 yield campaign
430- s3_client .delete_object (Bucket = bucket , Key = f"{ campaign .name } .json" )
451+ s3_client .delete_object (Bucket = rules_bucket , Key = f"{ campaign .name } .json" )
431452
432453
433454@pytest .fixture (scope = "class" )
434455def campaign_config_with_missing_descriptions_missing_rule_text (
435- s3_client : BaseClient , bucket : BucketName
456+ s3_client : BaseClient , rules_bucket : BucketName
436457) -> Generator [rules .CampaignConfig ]:
437458 campaign : rules .CampaignConfig = rule .CampaignConfigFactory .build (
438459 target = "FLU" ,
@@ -456,7 +477,7 @@ def campaign_config_with_missing_descriptions_missing_rule_text(
456477 )
457478 campaign_data = {"CampaignConfig" : campaign .model_dump (by_alias = True )}
458479 s3_client .put_object (
459- Bucket = bucket , Key = f"{ campaign .name } .json" , Body = json .dumps (campaign_data ), ContentType = "application/json"
480+ Bucket = rules_bucket , Key = f"{ campaign .name } .json" , Body = json .dumps (campaign_data ), ContentType = "application/json"
460481 )
461482 yield campaign
462- s3_client .delete_object (Bucket = bucket , Key = f"{ campaign .name } .json" )
483+ s3_client .delete_object (Bucket = rules_bucket , Key = f"{ campaign .name } .json" )
0 commit comments