Skip to content

Commit

Permalink
Merge pull request #99 from hassomehide/fix-create-mapping-response
Browse files Browse the repository at this point in the history
Change the return type of create_mapping from MappingResponse to Mapping
  • Loading branch information
oleg-nenashev committed Dec 12, 2023
2 parents 20442b2 + 3ebdd32 commit c304c06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions tests/test_resources/test_mapping/test_mapping_resource.py
Expand Up @@ -16,22 +16,24 @@
@pytest.mark.resource
@responses.activate
def test_create_mapping():
e = MappingResponse(body="test", status=200)
resp = e.get_json_data()
responses.add(
responses.POST, "http://localhost/__admin/mappings", json=resp, status=200
)

m = Mapping(
priority=1,
request=MappingRequest(url="test", method="GET"),
response=MappingResponse(status=200, body="test"),
)

e = Mapping(**m, id="1234-5678")
resp = e.get_json_data()
responses.add(
responses.POST, "http://localhost/__admin/mappings", json=resp, status=200
)

r = Mappings.create_mapping(m)
assert isinstance(r, MappingResponse)
assert r.status == 200
assert r.body == "test"
assert isinstance(r, Mapping)
assert r.id == "1234-5678"
assert r.priority == 1
assert r.request == m.request
assert r.response == m.response


@pytest.mark.unit
Expand Down
2 changes: 1 addition & 1 deletion wiremock/resources/mappings/resource.py
Expand Up @@ -30,7 +30,7 @@ def create_mapping(cls, mapping, parameters={}):
params=parameters,
)
response = cls.REST_CLIENT.handle_response(response)
return MappingResponse.from_dict(response.json())
return Mapping.from_dict(response.json())

@classmethod
def retrieve_all_mappings(cls, parameters={}):
Expand Down

0 comments on commit c304c06

Please sign in to comment.