python-jejakmasjid 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/PKG-INFO +1 -1
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/pyproject.toml +1 -1
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/client.py +6 -7
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/constants.py +7 -5
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/PKG-INFO +1 -1
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/tests/test_client.py +6 -6
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/LICENSE +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/README.md +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/setup.cfg +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/__init__.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/__main__.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/cli.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/exceptions.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/geo.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/jejakmasjid/models.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/SOURCES.txt +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/dependency_links.txt +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/entry_points.txt +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/requires.txt +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/top_level.txt +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/tests/test_auth.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/tests/test_cli.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/tests/test_geo.py +0 -0
- {python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/tests/test_models.py +0 -0
|
@@ -172,8 +172,8 @@ async def async_fetch_nearby(
|
|
|
172
172
|
|
|
173
173
|
timeout = aiohttp.ClientTimeout(total=timeout_seconds)
|
|
174
174
|
|
|
175
|
-
# 1. Attempt primary
|
|
176
|
-
params = {"lat": f"{lat:.
|
|
175
|
+
# 1. Attempt primary endpoint (original map nearby API)
|
|
176
|
+
params = {"lat": f"{lat:.3f}", "lng": f"{lon:.3f}", "radius": str(radius_km)}
|
|
177
177
|
try:
|
|
178
178
|
async with session.get(primary_url, params=params, headers=req_headers, timeout=timeout) as resp:
|
|
179
179
|
if resp.status == 200:
|
|
@@ -181,17 +181,16 @@ async def async_fetch_nearby(
|
|
|
181
181
|
return parse_places(payload, origin_lat=lat, origin_lon=lon)
|
|
182
182
|
if resp.status != 404 or endpoint_url:
|
|
183
183
|
raise JejakMasjidError(f"Jejak Masjid answered HTTP {resp.status}")
|
|
184
|
-
_LOGGER.warning("
|
|
184
|
+
_LOGGER.warning("Primary endpoint returned 404, falling back to secondary endpoint")
|
|
185
185
|
except (aiohttp.ClientError, TimeoutError, ValueError) as err:
|
|
186
186
|
if endpoint_url:
|
|
187
187
|
raise JejakMasjidError(f"Cannot reach Jejak Masjid: {err}") from err
|
|
188
|
-
_LOGGER.warning("
|
|
188
|
+
_LOGGER.warning("Primary endpoint failed (%s), falling back to secondary endpoint", err)
|
|
189
189
|
|
|
190
|
-
# 2. Fallback to
|
|
191
|
-
fallback_params = {"lat": f"{lat:.3f}", "lng": f"{lon:.3f}", "radius": str(radius_km)}
|
|
190
|
+
# 2. Fallback to secondary endpoint if primary returned 404 or connection failed
|
|
192
191
|
try:
|
|
193
192
|
async with session.get(
|
|
194
|
-
FALLBACK_NEARBY_URL, params=
|
|
193
|
+
FALLBACK_NEARBY_URL, params=params, headers=req_headers, timeout=timeout
|
|
195
194
|
) as resp:
|
|
196
195
|
if resp.status != 200:
|
|
197
196
|
raise JejakMasjidError(f"Jejak Masjid fallback answered HTTP {resp.status}")
|
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
API_BASE = "https://apiv2.jejakmasjid.my"
|
|
5
|
+
MAP_NEARBY_PATH = "/api/map/nearby"
|
|
5
6
|
HA_V1_NEARBY_PATH = "/api/ha/v1/masjids/nearby"
|
|
6
|
-
LEGACY_NEARBY_PATH =
|
|
7
|
-
NEARBY_PATH =
|
|
7
|
+
LEGACY_NEARBY_PATH = MAP_NEARBY_PATH
|
|
8
|
+
NEARBY_PATH = MAP_NEARBY_PATH
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
# Original map nearby is primary; HA v1 is ready as fallback/future
|
|
11
|
+
PRIMARY_NEARBY_URL = f"{API_BASE}{MAP_NEARBY_PATH}"
|
|
12
|
+
FALLBACK_NEARBY_URL = f"{API_BASE}{HA_V1_NEARBY_PATH}"
|
|
11
13
|
NEARBY_URL = PRIMARY_NEARBY_URL
|
|
12
14
|
HEALTH_URL = f"{API_BASE}/"
|
|
13
15
|
|
|
14
16
|
DEFAULT_TIMEOUT_SECONDS = 20
|
|
15
|
-
DEFAULT_USER_AGENT = "python-jejakmasjid/0.3.
|
|
17
|
+
DEFAULT_USER_AGENT = "python-jejakmasjid/0.3.1 (+https://github.com/zubirjamal/python-jejakmasjid)"
|
|
16
18
|
|
|
17
19
|
AUTH_SEND_OTP_PATH = "/api/auth/email-otp/send-verification-otp"
|
|
18
20
|
AUTH_VERIFY_OTP_PATH = "/api/auth/sign-in/email-otp"
|
|
@@ -95,14 +95,14 @@ def test_parse_ha_v1_masjids():
|
|
|
95
95
|
async def test_async_fetch_nearby_primary_success():
|
|
96
96
|
mock_resp = AsyncMock()
|
|
97
97
|
mock_resp.status = 200
|
|
98
|
-
mock_resp.json = AsyncMock(return_value=
|
|
98
|
+
mock_resp.json = AsyncMock(return_value=MOCK_LEGACY_PAYLOAD)
|
|
99
99
|
|
|
100
100
|
mock_session = MagicMock()
|
|
101
101
|
mock_session.get.return_value.__aenter__.return_value = mock_resp
|
|
102
102
|
|
|
103
|
-
places = await async_fetch_nearby(mock_session, 3.
|
|
103
|
+
places = await async_fetch_nearby(mock_session, 3.02, 101.79, 3)
|
|
104
104
|
assert len(places) == 2
|
|
105
|
-
assert places[0]["id"] == "
|
|
105
|
+
assert places[0]["id"] == "place-1"
|
|
106
106
|
|
|
107
107
|
# Verify primary URL was called
|
|
108
108
|
call_args = mock_session.get.call_args_list[0]
|
|
@@ -116,14 +116,14 @@ async def test_async_fetch_nearby_fallback_on_404():
|
|
|
116
116
|
|
|
117
117
|
resp_200 = AsyncMock()
|
|
118
118
|
resp_200.status = 200
|
|
119
|
-
resp_200.json = AsyncMock(return_value=
|
|
119
|
+
resp_200.json = AsyncMock(return_value=MOCK_HA_V1_PAYLOAD)
|
|
120
120
|
|
|
121
121
|
mock_session = MagicMock()
|
|
122
122
|
mock_session.get.return_value.__aenter__.side_effect = [resp_404, resp_200]
|
|
123
123
|
|
|
124
|
-
places = await async_fetch_nearby(mock_session, 3.
|
|
124
|
+
places = await async_fetch_nearby(mock_session, 3.1390, 101.6869, 5)
|
|
125
125
|
assert len(places) == 2
|
|
126
|
-
assert places[0]["id"] == "
|
|
126
|
+
assert places[0]["id"] == "surau-kl-sentral-kuala-lumpur"
|
|
127
127
|
|
|
128
128
|
# Verify both URLs were attempted
|
|
129
129
|
assert mock_session.get.call_count == 2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/requires.txt
RENAMED
|
File without changes
|
{python_jejakmasjid-0.3.0 → python_jejakmasjid-0.3.1}/src/python_jejakmasjid.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|