Skip to content

support of multipart patterns #113

Description

@FabienArcellier

Proposal

Hi, thanks for your great work.

I have a problem to mock multipart pattern. It seems not supported on python sdk. Is there a way to use it ?

Proposition of implementation

Here is a simple way I make it work as I expect changing the source code of python-wiremock

Usage

request = MappingRequest(
    method="POST",
    url="/api/archive/upload",
    multipart_patterns=[
        {
            "name": "table",
            "headers": {"Content-Disposition": {"matches": "form-data; name=\"table\""}},
            "bodyPatterns": [{"matches": "dt"}]
        }
    ]
)

Change

resources/mappings/models.py

@add_metaclass(BaseEntityMetaType)
class MappingRequest(BaseAbstractEntity):
    method = JsonProperty("method")
    url = JsonProperty("url")
    url_path = JsonProperty("urlPath")
    url_path_pattern = JsonProperty("urlPathPattern")
    url_pattern = JsonProperty("urlPattern")
    basic_auth_credentials = JsonProperty(
        "basicAuthCredentials", klass=BasicAuthCredentials
    )
    cookies = JsonProperty("cookies", klass=dict)
    headers = JsonProperty("headers", klass=dict)
    query_parameters = JsonProperty("queryParameters", klass=dict)
    body_patterns = JsonProperty("bodyPatterns", klass=list, list_klass=dict)
    metadata = JsonProperty("metadata", klass=dict)
    multipart_patterns = JsonProperty("multipartPatterns", klass=dict)

References

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions