def test_post_insecure_request(self, disable_warnings, post_request, create_session): library = APILibrary() library.suppress_insecure_request_warnings() library.call_post_request({"a": "Text"}, "Endpoint", "fullstring") disable_warnings.assert_called() post_request.assert_called_with('postapi', 'fullstring', None, files=None, timeout=None) create_session.assert_called_with("postapi", "Endpoint", {"a": "Text"}, cookies=None, timeout=None)
def test_basic_post(self, create_session, post_request): library = APILibrary() r = library.call_post_request({"a": "Text"}, "Endpoint", "fullstring") type(r).text = PropertyMock(return_value="success") type(r).status_code = PropertyMock(return_value=200) assert r.text == "success" assert r.status_code == 200
def test_post_with_cookies(self, post_request, create_session): library = APILibrary() r = library.call_post_request({"a": "Text"}, "Endpoint", "fullstring", None, "chocolate_chip") type(r).text = PropertyMock(return_value="success") type(r).status_code = PropertyMock(return_value=200) type(r).cookies = PropertyMock( return_value={"chocolate_chip": "tasty"}) assert r.text == "success" assert r.status_code == 200 assert r.cookies["chocolate_chip"] == "tasty"
def test_basic_post(self, create_session, post_request): library = APILibrary() r = library.call_post_request({"a": "Text"}, "Endpoint", "fullstring") type(r).text = PropertyMock(return_value="success") type(r).status_code = PropertyMock(return_value=200) assert r.text == "success" assert r.status_code == 200 create_session.assert_called_with('postapi', 'fullstring', None, files=None, timeout=None) post_request.assert_called_with("postapi", "Endpoint", {"a": "Text"}, cookies=None, timeout=None)
def test_files_post(self, post_on_session, create_session): library = APILibrary() r = library.call_post_request({"a": "Text"}, "Endpoint", "fullstring", b'item') type(r).text = PropertyMock(return_value="success") type(r).status_code = PropertyMock(return_value=200) assert r.text == "success" assert r.status_code == 200 post_on_session.assert_called_with('postapi', 'fullstring', b'item', files=None, timeout=None, expected_status='any') create_session.assert_called_with("postapi", "Endpoint", {"a": "Text"}, cookies=None, timeout=None)
def test_post_with_cookies(self, post_request, create_session): library = APILibrary() r = library.call_post_request({"a": "Text"}, "Endpoint", "fullstring", None, "chocolate_chip") type(r).text = PropertyMock(return_value="success") type(r).status_code = PropertyMock(return_value=200) type(r).cookies = PropertyMock( return_value={"chocolate_chip": "tasty"}) assert r.text == "success" assert r.status_code == 200 assert r.cookies["chocolate_chip"] == "tasty" post_request.assert_called_with('postapi', 'fullstring', None, files='chocolate_chip', timeout=None) create_session.assert_called_with("postapi", "Endpoint", {"a": "Text"}, cookies=None, timeout=None)
def test_post_insecure_request(self, disable_warnings, post_request, create_session): library = APILibrary() library.suppress_insecure_request_warnings() r = library.call_post_request({"a": "Text"}, "Endpoint", "fullstring") disable_warnings.assert_called()