标签: pact-python

实际交互与模拟 MockService 的预期交互不匹配

我是 python 和合同测试的新手。我正在尝试使用pact-python.

这是测试文件 test_posts_controller.py

import unittest
import atexit
from pact import Consumer, Provider, Term
import requests

pact = Consumer('Consumer').has_pact_with(Provider('Provider'))
pact.start_service()
atexit.register(pact.stop_service)

class GetPostsContract(unittest.TestCase):
    def test_get_all_posts(self):
        expected = {
            "userId": 1,
            "id": 1,
            "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
            "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
        }

        (pact
            .given('posts exist')
            .upon_receiving('a request for post by id')
            .with_request('GET', '/posts/1')
            .will_respond_with(200, body=expected)) …
Run Code Online (Sandbox Code Playgroud)

python-3.x pact pact-python

0
推荐指数
1
解决办法
2898
查看次数

标签 统计

pact ×1

pact-python ×1

python-3.x ×1