I'm currently implementing unit tests for a VPC creation automation script. I would like to mock the boto3 object so no actual calls to aws are made and assert that create_vpc and or any other call is being run via a unit test.
I have tried using moto but as it is not fully implemented it wouldn't work for some of my tests. This is some of the code I am testing.
class Vpc:
def __init__(self):
self.__ec2 = boto3.resource('ec2')
self.vpc = None
def create(self):
self.vpc = self.__ec2.create_vpc(CidrBlock=10.0.0.1/16)
if __name__ == "__main__":
vpc = Vpc()
vpc.create()
I have tried using mock and patch but I'm not familiar with the boto3 lib so not sure what call I need to mock. Any help/code suggestions will be appreciated.