Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTC-3081: Add political/id-lookup endpoint #616

Merged
merged 48 commits into from
Jan 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b94f3fa
Initial attempt at stub route for geoencoder
dmannarino Dec 17, 2024
505cc16
Turn URL params into query params; add boundary version, source;
dmannarino Dec 18, 2024
0514d42
Initial test, not expected to pass
dmannarino Dec 18, 2024
9d2ae13
Disable geoencoder tests to get it to deploy
dmannarino Dec 19, 2024
44a253f
WIP: Run a query instead of canned response
dmannarino Dec 19, 2024
9c2e0ca
WIP: refactor to make better use of helper fcns
dmannarino Dec 20, 2024
899e772
More error handling and tests
dmannarino Dec 20, 2024
d633596
Correct region/subregion->name fields
dmannarino Dec 21, 2024
7f5e9f3
Correct case of multiple WHEREs
dmannarino Dec 21, 2024
2f2facd
Update pre-commit packages, disable docformatter until it's fixed
dmannarino Dec 21, 2024
15de81a
Too much, TBH: Add limiting query to specified admin level; enforce s…
dmannarino Dec 23, 2024
40f7772
pipenv finally updated packages; add unidecode for geoencode endpoint
dmannarino Dec 26, 2024
2cee550
Optionally unaccent names in request to geoencode endpoint
dmannarino Dec 26, 2024
e07c4f4
Update lockfile for new raterio/numpy
dmannarino Dec 26, 2024
bb69f18
Don't pass Nones to unidecode
dmannarino Dec 26, 2024
1b95ca2
Actually search the unaccented columns
dmannarino Dec 27, 2024
79ae7c3
Add output example from ticket as a test, and adjust code to pass
dmannarino Dec 27, 2024
09e628e
Get regular fields, not unaccented ones
dmannarino Dec 27, 2024
2934fd6
Fix bug introduced in last commit: GET name fields, MATCH on (potenti…
dmannarino Dec 27, 2024
e09cf01
Add a test for getting from unaccented fields
dmannarino Dec 27, 2024
2d979a2
Hide extraneous fields
dmannarino Dec 27, 2024
0c6d541
Add docstrings, add a test, and slightly improve error message on non…
dmannarino Dec 27, 2024
ed5f2cd
Decapitalize as part of normalization; add tests
dmannarino Dec 27, 2024
34c41f8
Return GIDs as relative, not complete values. eg: GID_1=1 instead of …
dmannarino Dec 28, 2024
1952fc0
Minor doc addition
dmannarino Dec 28, 2024
c6384fd
Merge branch 'develop' into gtc-3081_geoencoder_endpoint
dmannarino Dec 28, 2024
4aef63c
Merge branch 'develop' into gtc-3081_geoencoder_endpoint
dmannarino Jan 7, 2025
0f80b9e
WIP: Move geoencode query params into a model in order to implement a…
dmannarino Jan 12, 2025
b23bf7f
Fix resolving version to string
dmannarino Jan 12, 2025
275ff6e
WIP: Temporarily include geoencode route in docs
dmannarino Jan 12, 2025
53ddba5
Fix for last commit: PRepend 'v' to version string, again.
dmannarino Jan 13, 2025
3bc92f5
WIP: Add lookup_admin_source_version helper, duplicating some code
dmannarino Jan 13, 2025
fbacd70
Raise ValueErrors instead of AssertionErrors on bad params
dmannarino Jan 13, 2025
9c5fc87
After much pain and gnashing of teeth, get validator working again
dmannarino Jan 14, 2025
849d68a
Add models for Geoencoder responses and children
dmannarino Jan 14, 2025
4668790
Use dolar sign quoting to avoid PostgreSQL complaining about apostrop…
dmannarino Jan 14, 2025
68f6590
Add type hint per Dan's suggestion
dmannarino Jan 21, 2025
d35bb02
Re-enable docformatter precommit hook
dmannarino Jan 24, 2025
0bdb3e5
Merge branch 'develop' into gtc-3081_geoencoder_endpoint
dmannarino Jan 24, 2025
a9cf2df
Improve error messages
dmannarino Jan 24, 2025
83aa0a0
Move geoencoder to /political/geoencoder
dmannarino Jan 24, 2025
0effc5b
Break forming Geoencoder response out into a helper
dmannarino Jan 24, 2025
84bf869
Rename geoencoder endpoint to id-lookup
dmannarino Jan 24, 2025
af3c244
Set version of GADM 4.1 in various environments
dmannarino Jan 27, 2025
498ecc6
Implement Gary's suggestions to rename from geoencoder -> admin id lo…
dmannarino Jan 27, 2025
d9e0cda
Use AdminIDLookupResponseData properly and add a few type hints
dmannarino Jan 28, 2025
55e1a2f
Merge branch 'develop' into gtc-3081_geoencoder_endpoint
dmannarino Jan 29, 2025
ffe9b6b
Use this branch's Pipfile, I need unidecode
dmannarino Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Initial test, not expected to pass
dmannarino committed Dec 18, 2024
commit 0514d4286d49f8a60c6a6f2cb6ae1686999a4f97
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions tests_v2/unit/app/routes/thematic/geoencoder/test_geoencoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest
from httpx import AsyncClient


@pytest.mark.asyncio
async def test_geoencoder_no_version(async_client: AsyncClient) -> None:
params = {"country": "Canada"}

resp = await async_client.get("/thematic/geoencode", params=params)

assert resp.status_code == 400


@pytest.mark.asyncio
async def test_geoencoder_fake_country_no_matches(async_client: AsyncClient) -> None:

params = {"admin_version": "4.1", "country": "Canadiastan"}

resp = await async_client.get("/thematic/geoencode", params=params)

assert resp.status_code == 200
assert resp.status_code == {
"status": "success",
"data": {
"adminVersion": "4.1",
"matches": []
}
}