Skip to content

support of multipart patterns #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
FabienArcellier opened this issue Feb 21, 2025 · 0 comments
Open

support of multipart patterns #113

FabienArcellier opened this issue Feb 21, 2025 · 0 comments

Comments

@FabienArcellier
Copy link

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

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

No branches or pull requests

1 participant