I have a function called check_stuff and it instantiates an object and calls the function describe_continuous_backups
, however, moto doesn't have support for this yet so I need to manually mock it myself. I have the following but it doesn't seem like I'm able to patch the object. How can I go about this?
def check_stuff(profile, table_name):
session = boto3.Session(profile_name=profile)
client = session.client('dynamodb', 'eu-west-1')
some_stuff = client.describe_continuous_backups(TableName=table_name)
#dostuff
@mock_dynamodb2
@mock.patch('boto3.Session.client.describe_continuous_backups', return_value={'foo': 'bar'})
def test_continuous_backup_disabled(self):
table = self.client.create_table(
TableName='Movies',
KeySchema=[
{
'AttributeName': 'year',
'KeyType': 'HASH'
},
{
'AttributeName': 'title',
'KeyType': 'RANGE'
}
],
AttributeDefinitions=[
{
'AttributeName': 'year',
'AttributeType': 'N'
},
{
'AttributeName': 'title',
'AttributeType': 'S'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
result = check_stuff('myprofile', 'some_table')
Aucun commentaire:
Enregistrer un commentaire