I want to test my python function which work is to extract all the data from the dynamoDB table
import boto3
import json
import constant as const
def connection():
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('file')
response = table.scan()['Items']
return response
And I am testing my above code using unit test. The code that I have written is given below
import unittest
from unittest import mock
import retrive
import constant
import boto3
class Test(unittest.TestCase):
@mock.patch('boto3.resource')
@mock.patch('boto3.resource.Table')
@mock.patch('table.scan')
def test_fetch_db_data(self, mock_boto3,mock_dynamo,mock_table):
mock_boto3.return_value()
mock_dynamo.return_value()
mock_table = {'Items':'key'}
result = retrive.connection()
self.assertEqual('key', result)
but this give me an error i.e ModuleNotFoundError: No module named 'table'