bots: tests: Move http mock to context manager.
This commit decouples the http mock conversation feature from assert_bot_response(), and moves it to the context manager mock_http_conversation(). This allows a modular design with context managers that could be added for assert_bot_response().
This commit is contained in:
		
							parent
							
								
									a9bb0c9417
								
							
						
					
					
						commit
						01c363317e
					
				
					 2 changed files with 32 additions and 38 deletions
				
			
		|  | @ -51,10 +51,10 @@ class TestGiphyBot(BotTestCase): | |||
|         # This message calls `send_reply` function of BotHandlerApi | ||||
|         keyword = "Hello" | ||||
|         gif_url = "https://media4.giphy.com/media/3o6ZtpxSZbQRRnwCKQ/giphy.gif" | ||||
|         self.assert_bot_response( | ||||
|             message = {'content': keyword}, | ||||
|             response = {'content': get_bot_response(gif_url)}, | ||||
|             expected_method='send_reply', | ||||
|             http_request=get_http_request(keyword), | ||||
|             http_response=get_http_response_json(gif_url) | ||||
|         ) | ||||
|         with self.mock_http_conversation(get_http_request(keyword), | ||||
|                                          get_http_response_json(gif_url)): | ||||
|             self.assert_bot_response( | ||||
|                 message = {'content': keyword}, | ||||
|                 response = {'content': get_bot_response(gif_url)}, | ||||
|                 expected_method='send_reply' | ||||
|             ) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Robert Hönig
						Robert Hönig