コード例 #1
0
def test_xml_payload(mock_server):
    # Given
    imposter = Imposter(
        Stub(
            Predicate(xpath="//foo", body="bar", operator=Predicate.Operator.EQUALS),
            Response(body="sausages"),
        )
    )

    with mock_server(imposter):
        # When
        r1 = requests.get(imposter.url, data=et2string(data2xml({"foo": "bar"})))
        r2 = requests.get(imposter.url, data=et2string(data2xml({"foo": "baz"})))

        # Then
        assert_that(r1, is_response().with_body("sausages"))
        assert_that(r2, is_response().with_body(not_("sausages")))
コード例 #2
0
def test_xml_response(mock_server):
    # Given
    imposter = Imposter(Stub(Predicate(), Response(body=data2xml({"foo": {"bar": "baz"}}))))

    with mock_server(imposter):
        # When
        r = requests.get(imposter.url)

        # Then
        assert_that(r, is_response().with_body("<foo><bar>baz</bar></foo>"))
コード例 #3
0
ファイル: test_copy.py プロジェクト: ozonru/mbtest
        assert_that(response,
                    is_response().with_body("Have you read Game of Thrones?"))


BOOKS_XML = et2string(
    data2xml({
        "books": [
            {
                "book": {
                    "title": "Game of Thrones",
                    "summary": "Dragons and political intrigue"
                }
            },
            {
                "book": {
                    "title": "Harry Potter",
                    "summary": "Dragons and a boy wizard"
                }
            },
            {
                "book": {
                    "title": "The Hobbit",
                    "summary": "A dragon and short people"
                }
            },
        ]
    }))
BOOKS_XML_NAMESPACED = et2string(
    data2xml(
        {
            "books": [
                {