Skip to content
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

Added a request list to remember_called decorator #54

Merged
merged 1 commit into from Jan 28, 2019

Conversation

jsenin
Copy link

@jsenin jsenin commented Mar 19, 2018

I need to assert the payload sent to an external host, so I added the request list in order to ensure my data was properly formed.

The scenario it's a functional tests with no integration servers. I need to test a call to an api, although it's my code I consider it as a blackbox. this blackbox must to do a call to another api so I have not direct way to validate the third call. Using the request history I can validate the call. Something like this:

def test_store_several_requests(self):
    with HTTMock(google_mock_store_requests):
        payload = {"query": "foo"}
        requests.post('http://google.com', data=payload)

    self.assertTrue(google_mock_store_requests.call['called'])
    self.assertEqual(google_mock_store_requests.call['count'], 1)
    request = google_mock_store_requests.call['requests'][0]
    self.assertEqual(request.body, 'query=foo')

@jsenin jsenin force-pushed the master branch 2 times, most recently from 05d8ad8 to 15aa8ca Compare March 19, 2018 13:27
@jsenin
Copy link
Author

jsenin commented Jan 28, 2019

@patrys could you consider my pull request ?
thanks

@patrys patrys merged commit 90899be into patrys:master Jan 28, 2019
@patrys
Copy link
Owner

patrys commented Jan 28, 2019

Yes, sorry for the long wait.

@jsenin
Copy link
Author

jsenin commented Jan 28, 2019 via email

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

Successfully merging this pull request may close these issues.

None yet

2 participants