I'm trying to use this answer as an example to test that a dynamo table is not written to.
Because I am using moto to test my reads & writes, I have to do the import inside the test case. I cannot get patch to take, keep getting SSL errors I've tried:
@patch('boto3.resource')
def my_test(self, mock_boto_resource)
import code_under_test
table_mock = MagicMock()
ddb_mock = MagicMock().return_value(table_mock)
mock_boto_resource.return_value = ddb_mock
code_under_test.execute
table_mock.assert_called_once()
I've tried moving the import after assigning the resource. I've tried using context def my_test(self)
table_mock = MagicMock()
ddb_mock = MagicMock().return_value(table_mock)
with patch('boto3.resource') as mock_boto_resource
mock_boto_resource.return_value = ddb_mock
import code_under_test
code_under_test.execute
table_mock.assert_called_once()
Again tried moving the import around. A normal execute() does a query & put. I want to test in some cases that the query does not occur, but I cannot get that far, because I keep getting botocor.exception.SSLError
I also found this answer, but having trouble figuring out what the equivalent method in resource is.