-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't check certificate in meteoview
- Loading branch information
Showing
3 changed files
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,6 +209,7 @@ def test_logs_on(self): | |
"data": json.dumps( | ||
{"email": "[email protected]", "key": "topsecret"} | ||
), | ||
"verify": False, | ||
}, | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
from unittest import TestCase | ||
from unittest.mock import MagicMock, patch | ||
|
||
import requests | ||
from freezegun import freeze_time | ||
from requests import Timeout | ||
|
||
from enhydris.models import Timeseries | ||
from enhydris.telemetry import TelemetryError | ||
|
@@ -55,7 +55,7 @@ def setUp(self): | |
@patch("enhydris.telemetry.types.meteoview2.requests.request") | ||
class MakeRequestTestCase(TelemetryAPIClientTestCaseBase): | ||
def test_raises_on_bad_status_code(self, mock_request): | ||
mock_request.return_value.raise_for_status.side_effect = Timeout | ||
mock_request.return_value.raise_for_status.side_effect = requests.Timeout | ||
with self.assertRaises(TelemetryError): | ||
self.telemetry_api_client.make_request("GET", "/") | ||
|
||
|
@@ -69,6 +69,11 @@ def test_raises_when_code_is_not_200(self, mock_request): | |
with self.assertRaises(TelemetryError): | ||
self.telemetry_api_client.make_request("GET", "/") | ||
|
||
def test_raises_on_ssl_error(self, mock_request): | ||
mock_request.side_effect = requests.exceptions.SSLError | ||
with self.assertRaises(TelemetryError): | ||
self.telemetry_api_client.make_request("GET", "/") | ||
|
||
def test_ok_when_code_is_200(self, mock_request): | ||
mock_request.return_value.json.return_value = {"code": "200"} | ||
self.assertEqual( | ||
|
@@ -88,6 +93,7 @@ def test_makes_request(self, mock_request): | |
data=json.dumps( | ||
{"email": "[email protected]", "key": "topsecretapikey"} | ||
), | ||
verify=False, | ||
) | ||
|
||
def test_sets_token(self, mock_request): | ||
|
@@ -117,6 +123,7 @@ def test_makes_request(self, mock_request): | |
"POST", | ||
"https://meteoview2.gr/api/stations", | ||
headers={"Authorization": "Bearer topsecretapitoken"}, | ||
verify=False, | ||
) | ||
|
||
def test_returns_stations(self, mock_request): | ||
|
@@ -149,6 +156,7 @@ def test_makes_request(self, mock_request): | |
"Authorization": "Bearer topsecretapitoken", | ||
}, | ||
data=json.dumps({"station_code": 823}), | ||
verify=False, | ||
) | ||
|
||
def test_returns_sensors(self, mock_request): | ||
|
@@ -213,6 +221,7 @@ def test_ignores_timezone(self, mock_request): | |
"dateto": "2022-12-11", | ||
} | ||
), | ||
"verify": False, | ||
}, | ||
) | ||
|
||
|
@@ -249,6 +258,7 @@ def test_makes_request(self, mock_request): | |
"dateto": "2022-12-11", | ||
} | ||
), | ||
verify=False, | ||
) | ||
|
||
def test_return_value(self, mock_request): | ||
|
@@ -284,6 +294,7 @@ def test_request_when_no_start_date(self, mock_request): | |
"dateto": "1990-06-30", | ||
} | ||
), | ||
verify=False, | ||
) | ||
|
||
def _set_successful_request_result(self, mock_request): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters