Skip to content

Updating a request deletes the newest entry from the request list #68

@sjaensch

Description

@sjaensch

Unfortunately, #67 doesn't work correctly after all. This small change to the test illustrates the issue:

diff --git a/tests/tests35/test_http_aiohttp.py b/tests/tests35/test_http_aiohttp.py
index 0edc396..2fe1557 100644
--- a/tests/tests35/test_http_aiohttp.py
+++ b/tests/tests35/test_http_aiohttp.py
@@ -29,6 +29,7 @@ class AioHttpEntryTestCase(TestCase):
                     async with session.post(url, data=body * 6) as post_response:
                         assert post_response.status == 201
                         assert await post_response.text() == body * 2
+                        assert Mocket.last_request().method == 'POST'
                         assert Mocket.last_request().body == body * 6

         loop = asyncio.get_event_loop()

The problem is that once the body data gets collected, the call to can_handle() causes the last request to be removed from the list and the body to be appended to the request before the last:
https://github.com/mindflayer/python-mocket/blob/master/mocket/mockhttp.py#L137

The assertion above just illustrates that Mocket.last_request() is actually the first one (the GET request) and not the POST request that was done afterwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions