Download tests/unit/shared/test_ip_utils.py from paisaly/backend: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/paisaly/backend/resolve/main/tests/unit/shared/test_ip_utils.py
- Command line
-
hf download hf://spaces/paisaly/backend/tests/unit/shared/test_ip_utils.py
-
curl -L -o test_ip_utils.py https://huggingface.co/spaces/paisaly/backend/resolve/main/tests/unit/shared/test_ip_utils.py
1.35 kB
| from __future__ import annotations | |
| from unittest.mock import MagicMock | |
| import pytest | |
| from app.shared.ip_utils import get_client_ip | |
| from .conftest import _make_request | |
| # --------------------------------------------------------------------------- | |
| # shared.ip_utils — get_client_ip | |
| # --------------------------------------------------------------------------- | |
| def test_get_client_ip(headers, client_host, expected_ip): | |
| assert get_client_ip(_make_request(headers, client_host)) == expected_ip | |
| def test_get_client_ip_no_client_returns_empty(): | |
| req = MagicMock() | |
| req.headers = {} | |
| req.client = None | |
| assert get_client_ip(req) == "" | |