1

使用它时 pytest.fixtures 和 mock_cognitoidp

@pytest.fixture(scope="function") def cognito(aws_credentials): import moto with moto.mock_cognitoidp(): yield boto3.client('cognito-idp', region_name='us-east-1')
def test_cognito(cognito): client_name = str(uuid.uuid4()) value = str(uuid.uuid4) user_pool_id = cognito.create_user_pool(PoolName=str(uuid.uuid4()))["UserPool"]["Id"] user_pool_client_id = cognito.create_user_pool_client( UserPoolId=user_pool_id, ClientName=client_name, CallbackURLs=[value] )['UserPoolClient']['ClientId'] Username=str(uuid.uuid4()) UserAttributes=[ {"Name":"full_name", 'Value':"Satej Sarker"} ] obj={ "ClientId": user_pool_client_id, "Username":Username, "Password":'satejsarker' } user=cognito.sign_up(ClientId=user_pool_client_id, Username=username, Password="abc1234"

它给了我错误,例如 sign_up 尚未实现,但可以完美地与其他模块一起使用。并且还在真实的aws环境中使用此代码

4

1 回答 1

0

此方法未在 moto 库中实现。

是相同的开放 github 问题。

它在实时 aws 中工作,因为在这种情况下它不使用 moto。

于 2020-06-23T04:05:21.390 回答