def test_session(self): """http.get: The function should accept a requests.Session object used to manage the http session and use it when sending requests. """ expected = 'success' session = Session() url1 = f'{self.fqdn}:{self.port}/cookie_set' url2 = f'{self.fqdn}:{self.port}/cookie_check' _ = http.get(url1, session) actual = http.get(url2, session) self.assertEqual(expected, actual)
def test_404(self): """http_get: The function raises an http.NotFoundError exception if the status code from the server was 404. """ expected = http.NotFoundError url = f'{self.fqdn}:{self.port}/404' with self.assertRaises(expected): resp = http.get(url)
def test_500(self): """http.get: The function raises an http.ServerError exception if the status code from the server was in the 5xx range. """ expected = http.ServerError url = f'{self.fqdn}:{self.port}/500' with self.assertRaises(expected): resp = http.get(url)
def test_200(self): """http.get: The function should make an HTTP GET request to the given URL, and return the text in the body of the HTTP response. """ expected = 'success' url = f'{self.fqdn}:{self.port}/get' actual = http.get(url) self.assertEqual(expected, actual)
def _get_members_details(): resp = http.get(URL) return common.parse_json(resp)