File tree Expand file tree Collapse file tree 2 files changed +7
-16
lines changed
Expand file tree Collapse file tree 2 files changed +7
-16
lines changed Original file line number Diff line number Diff line change 11from datetime import datetime
22from utils .base_test import ImmunizationBaseTest
33from utils .immunisation_api import parse_location
4- from utils .resource import generate_imms_resource
5- from mypy_boto3_dynamodb .service_resource import DynamoDBServiceResource
4+ from utils .resource import generate_imms_resource , get_dynamodb_table
65import time
76import copy
8- import boto3
9- from botocore .config import Config
107import os
118
129
@@ -17,14 +14,9 @@ class TestDeltaImmunization(ImmunizationBaseTest):
1714 DELETE_OPERATION = "DELETE"
1815 DPS_SOURCE = "DPS"
1916
20- def get_delta_table (self ):
21- config = Config (connect_timeout = 1 , read_timeout = 1 , retries = {"max_attempts" : 1 })
22- db : DynamoDBServiceResource = boto3 .resource ("dynamodb" , region_name = "eu-west-2" , config = config )
23- return db .Table (os .getenv ("IMMS_DELTA_TABLE_NAME" ))
24-
2517 def test_create_delta_imms (self ):
2618 """Should create,update,delete FHIR Immunization resource causing those resources to be stored in Delta table"""
27- imms_delta_table = self . get_delta_table ( )
19+ imms_delta_table = get_dynamodb_table ( os . getenv ( "IMMS_DELTA_TABLE_NAME" ) )
2820 # Given
2921 start_timestamp = datetime .now ().strftime ("%Y-%m-%dT%H:%M:%S" )
3022 # Creating two Imms Event, one of them will be updated and second of them will be deleted afterwards
Original file line number Diff line number Diff line change @@ -132,22 +132,21 @@ def get_patient_postal_code(imms: dict):
132132
133133
134134def get_full_row_from_identifier (identifier : str ) -> dict :
135- table = get_dynamodb_table ()
136-
135+ table = get_dynamodb_table (os .getenv ("DYNAMODB_TABLE_NAME" ))
137136 return table .get_item (Key = {"PK" : f"Immunization#{ identifier } " }).get ("Item" )
138137
139138
140- def get_dynamodb_table () -> Table :
141- config = Config (connect_timeout = 5 , read_timeout = 5 , retries = {"max_attempts" : 5 })
139+ def get_dynamodb_table (table_name : str ) -> Table :
140+ config = Config (connect_timeout = 60 , read_timeout = 60 , retries = {"max_attempts" : 3 })
142141 db : DynamoDBServiceResource = boto3 .resource ("dynamodb" , region_name = "eu-west-2" , config = config )
143- return db .Table (os . getenv ( "DYNAMODB_TABLE_NAME" ) )
142+ return db .Table (table_name )
144143
145144
146145def delete_imms_records (identifiers : list [str ]) -> None :
147146 """Batch delete immunization records from the DynamoDB table.
148147 Handles logging internally and does not return anything.
149148 """
150- table = get_dynamodb_table ()
149+ table = get_dynamodb_table (os . getenv ( "DYNAMODB_TABLE_NAME" ) )
151150 success_count = 0
152151 failure_count = 0
153152 total = len (identifiers )
You can’t perform that action at this time.
0 commit comments