Skip to content

Commit fe1d7d2

Browse files
authored
Fix workspace bounding box parsing (#191)
This pr adds a fix to the workspace bounding box parsing as well as adds a test adding coverage to that parsing ## Checklist - [ ] I have read the contributing guide and the code of conduct
1 parent 3cc9213 commit fe1d7d2

File tree

5 files changed

+104
-8
lines changed

5 files changed

+104
-8
lines changed

packages/evo-sdk-common/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "evo-sdk-common"
33
description = "Python package that establishes a common framework for use by client libraries that interact with Seequent Evo APIs"
4-
version = "0.5.14"
4+
version = "0.5.15"
55
requires-python = ">=3.10"
66
license-files = ["LICENSE.md"]
77
dynamic = ["readme"]

packages/evo-sdk-common/src/evo/workspaces/parse.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def workspace_model(
8383
:param base_url: The base URL of the hub.
8484
:return: A Workspace instance.
8585
"""
86-
bounding_box = None
86+
parsed_bounding_box = None
8787
if model.bounding_box:
88-
bounding_box = bounding_box(model.bounding_box)
88+
parsed_bounding_box = bounding_box(model.bounding_box)
8989

9090
return Workspace(
9191
id=model.id,
@@ -94,11 +94,11 @@ def workspace_model(
9494
display_name=model.name,
9595
description=model.description,
9696
user_role=WorkspaceRole[str(model.current_user_role.value)] if model.current_user_role else None,
97-
created_at=model.created_at,
97+
created_at=model.created_at.replace(tzinfo=timezone.utc),
9898
created_by=ServiceUser.from_model(model.created_by),
99-
updated_at=model.updated_at,
99+
updated_at=model.updated_at.replace(tzinfo=timezone.utc),
100100
updated_by=ServiceUser.from_model(model.updated_by),
101-
bounding_box=bounding_box,
101+
bounding_box=parsed_bounding_box,
102102
default_coordinate_system=model.default_coordinate_system,
103103
labels=model.labels,
104104
)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"id": "00000000-0000-0000-0000-00000000000d",
3+
"name": "Test Workspace D",
4+
"description": "test workspace d",
5+
"current_user_role": "owner",
6+
"bounding_box": {
7+
"coordinates": [
8+
[
9+
[
10+
100,
11+
0
12+
],
13+
[
14+
101,
15+
0
16+
],
17+
[
18+
101,
19+
1
20+
],
21+
[
22+
100,
23+
1
24+
],
25+
[
26+
100,
27+
0
28+
]
29+
]
30+
],
31+
"type": "Polygon"
32+
},
33+
"created_at": "2020-01-01T00:00:00.000000+00:00",
34+
"updated_at": "2020-01-01T00:00:00.000000+00:00",
35+
"created_by": {
36+
"id": "00000000-0000-0000-0000-000000000002",
37+
"name": "Test User",
38+
"email": "test.user@unit.test"
39+
},
40+
"updated_by": {
41+
"id": "00000000-0000-0000-0000-000000000002",
42+
"name": "Test User",
43+
"email": "test.user@unit.test"
44+
},
45+
"ml_enabled": false,
46+
"default_coordinate_system": "",
47+
"labels": [],
48+
"self_link": "https://unittest.localhost/workspace/orgs/00000000-0000-0000-0000-000000000000/workspaces"
49+
}

packages/evo-sdk-common/tests/workspaces/test_workspace_client.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from evo.workspaces import (
2121
AddedInstanceUsers,
2222
BasicWorkspace,
23+
BoundingBox,
24+
Coordinate,
2325
InstanceRole,
2426
InstanceRoleWithPermissions,
2527
InstanceUser,
@@ -44,7 +46,7 @@
4446
TEST_USER = ServiceUser(id=USER_ID, name="Test User", email="test.user@unit.test")
4547

4648

47-
def _test_workspace(ws_id: UUID, name: str) -> Workspace:
49+
def _test_workspace(ws_id: UUID, name: str, bounding_box: BoundingBox | None = None) -> Workspace:
4850
"""Factory method to create test workspace objects."""
4951
return Workspace(
5052
id=ws_id,
@@ -57,6 +59,7 @@ def _test_workspace(ws_id: UUID, name: str) -> Workspace:
5759
created_by=TEST_USER,
5860
updated_at=utc_datetime(2020, 1, 1),
5961
updated_by=TEST_USER,
62+
bounding_box=bounding_box,
6063
)
6164

6265

@@ -116,6 +119,23 @@ def _test_instance_user_invitation(
116119
TEST_WORKSPACE_A = _test_workspace(UUID(int=0xA), "Test Workspace A")
117120
TEST_WORKSPACE_B = _test_workspace(UUID(int=0xB), "Test Workspace B")
118121
TEST_WORKSPACE_C = _test_workspace(UUID(int=0xC), "Test Workspace C")
122+
TEST_WORKSPACE_D = _test_workspace(
123+
UUID(int=0xD),
124+
"Test Workspace D",
125+
bounding_box=BoundingBox(
126+
coordinates=[
127+
[
128+
Coordinate(longitude=100, latitude=0),
129+
Coordinate(longitude=101, latitude=0),
130+
Coordinate(longitude=101, latitude=1),
131+
Coordinate(longitude=100, latitude=1),
132+
Coordinate(longitude=100, latitude=0),
133+
]
134+
],
135+
type="Polygon",
136+
),
137+
)
138+
119139
TEST_BASIC_WORKSPACE_A = _test_basic_workspace(UUID(int=0xA), "Test Workspace A")
120140
TEST_BASIC_WORKSPACE_B = _test_basic_workspace(UUID(int=0xB), "Test Workspace B")
121141
TEST_BASIC_WORKSPACE_C = _test_basic_workspace(UUID(int=0xC), "Test Workspace C")
@@ -204,6 +224,33 @@ async def test_create_workspace(self):
204224
)
205225
self.assertEqual(TEST_WORKSPACE_A, new_workspace)
206226

227+
async def test_create_workspace_with_bounding_box(self):
228+
with self.transport.set_http_response(201, json.dumps(load_test_data("new_workspace_with_bounding_box.json"))):
229+
new_workspace = await self.workspace_client.create_workspace(
230+
name="Test Workspace",
231+
description="test workspace",
232+
bounding_box_coordinates=[(100, 0), (101, 0), (101, 1), (100, 1), (100, 0)],
233+
)
234+
self.assert_request_made(
235+
method=RequestMethod.POST,
236+
path=f"{BASE_PATH}/workspaces",
237+
headers={
238+
"Accept": "application/json",
239+
"Content-Type": "application/json",
240+
},
241+
body={
242+
"bounding_box": {
243+
"coordinates": [[[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]]],
244+
"type": "Polygon",
245+
},
246+
"default_coordinate_system": "",
247+
"description": "test workspace",
248+
"labels": None,
249+
"name": "Test Workspace",
250+
},
251+
)
252+
self.assertEqual(TEST_WORKSPACE_D, new_workspace)
253+
207254
async def test_update_workspace(self):
208255
with self.transport.set_http_response(200, json.dumps(load_test_data("new_workspace.json"))):
209256
updated_workspace = await self.workspace_client.update_workspace(

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)