小编Ale*_*dze的帖子

使用 moto 和 boto3 上传测试文件

我想对从 aws 导入的文件进行测试。我使用 moto 模拟 s3,以免弄乱实际数据。然而,现在 aws 似乎是空的,因此我决定在模拟的 s3 上上传一些测试文件。我怎样才能这样做呢?

这是我的设置,
Conftest.py:

@pytest.fixture(scope='function')
def aws_credentials():
    """Mocked AWS Credentials for moto."""
    os.environ['AWS_ACCESS_KEY_ID'] = 'testing'
    os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing'
    os.environ['AWS_SECURITY_TOKEN'] = 'testing'
    os.environ['AWS_SESSION_TOKEN'] = 'testing'


@pytest.fixture(scope='function')
def s3(aws_credentials):
    with mock_s3():
        yield boto3.client('s3', region_name='us-east-1')
Run Code Online (Sandbox Code Playgroud)

测试文件:

class TestLoadRecommendations:

    @pytest.fixture(autouse=True)
    def _setup(self, s3):
        self.bucket = s3.create_bucket(Bucket=settings.SERVER_DATA_S3_BUCKET)
        self.bucket.upload_file("tmp/recommendations-2021-04-13T17_28_06.csv", "tmp/recommendations-2021-04-13T17_28_06.csv")
Run Code Online (Sandbox Code Playgroud)

但是,上传它会引发错误TypeError: expected string or bytes-like object,但我确信我使用了错误的命令来上传文件。有人可以帮忙吗?谢谢!

django amazon-web-services pytest boto3 moto

6
推荐指数
1
解决办法
1万
查看次数

Flex 框在悬停时移动

每当我将鼠标悬停在文本上时,我都希望它有一个底部边框。但是,我也让我的文字向上移动。也许有什么建议?图像之前是不正确的位置和图像之后被提升一个位。我知道你不能从截图中看到它。但是,我不知道如何上传视频。

.pages {
  width: 370px;
  font-family: 'Heebo', sans-serif;
  font-size: 18.5px;
  display: inline-flex;
  flex-direction: row;
  margin: auto 0px auto 0px;
  justify-content: space-between;
  padding: 0px 24px 22px 0px;
}

.pages :hover {
  cursor: pointer;
  border-bottom: 1px solid black;
  padding-bottom: 1px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="pages">
  <a id="Gallery">Gallery Walls</a>
  <a id="Contact">Contact</a>
  <i class="fab fa-instagram" id="icon"></i>
  <i class="fas fa-store" id="icon"></i>
</div>
Run Code Online (Sandbox Code Playgroud)

html css flexbox

3
推荐指数
1
解决办法
520
查看次数

标签 统计

amazon-web-services ×1

boto3 ×1

css ×1

django ×1

flexbox ×1

html ×1

moto ×1

pytest ×1