Skip to content

Commit b80d103

Browse files
committed
Added automatic testing and fixed docker. Updated README
1 parent 62dba7b commit b80d103

6 files changed

Lines changed: 67 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ token.json
88
NOTES_drive.md
99
drive_plans_fetch.py
1010
SPEC.mc
11-
mls_spatial.db
11+
mls_spatial.db
12+
test_results.txt

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12-slim
1+
FROM python:3.11-slim
22
WORKDIR /app
33
COPY requirements.txt .
44
RUN pip install --no-cache-dir -r requirements.txt

PLAN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ All Python repos follow the same pattern: FastAPI service, structured as a packa
7070

7171
**Engineering hygiene**
7272
- Rewrite all tests with mocked HTTP using `pytest-httpx` (no live API calls) # DONE
73-
- Add `Dockerfile` and `docker-compose.yml` # DONE needs testing though
74-
- Add GitHub Actions workflow — runs pytest on every push # not done
73+
- Add `Dockerfile` and `docker-compose.yml` # DONE
74+
- Add GitHub Actions workflow — runs pytest on every push # DONE
7575
- Add SQLite search history (`service/history.py`, `GET /history` endpoint) # DONE
76-
- Convert NSW API calls to async using `httpx` + `asyncio` # not done
76+
- Convert NSW API calls to async using `httpx` + `asyncio` # check with surveyor, bit of a big change and already runs API calls in parallel using ThreadPoolExecutor
7777

7878
### Definition of done
7979
- All 3 GitHub issues closed with a PR each # no pr

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
![CI](https://github.com/jamAM7/mls-spatial/actions/workflows/ci.yml/badge.svg)
2+
13
# MLS Spatial Search
24

35
NSW cadastral search tool — queries Spatial Services APIs to return lots, survey plans and survey marks for a given address. Generates cadastral drawings, CRE map images and downloads plan documents from Google Drive.
46

57
## Requirements
6-
- Python 3.x
8+
- Python 3.11
79
- `credentials.json` — Google OAuth credentials (provided separately, never committed to git)
810
- `token.json` — created automatically on first run after authenticating with Google
911

@@ -35,6 +37,31 @@ source venv/bin/activate
3537
pip install -r requirements.txt
3638
```
3739

40+
## Running with Docker (recommended)
41+
42+
Docker is the easiest way to run the service without configuring a local Python environment.
43+
44+
### Requirements
45+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
46+
- `credentials.json` and `token.json` in the project root
47+
48+
### Start the service
49+
```
50+
docker compose up --build
51+
```
52+
53+
The service will be available at `http://localhost:8000`.
54+
55+
To run in the background:
56+
```
57+
docker compose up --build -d
58+
```
59+
60+
To stop:
61+
```
62+
docker compose down
63+
```
64+
3865
## Usage
3966

4067
Run the console app:
@@ -62,7 +89,7 @@ Results are saved to `output/{address}-{date}/` containing:
6289
- `cre_map.png` — CRE raster map image (options 2, 3, 4)
6390
- `plans/` — downloaded plan PDFs from Google Drive (option 3)
6491

65-
## Running the FastAPI Service (optional)
92+
## FastAPI Service
6693

6794
For programmatic access or the AutoCAD add-in:
6895
```
@@ -82,11 +109,19 @@ Interactive API documentation: `http://localhost:8000/docs`
82109

83110
## Testing
84111

112+
Run the full test suite:
85113
```
86114
pytest tests/ -v
87115
```
88116

89-
Tests use mocked HTTP via the `responses` library and require no internet connection. All NSW Spatial Services API calls are intercepted using fixture data in `tests/fixtures/`.
117+
To save output to a file:
118+
```
119+
pytest tests/ -v > test_results.txt 2>&1
120+
```
121+
122+
Tests use mocked HTTP via the `responses` library — no internet connection or running server required. All NSW Spatial Services API calls are intercepted using fixture JSON files in `tests/fixtures/`.
123+
124+
CI runs automatically on every push via GitHub Actions.
90125

91126
## Data Sources
92127
- NSW Spatial Services: https://portal.spatial.nsw.gov.au

logs/service-err.log

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,3 +4056,25 @@ Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsA
40564056
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
40574057
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
40584058
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4059+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4060+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4061+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4062+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4063+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4064+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4065+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4066+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4067+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4068+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4069+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4070+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4071+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4072+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4073+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4074+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4075+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4076+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4077+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4078+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4079+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'
4080+
Unable to create process using '"C:\Users\jamez\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe" -m uvicorn server:app --host 0.0.0.0 --port 8000'

service/drive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _is_exact_plan_match(filename: str, pl_exact: str, digits: str) -> bool:
187187
return True
188188
if re.search(r'\b' + prefix + r'[\s_]0*' + digits + r'\b', name_u):
189189
return True
190-
plan_word = "DEPOSITED[\s_]PLAN" if prefix == "DP" else "STRATA[\s_]PLAN"
190+
plan_word = r"DEPOSITED[\s_]PLAN" if prefix == "DP" else r"STRATA[\s_]PLAN"
191191
if re.search(plan_word + r'[\s_]0*' + digits + r'\b', name_u):
192192
return True
193193
if re.search(r'(?<![0-9])0*' + digits + r'(?![0-9])', name_u):

0 commit comments

Comments
 (0)