forked from meraki/dashboard-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_response_handler.py
More file actions
27 lines (19 loc) · 992 Bytes
/
Copy pathtest_response_handler.py
File metadata and controls
27 lines (19 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from unittest.mock import MagicMock
from meraki.response_handler import handle_3xx
class TestHandle3xx:
def test_extracts_location_and_updates_base_url(self):
session = MagicMock()
session._base_url = "https://api.meraki.com/api/v1"
response = MagicMock()
response.headers = {"Location": "https://n123.meraki.com/api/v1/organizations"}
result = handle_3xx(session, response)
assert result == "https://n123.meraki.com/api/v1/organizations"
assert session._base_url == "https://n123.meraki.com/api/v1"
def test_handles_china_domain(self):
session = MagicMock()
session._base_url = "https://api.meraki.cn/api/v1"
response = MagicMock()
response.headers = {"Location": "https://n456.meraki.cn/api/v1/networks"}
result = handle_3xx(session, response)
assert result == "https://n456.meraki.cn/api/v1/networks"
assert session._base_url == "https://n456.meraki.cn/api/v1"