def test_call(): """Calling a command should result in an http request.""" s = SoapMessage( endpoint='http://endpoint.example.com', method='getData', parameters=[('one', '1')], http_headers={'user-agent': 'sonos'}, soap_action='ACTION', soap_header="<a_header>data</a_header>", namespace="http://namespace.com", other_arg=4) response = mock.MagicMock() response.headers = {} response.status_code = 200 response.content = DUMMY_VALID_RESPONSE with mock.patch('requests.post', return_value=response) as fake_post: result = s.call() assert XML.tostring(result) fake_post.assert_called_once_with( 'http://endpoint.example.com', headers={'SOAPACTION': '"ACTION"', 'Content-Type': 'text/xml; charset="utf-8"', 'user-agent': 'sonos'}, data=mock.ANY, other_arg=4)
def test_call(): """Calling a command should result in an http request.""" s = SoapMessage( endpoint="http://endpoint.example.com", method="getData", parameters=[("one", "1")], http_headers={"user-agent": "sonos"}, soap_action="ACTION", soap_header="<a_header>data</a_header>", namespace="http://namespace.com", other_arg=4, ) response = mock.MagicMock() response.headers = {} response.status_code = 200 response.content = DUMMY_VALID_RESPONSE with mock.patch("requests.post", return_value=response) as fake_post: result = s.call() assert XML.tostring(result) fake_post.assert_called_once_with( "http://endpoint.example.com", headers={ "SOAPACTION": '"ACTION"', "Content-Type": 'text/xml; charset="utf-8"', "user-agent": "sonos", }, data=mock.ANY, other_arg=4, )