diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index d2ce901..1668e19 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -13,10 +13,6 @@ on: permissions: contents: read -env: - GEOSERVER_USER: ${{secrets.GEOSERVER_USER}} - GEOSERVER_PASSWORD: ${{secrets.GEOSERVER_PASSWORD}} - jobs: # ------- START TEST PROCCESS -------- # @@ -40,10 +36,6 @@ jobs: - name: Install dependencies run: | pip install -r ./requirements.txt - - name: Create environment variables - run: | - export GEOSERVER_USER=${{env.GEOSERVER_USER}} - export GEOSERVER_PASSWORD=${{env.GEOSERVER_PASSWORD}} - name: Run Tests run: | python -m unittest discover -s ./src/test/ -p 'test_*.py' diff --git a/README.md b/README.md index 5f7c0c1..adbf055 100644 Binary files a/README.md and b/README.md differ diff --git a/src/aclimate_api/geoserver.py b/src/aclimate_api/geoserver.py index 8acd792..7a28198 100644 --- a/src/aclimate_api/geoserver.py +++ b/src/aclimate_api/geoserver.py @@ -5,22 +5,23 @@ import re import tempfile import geopandas as gpd -import os class Geoserver: def __init__(self, url_root): self.url_root = url_root - def get_geo_workspaces(self): + def get_geo_workspaces(self, user, password): """ Retrieves the list of GeoServer workspaces. + Args: + user (str): The username for the GeoServer instance. + password (str): The password for the GeoServer instance. + Returns: pandas.DataFrame: A DataFrame containing the workspace names and their corresponding hrefs. """ - user = os.getenv("GEOSERVER_USER") - password = os.getenv("GEOSERVER_PASSWORD") if not user or not password: print("Error: Missing GeoServer credentials") @@ -57,18 +58,18 @@ def get_geo_workspaces(self): # print(get_geo_workspaces("https://geo.aclimate.org/geoserver/")) - def get_geo_mosaic_name(self, workspace): + def get_geo_mosaic_name(self, workspace, user, password): """ Retrieves the names and hrefs of the mosaics in the specified GeoServer workspace. Args: workspace (str): The name of the GeoServer workspace. + user (str): The username for the GeoServer instance. + password (str): The password for the GeoServer instance. Returns: pandas.DataFrame: A DataFrame containing the mosaic names and hrefs, or an empty DataFrame if there was an error. """ - user = os.getenv("GEOSERVER_USER") - password = os.getenv("GEOSERVER_PASSWORD") if not user or not password: print("Error: Missing GeoServer credentials") @@ -155,19 +156,19 @@ def get_geo_mosaics(self, workspace, mosaic_name, year, month=1, day=1): # print(get_geo_mosaics("https://geo.aclimate.org/geoserver/", "waterpoints_et", "biomass", 2024, 4, 22)) - def get_geo_polygon_name(self, workspace): + def get_geo_polygon_name(self, workspace, user, password): """ Retrieves the names and hrefs of polygons from the specified workspace in GeoServer. Args: workspace (str): The name of the workspace in GeoServer. + user (str): The username for the GeoServer instance. + password (str): The password for the GeoServer instance. Returns: pandas.DataFrame: A DataFrame containing the names and hrefs of the polygons, with columns 'polygon_name' and 'polygon_href'. If no polygons are found or an error occurs, an empty DataFrame is returned. """ - user = os.getenv("GEOSERVER_USER") - password = os.getenv("GEOSERVER_PASSWORD") if not user or not password: print("Error: Missing GeoServer credentials") diff --git a/src/test/test_geoserver.py b/src/test/test_geoserver.py index e4c87d0..52b2aed 100644 --- a/src/test/test_geoserver.py +++ b/src/test/test_geoserver.py @@ -25,7 +25,7 @@ def test_get_geo_workspaces(self, mock_get): mock_get.return_value.status_code = 200 mock_get.return_value.text = geo_workspace_mock_data - result = self.geoserver.get_geo_workspaces() + result = self.geoserver.get_geo_workspaces("test","pass") self.assertIsInstance(result, pd.DataFrame) self.assertIn("workspace_name", result.columns) @@ -39,7 +39,7 @@ def test_get_geo_mosaic_name(self, mock_get): mock_get.return_value.status_code = 200 mock_get.return_value.text = geo_mosaic_name_mock_data - result = self.geoserver.get_geo_mosaic_name(workspace) + result = self.geoserver.get_geo_mosaic_name(workspace,"test","pass") self.assertIsInstance(result, pd.DataFrame) self.assertIn("mosaic_name", result.columns) @@ -74,7 +74,7 @@ def test_get_geo_polygon_name(self, mock_get): mock_get.return_value.status_code = 200 mock_get.return_value.text = geo_polygon_name_mock_data - result = self.geoserver.get_geo_polygon_name(workspace) + result = self.geoserver.get_geo_polygon_name(workspace,"test","pass") self.assertIsInstance(result, pd.DataFrame) self.assertIn("polygon_name", result.columns)