Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions tests/unit_tests/test_geoserver_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,6 @@ def test_create_shapefile_resource(self, mock_catalog, mock_put):

mc.get_default_workspace.assert_called_with()
mc.get_resource.assert_called_with(
name=self.store_names[0],
store=self.store_names[0],
workspace=self.workspace_name[0],
)
Expand Down Expand Up @@ -2321,7 +2320,7 @@ def test_create_shapefile_resource_zipfile(self, mock_catalog, mock_put):
self.assertIn(self.store_name[0], r["store"])

mc.get_resource.assert_called_with(
name="test1", store=self.store_names[0], workspace=self.workspace_name
store=self.store_names[0], workspace=self.workspace_name
)

@mock.patch("tethys_dataset_services.engines.geoserver_engine.requests.put")
Expand Down Expand Up @@ -2364,7 +2363,6 @@ def test_create_shapefile_resource_upload(self, mock_catalog, mock_put):
self.assertIn(self.store_name[0], r["store"])

mc.get_resource.assert_called_with(
name=self.store_names[0],
store=self.store_names[0],
workspace=self.workspace_name,
)
Expand Down Expand Up @@ -2440,7 +2438,6 @@ def test_create_shapefile_resource_overwrite_store_not_exists(
self.assertIn(self.store_name[0], r["store"])

mc.get_resource.assert_called_with(
name=self.store_names[0],
store=self.store_names[0],
workspace=self.workspace_name,
)
Expand Down
18 changes: 3 additions & 15 deletions tethys_dataset_services/engines/geoserver_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,6 @@ def create_sql_view_layer(
template = Template(text)
xml = template.render(context)


# Decide method, aligned with current GWC REST:
# PUT => add new layer, POST => modify existing layer
method = (gwc_method or "AUTO").upper()
Expand Down Expand Up @@ -2219,19 +2218,9 @@ def create_shapefile_resource(self, store_id, shapefile_base=None, shapefile_zip
self._handle_debug(response_dict, debug)
return response_dict

if shapefile_base:
# This case uses the store name as the Resource ID.
resource_id = name
elif shapefile_zip:
# This case uses the filename as the Resource ID.
resource_id = os.path.splitext(os.path.basename(shapefile_zip))[0]
elif shapefile_upload:
# This case uses the store name as the Resource ID.
resource_id = name

# Set the default style
if default_style is not None:
layer_url = self._assemble_url('layers', f'{workspace}:{resource_id}.xml')
layer_url = self._assemble_url("layers", name)
layer_headers = {"Content-Type": "application/xml"}
layer_data = f"""
<layer>
Expand Down Expand Up @@ -2259,7 +2248,7 @@ def create_shapefile_resource(self, store_id, shapefile_base=None, shapefile_zip

# Wrap up successfully
new_resource = self.catalog.get_resource(
name=resource_id, store=name, workspace=workspace
store=name, workspace=workspace
)
resource_dict = self._transcribe_geoserver_object(new_resource)

Expand Down Expand Up @@ -3040,8 +3029,7 @@ def delete_layer_group(self, layer_group_id):
if not workspace:
workspace = self.catalog.get_default_workspace().name

url = self._assemble_url("workspaces", workspace, "layergroups",
f"{group_name}")
url = self._assemble_url("workspaces", workspace, "layergroups", f"{group_name}")
response = requests.delete(
url,
auth=(self.username, self.password),
Expand Down
Loading