mirror of
https://github.com/geoserver/geoserver-cloud.git
synced 2025-12-08 20:16:08 +00:00
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
from tests.conftest import (
|
|
PGDATABASE,
|
|
PGPASSWORD,
|
|
PGSCHEMA,
|
|
PGUSER,
|
|
RESOURCE_DIR,
|
|
)
|
|
|
|
|
|
def test_wfs(geoserver_factory):
|
|
workspace = datastore = feature_type = "test_wfs"
|
|
geoserver = geoserver_factory(workspace)
|
|
attributes = {
|
|
"geom": {
|
|
"type": "Point",
|
|
"required": True,
|
|
},
|
|
"id": {
|
|
"type": "integer",
|
|
"required": True,
|
|
},
|
|
"title": {
|
|
"type": "string",
|
|
"required": False,
|
|
},
|
|
"timestamp": {
|
|
"type": "datetime",
|
|
"required": False,
|
|
},
|
|
}
|
|
_, code = geoserver.create_pg_datastore(
|
|
workspace_name=workspace,
|
|
datastore_name=datastore,
|
|
pg_host="geodatabase",
|
|
pg_port=5432,
|
|
pg_db=PGDATABASE,
|
|
pg_user=PGUSER,
|
|
pg_password=PGPASSWORD,
|
|
pg_schema=PGSCHEMA,
|
|
set_default_datastore=True,
|
|
)
|
|
assert code == 201
|
|
content, code = geoserver.create_feature_type(
|
|
feature_type, attributes=attributes, epsg=2056
|
|
)
|
|
assert content == ""
|
|
assert code == 201
|
|
|
|
# Post a feature through a WFS request
|
|
with open(f"{RESOURCE_DIR}/wfs_payload.xml") as file:
|
|
data = file.read()
|
|
response = geoserver.rest_service.rest_client.post(
|
|
f"/{workspace}/wfs/", data=data
|
|
)
|
|
assert response.status_code == 200
|
|
|
|
# GetFeature request
|
|
feature_collection = geoserver.get_feature(workspace, feature_type)
|
|
assert type(feature_collection) is dict
|
|
assert type(feature_collection.get("features")) is list
|
|
feature = feature_collection["features"][0]
|
|
properties = feature.get("properties")
|
|
assert properties.get("id") == 10
|
|
assert properties.get("title") == "Title"
|
|
assert properties.get("timestamp") == "2024-05-13T08:14:48.763Z"
|
|
assert feature.get("geometry", {}) == {
|
|
"type": "Point",
|
|
"coordinates": [2600000, 1200000],
|
|
}
|
|
assert feature_collection.get("crs") == {
|
|
"type": "name",
|
|
"properties": {"name": "urn:ogc:def:crs:EPSG::2056"},
|
|
}
|