-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_multi_tenant_api_routing.py
More file actions
46 lines (42 loc) · 1.07 KB
/
test_multi_tenant_api_routing.py
File metadata and controls
46 lines (42 loc) · 1.07 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from uuid import UUID
import pytest
from pyoaev import OpenAEV
@pytest.mark.parametrize(
"tenant_id, path, expected",
[
(
None,
"/path",
"base_url/api/path",
),
(
UUID("2cffad3a-0001-4078-b0e2-ef74274022c3"),
"/path",
"base_url/api/tenants/2cffad3a-0001-4078-b0e2-ef74274022c3/path",
),
(
None,
"https://external.service/api/path",
"https://external.service/api/path",
),
(
UUID("2cffad3a-0001-4078-b0e2-ef74274022c3"),
"https://external.service/api/path",
"https://external.service/api/path",
),
],
ids=[
"legacy-relative-path",
"tenant-relative-path",
"legacy-full-url-bypass",
"tenant-full-url-bypass",
],
)
def test_build_url_behavior(tenant_id, path, expected):
client = OpenAEV(
"base_url",
"token",
tenant_id=tenant_id,
)
result = client._build_url(path)
assert result == expected