11import unittest
22from unittest .mock import patch , MagicMock
3- from common .aws_dynamodb import get_delta_table
3+ from common .aws_dynamodb import get_dynamodb_table
44
55
6- class TestGetDeltaTable (unittest .TestCase ):
6+ class TestGetIedsTable (unittest .TestCase ):
77
88 AWS_REGION = "eu-west-2" # Add this missing constant
99
@@ -21,34 +21,34 @@ def setUp(self):
2121 "AWS_REGION" : self .AWS_REGION
2222 }.get (key , default )
2323
24- self .dynamodb_client_patcher = patch ('common.aws_dynamodb.dynamodb_client ' )
25- self .mock_dynamodb_client = self .dynamodb_client_patcher .start ()
24+ self .dynamodb_resource_patcher = patch ('common.aws_dynamodb.dynamodb_resource ' )
25+ self .mock_dynamodb_resource = self .dynamodb_resource_patcher .start ()
2626
2727 def tearDown (self ):
2828 patch .stopall ()
2929
30- def test_get_delta_table_success (self ):
30+ def test_get_ieds_table_success (self ):
3131 # Create a mock table object
3232 table_name = "abc"
3333 mock_table = MagicMock ()
34- self .mock_dynamodb_client .Table .return_value = mock_table
34+ self .mock_dynamodb_resource .Table .return_value = mock_table
3535
3636 # Call the function
37- table = get_delta_table (table_name )
37+ table = get_dynamodb_table (table_name )
3838
39- self .mock_dynamodb_client .Table .assert_called_once_with (table_name )
39+ self .mock_dynamodb_resource .Table .assert_called_once_with (table_name )
4040 self .assertEqual (table , mock_table )
4141 # Verify the success logging
4242 self .mock_logger_info .assert_called_once_with ("Initializing table: %s" , table_name )
4343
44- def test_get_delta_table_failure (self ):
44+ def test_get_ieds_table_failure (self ):
4545 # Simulate exception when accessing Table
4646 msg = "DynamoDB failure"
47- self .mock_dynamodb_client .Table .side_effect = Exception (msg )
47+ self .mock_dynamodb_resource .Table .side_effect = Exception (msg )
4848 table_name = "abc"
4949
5050 with self .assertRaises (Exception ) as context :
51- get_delta_table (table_name )
51+ get_dynamodb_table (table_name )
5252
5353 self .assertEqual (str (context .exception ), msg )
5454 # This should now work - mocking the instance method
0 commit comments