Skip to content

Commit 168de8e

Browse files
committed
Merge branch 'develop'
2 parents 8ee2cf2 + af61c2b commit 168de8e

16 files changed

Lines changed: 2901 additions & 2537 deletions

.github/workflows/unit-tests.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- master
99
jobs:
1010
test-on-pr:
11-
runs-on: windows-latest
11+
runs-on: ubuntu-latest
1212

1313
steps:
1414
- uses: actions/checkout@v4
@@ -18,12 +18,49 @@ jobs:
1818
with:
1919
python-version: '3.12'
2020

21+
- name: Start pygeoapi container
22+
run: |
23+
docker run --rm -d \
24+
-p 5000:80 \
25+
--rm --name=pygeoapi \
26+
geopython/pygeoapi:latest run-with-hot-reload
27+
28+
- name: Wait for service to be ready
29+
run: |
30+
# This gives the container a few seconds to initialize
31+
timeout 60s bash -c 'until curl -s localhost:5000 > /dev/null; do sleep 2; done'
32+
echo "pygeoapi is up and running"
33+
34+
- name: Enable admin api
35+
run: |
36+
docker exec pygeoapi sed -i 's/admin: .*/admin: true/' /pygeoapi/local.config.yml
37+
2138
- name: Install dependencies
2239
run: |
2340
python -m pip install --upgrade pip
2441
pip install -r requirements.txt
2542
pip install -r requirements_dev.txt
2643
44+
- name: Install GUI dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y \
48+
libgl1 \
49+
libegl1 \
50+
libglx-mesa0 \
51+
libglib2.0-0t64 \
52+
libdbus-1-3 \
53+
libxkbcommon-x11-0 \
54+
libxcb-icccm4 \
55+
libxcb-image0 \
56+
libxcb-keysyms1 \
57+
libxcb-randr0 \
58+
libxcb-render-util0 \
59+
libxcb-xinerama0 \
60+
libxcb-xinput0 \
61+
libxcb-xfixes0 \
62+
libxcb-shape0
63+
2764
- name: Run unit tests (headless PyQt)
2865
env:
2966
QT_QPA_PLATFORM: offscreen

models/ConfigData.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass, field, fields, is_dataclass
2-
from datetime import datetime, timezone
2+
from datetime import datetime
33
from enum import Enum
44

55
from .utils import update_dataclass_from_dict
@@ -9,6 +9,7 @@
99
MetadataConfig,
1010
ResourceConfigTemplate,
1111
)
12+
from ..utils.helper_functions import datetime_to_string
1213
from .top_level.utils import InlineList
1314
from .top_level.providers import ProviderTemplate
1415
from .top_level.providers.records import ProviderTypes
@@ -141,14 +142,6 @@ def all_missing_props(self):
141142
return self._all_missing_props
142143
return []
143144

144-
def datetime_to_string(self, data: datetime):
145-
# normalize to UTC and format with Z
146-
if data.tzinfo is None:
147-
data = data.replace(tzinfo=timezone.utc)
148-
else:
149-
data = data.astimezone(timezone.utc)
150-
return data.strftime("%Y-%m-%dT%H:%M:%SZ")
151-
152145
def asdict_enum_safe(self, obj, datetime_to_str=False):
153146
"""Overwriting dataclass 'asdict' fuction to replace Enums with strings."""
154147
if is_dataclass(obj):
@@ -177,7 +170,7 @@ def asdict_enum_safe(self, obj, datetime_to_str=False):
177170
}
178171
else:
179172
if isinstance(obj, datetime) and datetime_to_str:
180-
return self.datetime_to_string(obj)
173+
return datetime_to_string(obj)
181174
else:
182175
return obj
183176

models/top_level/utils.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,3 @@ def bbox_from_list(raw_bbox_list: list):
5050
)
5151

5252
return InlineList(list_bbox_val)
53-
54-
55-
def to_iso8601(dt: datetime) -> str:
56-
"""
57-
Convert datetime to UTC ISO 8601 string, for both naive and aware datetimes.
58-
"""
59-
if dt.tzinfo is None:
60-
# Treat naive datetime as UTC
61-
dt = dt.replace(tzinfo=timezone.utc)
62-
else:
63-
# Convert to UTC
64-
dt = dt.astimezone(timezone.utc)
65-
66-
return dt.strftime("%Y-%m-%dT%H:%M:%SZ")

models/utils.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from types import UnionType
55
from typing import Any, get_origin, get_args, Union, get_type_hints
66

7-
from .top_level.utils import InlineList, get_enum_value_from_string
7+
from .top_level.utils import (
8+
InlineList,
9+
get_enum_value_from_string,
10+
)
11+
from ..utils.helper_functions import datetime_from_string
812

913

1014
def update_dataclass_from_dict(
@@ -67,12 +71,7 @@ def update_dataclass_from_dict(
6771
if (datetime in args or expected_type is datetime) and isinstance(
6872
new_value, str
6973
):
70-
try:
71-
new_value = datetime.strptime(
72-
new_value, "%Y-%m-%dT%H:%M:%SZ"
73-
)
74-
except:
75-
pass
74+
new_value = datetime_from_string(new_value)
7675

7776
# Exception: remap str to Enum
7877
elif isinstance(expected_type, type) and issubclass(
@@ -294,11 +293,10 @@ def _is_instance_of_type(value, expected_type) -> bool:
294293

295294
# Exception: try cast str to datetime manually
296295
if expected_type is datetime:
297-
try:
298-
datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ")
296+
if datetime_from_string(value) is not None:
299297
return True
300-
except:
301-
pass
298+
else:
299+
return False
302300

303301
# Fallback for normal types
304302
return isinstance(value, expected_type)

pb_tool.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ python_files: __init__.py pygeoapi_config.py pygeoapi_config_dialog.py
5454
main_dialog: pygeoapi_config_dialog_base.ui
5555

5656
# Other ui files for dialogs you create (these will be compiled)
57-
compiled_ui_files:
57+
compiled_ui_files: server_config_dialog.ui
5858

5959
# Resource file(s) that will be compiled
6060
resource_files: resources.qrc

pygeoapi_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
# Import the code for the dialog
3232
from .pygeoapi_config_dialog import PygeoapiConfigDialog
33+
3334
import os.path
3435

3536

0 commit comments

Comments
 (0)