def test_retrieve_page_params_non_post(self, mock_make_request): """ Test that non-POST post params get set as a query string """ path = "http://google.com" post_params = {"key1": "val1"} expected_uri = "?".join((path, urllib.urlencode(post_params))) mock_http_response = MagicMock() mock_http_response.status = 200 mock_http_response['set-cookie'] = "" mock_make_request.return_value = mock_http_response fw = Framework() fw.retrieve_page("GET", path, post_params=post_params) mock_make_request.asserted_called_with(expected_uri, method="GET", body=None, headers=None)
def test_retrieve_page_basic_auth(self, mock_make_request): """ Test that a basic auth request generates the correct header """ path = "http://google.com" username, password = "******", "pass" auth_str = base64.b64encode(":".join((username, password))) expected_uri = path expected_headers = {"Authorization": "Basic %s" % auth_str} mock_http_response = MagicMock() mock_http_response.status = 200 mock_make_request.return_value = mock_http_response fw = Framework() fw.retrieve_page("GET", path, username=username, password=password) mock_make_request.asserted_called_with(expected_uri, method="GET", body=None, headers=expected_headers)