|
2 | 2 |
|
3 | 3 | import pytest |
4 | 4 |
|
5 | | -from aignostics.gui._frame import get_status_page_url |
6 | 5 | from aignostics.platform import ( |
7 | 6 | API_ROOT_DEV, |
8 | 7 | API_ROOT_PRODUCTION, |
9 | 8 | API_ROOT_STAGING, |
10 | 9 | API_ROOT_TEST, |
| 10 | + STATUS_PAGE_URL_DEV, |
| 11 | + STATUS_PAGE_URL_PRODUCTION, |
| 12 | + STATUS_PAGE_URL_STAGING, |
| 13 | + STATUS_PAGE_URL_TEST, |
| 14 | + Settings, |
11 | 15 | ) |
12 | 16 |
|
13 | 17 |
|
14 | 18 | @pytest.mark.unit |
15 | | -def test_get_status_page_url_production(record_property) -> None: |
16 | | - """Test that production environment returns correct status page URL. |
| 19 | +def test_status_page_url_production(record_property) -> None: |
| 20 | + """Test that production environment has correct status page URL in settings. |
17 | 21 |
|
18 | 22 | Args: |
19 | 23 | record_property: pytest record_property fixture |
20 | 24 | """ |
21 | | - record_property("tested-item-id", "SPEC-GUI-FRAME") |
22 | | - url = get_status_page_url(API_ROOT_PRODUCTION) |
23 | | - assert url == "https://status.platform.aignostics.com" |
| 25 | + record_property("tested-item-id", "SPEC-PLATFORM-SETTINGS") |
| 26 | + settings = Settings(api_root=API_ROOT_PRODUCTION) |
| 27 | + assert settings.status_page_url == STATUS_PAGE_URL_PRODUCTION |
| 28 | + assert settings.status_page_url == "https://status.platform.aignostics.com" |
24 | 29 |
|
25 | 30 |
|
26 | 31 | @pytest.mark.unit |
27 | | -def test_get_status_page_url_staging(record_property) -> None: |
28 | | - """Test that staging environment returns correct status page URL. |
| 32 | +def test_status_page_url_staging(record_property) -> None: |
| 33 | + """Test that staging environment has correct status page URL in settings. |
29 | 34 |
|
30 | 35 | Args: |
31 | 36 | record_property: pytest record_property fixture |
32 | 37 | """ |
33 | | - record_property("tested-item-id", "SPEC-GUI-FRAME") |
34 | | - url = get_status_page_url(API_ROOT_STAGING) |
35 | | - assert url == "https://status.platform-staging.aignostics.com" |
| 38 | + record_property("tested-item-id", "SPEC-PLATFORM-SETTINGS") |
| 39 | + settings = Settings(api_root=API_ROOT_STAGING) |
| 40 | + assert settings.status_page_url == STATUS_PAGE_URL_STAGING |
| 41 | + assert settings.status_page_url == "https://status.platform-staging.aignostics.com" |
36 | 42 |
|
37 | 43 |
|
38 | 44 | @pytest.mark.unit |
39 | | -def test_get_status_page_url_dev(record_property) -> None: |
40 | | - """Test that dev environment returns None (no status page). |
| 45 | +def test_status_page_url_dev(record_property) -> None: |
| 46 | + """Test that dev environment has no status page URL in settings. |
41 | 47 |
|
42 | 48 | Args: |
43 | 49 | record_property: pytest record_property fixture |
44 | 50 | """ |
45 | | - record_property("tested-item-id", "SPEC-GUI-FRAME") |
46 | | - url = get_status_page_url(API_ROOT_DEV) |
47 | | - assert url is None |
| 51 | + record_property("tested-item-id", "SPEC-PLATFORM-SETTINGS") |
| 52 | + settings = Settings(api_root=API_ROOT_DEV) |
| 53 | + assert settings.status_page_url == STATUS_PAGE_URL_DEV |
| 54 | + assert settings.status_page_url is None |
48 | 55 |
|
49 | 56 |
|
50 | 57 | @pytest.mark.unit |
51 | | -def test_get_status_page_url_test(record_property) -> None: |
52 | | - """Test that test environment returns None (no status page). |
| 58 | +def test_status_page_url_test(record_property) -> None: |
| 59 | + """Test that test environment has no status page URL in settings. |
53 | 60 |
|
54 | 61 | Args: |
55 | 62 | record_property: pytest record_property fixture |
56 | 63 | """ |
57 | | - record_property("tested-item-id", "SPEC-GUI-FRAME") |
58 | | - url = get_status_page_url(API_ROOT_TEST) |
59 | | - assert url is None |
| 64 | + record_property("tested-item-id", "SPEC-PLATFORM-SETTINGS") |
| 65 | + settings = Settings(api_root=API_ROOT_TEST) |
| 66 | + assert settings.status_page_url == STATUS_PAGE_URL_TEST |
| 67 | + assert settings.status_page_url is None |
60 | 68 |
|
61 | 69 |
|
62 | 70 | @pytest.mark.unit |
63 | | -def test_get_status_page_url_unknown(record_property) -> None: |
64 | | - """Test that unknown environment returns None (no status page). |
| 71 | +def test_status_page_url_configurable(record_property, monkeypatch) -> None: |
| 72 | + """Test that status page URL can be explicitly configured via settings. |
65 | 73 |
|
66 | 74 | Args: |
67 | 75 | record_property: pytest record_property fixture |
| 76 | + monkeypatch: pytest monkeypatch fixture |
68 | 77 | """ |
69 | | - record_property("tested-item-id", "SPEC-GUI-FRAME") |
70 | | - url = get_status_page_url("https://custom.example.com") |
71 | | - assert url is None |
| 78 | + record_property("tested-item-id", "SPEC-PLATFORM-SETTINGS") |
| 79 | + # Test that we can override the status page URL |
| 80 | + custom_url = "https://custom-status.example.com" |
| 81 | + monkeypatch.setenv("AIGNOSTICS_STATUS_PAGE_URL", custom_url) |
| 82 | + settings = Settings(api_root=API_ROOT_PRODUCTION) |
| 83 | + assert settings.status_page_url == custom_url |
| 84 | + |
0 commit comments