Send generated values in test as parameters to fixture in pytest

。 测试交流评论78字数 1359阅读模式
摘要Let me give you and idea of what the test is about. In this test, I'm calling an API that ...

Let me give you and idea of what the test is about.
In this test, I'm calling an API that basically generates a file and an item in a DynamoDB table. The response the service, gives me the UUID that I use to look into the DB and check that everything is created correctly.
However, I cannot do the teardown in fixture because the uuid I need to delete item in dynamo is generated in the test. Right now, I'm deleting the item in the test but I wanted to do it in the fixture but I'm not sure if its possible to pass this uuid to the fixture.
Any suggestions or ideas?

@pytest.fixture
def prepare_test(self):
    body = open(self._filepath, "r")
    yield body
def test_post_template_tyc_happy_path(self, prepare_test):
    body = prepare_test
    response_body = self._tyc_api.post_template_contract(body.read(), header, 'LOAN', 'GOBIERNO', 'AUTOMATED_QA_TEST')
    result_dynamo = self._tyc_crud.find_contract_by_product_id_and_tac_version_id_async(response_body['productId'], response_body['tacVersionId'])
    assert response_body['productId'] == 'LOAN'
    assert response_body['tacVersionId'][:-36] == 'GOBIERNO#'
    assert response_body['description'] == 'AUTOMATED_QA_TEST'
    assert response_body['isLastVersion'] is True
    assert result_dynamo.description == 'AUTOMATED_QA_TEST'
    assert result_dynamo.tac_id == 'GOBIERNO'
    self.delete_test_data(response_body['productId'], response_body['tacVersionId'])
def delete_test_data(self, product_id, tac_version_id):
    self._tyc_crud.delete_contract_by_product_id_and_tac_version_id(product_id, tac_version_id)

Thanks!文章源自玩技e族-https://www.playezu.com/179287.html 文章源自玩技e族-https://www.playezu.com/179287.html

玩技站长微信
添加好友自动发送入群邀请
weinxin
rainbow-shownow
玩技官方公众号
官方微信公众号
weinxin
PLAYEZU
 
  • 版权提示:本站仅供存储任何法律责任由作者承担▷诈骗举报◁▷新闻不符◁▷我要投稿◁
    风险通知:非原创文章均为网络投稿真实性无法判断,侵权联系2523030730
    免责声明:内容来自用户上传发布或新闻客户端自媒体,切勿!切勿!切勿!添加联系方式以免受骗。
  • 原创转载:https://www.playezu.com/179287.html
    转载说明: 点我前往阅读>>>
匿名

发表评论

匿名网友
确定