diff --git a/_sources/lectures/TWP45/TWP45_4.rst b/_sources/lectures/TWP45/TWP45_4.rst index 802d93244e..7d71ed281b 100644 --- a/_sources/lectures/TWP45/TWP45_4.rst +++ b/_sources/lectures/TWP45/TWP45_4.rst @@ -16,7 +16,7 @@ contiene dominios, nombres y países de la mayoría de las universidades del mu import urllib.parse import json - api_url = "https://cors.bridged.cc/http://universities.hipolabs.com/search?" + api_url = "http://universities.hipolabs.com/search?" parametros = urllib.parse.urlencode({"name": "middle", "country": "turkey"}) solicitud = urllib.request.urlopen(api_url + parametros) @@ -35,7 +35,7 @@ contiene dominios, nombres y países de la mayoría de las universidades del mu import requests import json - api_url = "https://cors.bridged.cc/http://universities.hipolabs.com/search" + api_url = "http://universities.hipolabs.com/search" parametros = {"country": "colombia"} solicitud = requests.get(api_url, params=parametros) diff --git a/_sources/lectures/TWP45/TWP45_4_en.rst b/_sources/lectures/TWP45/TWP45_4_en.rst index 437ed88053..a440798239 100644 --- a/_sources/lectures/TWP45/TWP45_4_en.rst +++ b/_sources/lectures/TWP45/TWP45_4_en.rst @@ -16,7 +16,7 @@ domains, names, and countries of most universities around the world. import urllib.parse import json - api_url = "https://cors.bridged.cc/http://universities.hipolabs.com/search?" + api_url = "http://universities.hipolabs.com/search?" params = urllib.parse.urlencode({"name": "middle", "country": "turkey"}) request = urllib.request.urlopen(api_url + params) @@ -35,7 +35,7 @@ domains, names, and countries of most universities around the world. import requests import json - api_url = "https://cors.bridged.cc/http://universities.hipolabs.com/search" + api_url = "http://universities.hipolabs.com/search" params = {"country": "colombia"} request = requests.get(api_url, params=params) diff --git a/tests/test_TWP45.py b/tests/test_TWP45.py index 2f0a8ed1f0..9339251785 100644 --- a/tests/test_TWP45.py +++ b/tests/test_TWP45.py @@ -119,3 +119,28 @@ def test_l45_3_en(page): page.hover("#ac_l45_3c_en >> text=You passed:") assert page.inner_text( "#ac_l45_3c_en >> text=You passed:") == "You passed: 100.0% of the tests" + + +def test_l45_4_api_1(): + """Tests fetching data from the provided URL""" + # Send a GET request to the URL for a sample user + url = "http://universities.hipolabs.com/search?name=middle&country=turkey" + + # Send a GET request to the URL + response = requests.get(url) + + # Check for successful response (status code 200) + assert response.status_code == 200, f"Expected status code 200, but got {response.status_code}, Data can not be fetched from the provided URL" + + +def test_l45_4_api_2(): + """Tests fetching data from the provided URL""" + # Send a GET request to the URL for a sample user + url = "http://universities.hipolabs.com/search?country=colombia" + + # Send a GET request to the URL + response = requests.get(url) + + # Check for successful response (status code 200) + assert response.status_code == 200, f"Expected status code 200, but got {response.status_code}, Data can not be fetched from the provided URL" +