markdown moto片段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown moto片段相关的知识,希望对你有一定的参考价值。

# moto snippet
いつもmotoの使い方がわからなくなるのでメモ.  
botoのmockライブラリなので、基本的な使い方なmockオブジェクトを作るところから始まる

[基本的な使い方](https://github.com/spulec/moto/blob/master/tests/)

## s3にobjectをput
```
import boto3
from moto import mock_s3
import hogehoge

# botoを使ってs3にオブジェクトをアップするメソッドの
# handler.store_license_info()のテスト
@mock_s3
def test_put_object():
    client = boto3.resource('s3')
    client.create_bucket(Bucket="dummy-bucket")
    hogehoge.put_object(client, "path/to/file", "dummy-data")

```

## sesでメール送付
```
from moto import mock_ses
import boto3
improt hogehoge

@mock_ses
def test_メールアドレスが設定されている場合は正常終了():
    ses = boto3.client('ses', region_name='us-east-1')
    ses.verify_email_identity(EmailAddress='no-reply-dummy@mail.example.com')
    result = hogehoge.send_email(destination_address="test_to@example.com")
    assert result["MessageId"]
    assert result["ResponseMetadata"]["HTTPStatusCode"] == 200

```

以上是关于markdown moto片段的主要内容,如果未能解决你的问题,请参考以下文章

VS Code配置markdown代码片段

markdown 正则表达式模式片段

markdown 前端片段

markdown 活动片段

markdown 一堆Git的基本片段

markdown graphql片段