forked from geoserver/geoserver-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe35e23
commit 9b290af
Showing
31 changed files
with
888 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,60 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
import sqlalchemy | ||
from geoservercloud import GeoServerCloud | ||
|
||
|
||
GEOSERVER_URL = os.getenv("GEOSERVER_URL", "http://gateway:8080/geoserver/cloud") | ||
RESOURCE_DIR = Path(__file__).parent / "resources" | ||
# Database connection | ||
PGHOST = "geodatabase" | ||
PGPORT = 5432 | ||
PGDATABASE = "geodata" | ||
PGUSER = "geodata" | ||
PGPASSWORD = "geodata" | ||
PGSCHEMA = "test1" | ||
WORKSPACE = "test_workspace" | ||
DATASTORE = "test_datastore" | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def engine(): | ||
yield sqlalchemy.create_engine( | ||
f"postgresql://{PGUSER}:{PGPASSWORD}@{PGHOST}:{PGPORT}/{PGDATABASE}", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def db_session(engine): | ||
with engine.connect() as connection: | ||
connection.execute( | ||
sqlalchemy.sql.text(f"CREATE SCHEMA IF NOT EXISTS {PGSCHEMA}") | ||
) | ||
connection.execute(sqlalchemy.sql.text(f"SET SEARCH_PATH = {PGSCHEMA}")) | ||
connection.commit() | ||
yield connection | ||
connection.execute( | ||
sqlalchemy.sql.text(f"DROP SCHEMA IF EXISTS {PGSCHEMA} CASCADE") | ||
) | ||
connection.commit() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def geoserver(): | ||
yield GeoServerCloud(GEOSERVER_URL) | ||
geoserver = GeoServerCloud(GEOSERVER_URL) | ||
geoserver.recreate_workspace(WORKSPACE, set_default_workspace=True) | ||
geoserver.create_pg_datastore( | ||
workspace=WORKSPACE, | ||
datastore=DATASTORE, | ||
pg_host=PGHOST, | ||
pg_port=PGPORT, | ||
pg_db=PGDATABASE, | ||
pg_user=PGUSER, | ||
pg_password=PGPASSWORD, | ||
pg_schema=PGSCHEMA, | ||
set_default_datastore=True, | ||
) | ||
geoserver.publish_workspace(WORKSPACE) | ||
yield geoserver | ||
geoserver.delete_workspace(WORKSPACE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pathlib import Path | ||
|
||
|
||
def write_actual_image(response, tag): | ||
file = Path(f"/tmp/{tag}_actual.png") | ||
file.parent.mkdir(parents=True, exist_ok=True) | ||
with open(file, "wb") as fs: | ||
fs.write(response.read()) | ||
|
||
|
||
def compare_images(dir, tag): | ||
actual = f"/tmp/{tag}_actual.png" | ||
expected = f"{dir}/{tag}_expected.png" | ||
with open(actual, "rb") as fs1, open(expected, "rb") as fs2: | ||
assert fs1.read() == fs2.read() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.48 KB
.../tests/resources/labels/default_locale/default_value/language_None_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.87 KB
...ests/tests/resources/labels/default_locale/default_value/language__expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.16 KB
...ts/tests/resources/labels/default_locale/default_value/language_de_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.48 KB
...ts/tests/resources/labels/default_locale/default_value/language_fr_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
...ts/tests/resources/labels/default_locale/default_value/language_it_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.48 KB
...sts/resources/labels/default_locale/no_default_value/language_None_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
...s/tests/resources/labels/default_locale/no_default_value/language__expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
...tests/resources/labels/default_locale/no_default_value/language_it_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.87 KB
...sts/resources/labels/no_default_locale/default_value/language_None_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.87 KB
...s/tests/resources/labels/no_default_locale/default_value/language__expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.16 KB
...tests/resources/labels/no_default_locale/default_value/language_de_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.48 KB
...tests/resources/labels/no_default_locale/default_value/language_fr_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
...tests/resources/labels/no_default_locale/default_value/language_it_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
.../resources/labels/no_default_locale/no_default_value/language_None_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
...ests/resources/labels/no_default_locale/no_default_value/language__expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+670 Bytes
...ts/resources/labels/no_default_locale/no_default_value/language_it_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<StyledLayerDescriptor version="1.0.0" | ||
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" | ||
xmlns="http://www.opengis.net/sld" | ||
xmlns:ogc="http://www.opengis.net/ogc" | ||
xmlns:se="http://www.opengis.net/se" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<NamedLayer> | ||
<Name>localized_labels</Name> | ||
<UserStyle> | ||
<Name>localized_labels</Name> | ||
<FeatureTypeStyle> | ||
<Rule> | ||
<Name>Localized labels</Name> | ||
<TextSymbolizer> | ||
<Label> | ||
<ogc:Function name="Recode"> | ||
<ogc:Function name="language"/> | ||
<ogc:Literal/> | ||
<ogc:PropertyName>label_default</ogc:PropertyName> | ||
<ogc:Literal>de</ogc:Literal> | ||
<ogc:PropertyName>label_de</ogc:PropertyName> | ||
<ogc:Literal>fr</ogc:Literal> | ||
<ogc:PropertyName>label_fr</ogc:PropertyName> | ||
</ogc:Function> | ||
</Label> | ||
<Fill> | ||
<CssParameter name="fill">#000000</CssParameter> | ||
</Fill> | ||
</TextSymbolizer> | ||
</Rule> | ||
</FeatureTypeStyle> | ||
</UserStyle> | ||
</NamedLayer> | ||
</StyledLayerDescriptor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<StyledLayerDescriptor version="1.0.0" | ||
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" | ||
xmlns="http://www.opengis.net/sld" | ||
xmlns:ogc="http://www.opengis.net/ogc" | ||
xmlns:se="http://www.opengis.net/se" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<NamedLayer> | ||
<Name>localized_style</Name> | ||
<UserStyle> | ||
<Name>localized_no_default</Name> | ||
<FeatureTypeStyle> | ||
<Rule> | ||
<Name>Localized, no default value</Name> | ||
<Title> | ||
<Localized lang="en">English</Localized> | ||
<Localized lang="de">Deutsch</Localized> | ||
<Localized lang="fr">Français</Localized> | ||
<Localized lang="it">Italiano</Localized> | ||
</Title> | ||
<PointSymbolizer> | ||
<Graphic> | ||
<Mark> | ||
<WellKnownName>circle</WellKnownName> | ||
<Fill> | ||
<CssParameter name="fill">#FF0000</CssParameter> | ||
</Fill> | ||
</Mark> | ||
<Size>6</Size> | ||
</Graphic> | ||
</PointSymbolizer> | ||
</Rule> | ||
</FeatureTypeStyle> | ||
</UserStyle> | ||
</NamedLayer> | ||
</StyledLayerDescriptor> |
37 changes: 37 additions & 0 deletions
37
acceptance_tests/tests/resources/localized_with_default.sld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<StyledLayerDescriptor version="1.0.0" | ||
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" | ||
xmlns="http://www.opengis.net/sld" | ||
xmlns:ogc="http://www.opengis.net/ogc" | ||
xmlns:se="http://www.opengis.net/se" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<NamedLayer> | ||
<Name>localized_style</Name> | ||
<UserStyle> | ||
<Name>localized_with_default</Name> | ||
<FeatureTypeStyle> | ||
<Rule> | ||
<Name>Localized, with default value</Name> | ||
<Title> | ||
Default label<Localized lang="en">English</Localized> | ||
<Localized lang="de">Deutsch</Localized> | ||
<Localized lang="fr">Français</Localized> | ||
<Localized lang="it">Italiano</Localized> | ||
</Title> | ||
<PointSymbolizer> | ||
<Graphic> | ||
<Mark> | ||
<WellKnownName>circle</WellKnownName> | ||
<Fill> | ||
<CssParameter name="fill">#FF0000</CssParameter> | ||
</Fill> | ||
</Mark> | ||
<Size>6</Size> | ||
</Graphic> | ||
</PointSymbolizer> | ||
</Rule> | ||
</FeatureTypeStyle> | ||
</UserStyle> | ||
</NamedLayer> | ||
</StyledLayerDescriptor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> | ||
<Insert> | ||
<test_wfs xmlns="test_wfs"> | ||
<geom> | ||
<Point xmlns="http://www.opengis.net/gml" srsName="EPSG:2056"> | ||
<pos srsDimension="2">2600000.0 1200000.0</pos> | ||
</Point> | ||
</geom> | ||
<timestamp>2024-05-13T08:14:48.763Z</timestamp> | ||
<id>10</id> | ||
<title>Title</title> | ||
</test_wfs> | ||
</Insert> | ||
</Transaction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from conftest import PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD, PGSCHEMA | ||
|
||
|
||
def test_create_get_and_delete_datastore(geoserver): | ||
workspace = datastore = "test_create_pg_datastore" | ||
geoserver.create_workspace(workspace) | ||
response = geoserver.create_pg_datastore( | ||
workspace=workspace, | ||
datastore=datastore, | ||
pg_host=PGHOST, | ||
pg_port=PGPORT, | ||
pg_db=PGDATABASE, | ||
pg_user=PGUSER, | ||
pg_password=PGPASSWORD, | ||
pg_schema=PGSCHEMA, | ||
set_default_datastore=True, | ||
) | ||
assert response.status_code == 201 | ||
response = geoserver.get_request( | ||
f"/rest/workspaces/{workspace}/datastores/{datastore}.json" | ||
) | ||
assert response.status_code == 200 | ||
response = geoserver.delete_workspace(workspace) | ||
assert response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pytest | ||
|
||
WORKSPACE = "test_gwc" | ||
WMTS_STORE = "test_gwc_store" | ||
WMTS_LAYER = "ch.swisstopo.swissimage" | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def geoserver_with_gwc_layers(geoserver): | ||
geoserver.create_workspace(WORKSPACE) | ||
geoserver.create_wmts_store( | ||
WORKSPACE, | ||
WMTS_STORE, | ||
capabilities="https://wmts.geo.admin.ch/EPSG/4326/1.0.0/WMTSCapabilities.xml", | ||
) | ||
geoserver.create_wmts_layer(WORKSPACE, WMTS_STORE, WMTS_LAYER) | ||
geoserver.get_request( | ||
f"/rest/workspaces/{WORKSPACE}/wmtsstores/{WMTS_STORE}/layers/{WMTS_LAYER}.json" | ||
) | ||
response = geoserver.publish_gwc_layer(WORKSPACE, WMTS_LAYER) | ||
assert response.status_code == 200 | ||
yield geoserver | ||
geoserver.delete_workspace(WORKSPACE) | ||
|
||
|
||
def test_tile_cache(geoserver_with_gwc_layers): | ||
|
||
response = geoserver_with_gwc_layers.get_tile( | ||
format="image/png", | ||
layer=f"{WORKSPACE}:{WMTS_LAYER}", | ||
tile_matrix_set="EPSG:4326", | ||
tile_matrix="EPSG:4326:9", | ||
row=122, | ||
column=534, | ||
) | ||
assert response.info().get("Content-Type") == "image/png" | ||
assert response.info().get("Geowebcache-Cache-Result") == "MISS" | ||
|
||
response = geoserver_with_gwc_layers.get_tile( | ||
format="image/png", | ||
layer=f"{WORKSPACE}:{WMTS_LAYER}", | ||
tile_matrix_set="EPSG:4326", | ||
tile_matrix="EPSG:4326:9", | ||
row=122, | ||
column=534, | ||
) | ||
assert response.info().get("Geowebcache-Cache-Result") == "HIT" |
Oops, something went wrong.