Skip to content

Commit 769da66

Browse files
adjust tests
1 parent 40f799b commit 769da66

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

geoengine/colorizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def to_api_dict(self) -> geoengine_openapi_client.Colorizer:
309309
"""Return the colorizer as a dictionary."""
310310
return geoengine_openapi_client.Colorizer(geoengine_openapi_client.PaletteColorizer(
311311
type='palette',
312-
colors=self.colors,
312+
colors={str(k): v for k,v in self.colors.items()},
313313
default_color=self.default_color,
314314
no_data_color=self.no_data_color,
315315
))

geoengine/datasets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,11 @@ def upload_dataframe(
494494
),
495495
on_error=on_error.to_api_enum(),
496496
),
497-
result_descriptor=VectorResultDescriptor(
497+
result_descriptor=geoengine_openapi_client.VectorResultDescriptor.from_dict(VectorResultDescriptor(
498498
data_type=vector_type,
499499
spatial_reference=df.crs.to_string(),
500500
columns=columns,
501-
).to_api_dict().actual_instance
501+
).to_api_dict().actual_instance.to_dict())
502502
)
503503
)
504504
)

geoengine/workflow.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,13 @@ def save_as_dataset(
535535

536536
session = get_session()
537537

538+
print(geoengine_openapi_client.RasterDatasetFromWorkflow(
539+
name=name,
540+
display_name=display_name,
541+
description=description,
542+
query=query_rectangle
543+
).to_json())
544+
538545
with geoengine_openapi_client.ApiClient(session.configuration) as api_client:
539546
workflows_api = geoengine_openapi_client.WorkflowsApi(api_client)
540547
response = workflows_api.dataset_from_workflow_handler(
@@ -984,8 +991,9 @@ def data_usage(offset: int = 0, limit: int = 10) -> List[geoengine_openapi_clien
984991
response = user_api.data_usage_handler(offset=offset, limit=limit)
985992

986993
# create dataframe from response
987-
usage_dicts = [data_usage.dict(by_alias=True) for data_usage in response]
994+
usage_dicts = [data_usage.model_dump(by_alias=True) for data_usage in response]
988995
df = pd.DataFrame(usage_dicts)
996+
df['timestamp'] = pd.to_datetime(df['timestamp'], utc=True)
989997

990998
return df
991999

@@ -1005,7 +1013,8 @@ def data_usage_summary(granularity: geoengine_openapi_client.UsageSummaryGranula
10051013
offset=offset, limit=limit)
10061014

10071015
# create dataframe from response
1008-
usage_dicts = [data_usage.dict(by_alias=True) for data_usage in response]
1016+
usage_dicts = [data_usage.model_dump(by_alias=True) for data_usage in response]
10091017
df = pd.DataFrame(usage_dicts)
1018+
df['timestamp'] = pd.to_datetime(df['timestamp'], utc=True)
10101019

10111020
return df

tests/ge_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def _start(self) -> None:
201201
'GEOENGINE__POSTGRES__PASSWORD': POSTGRES_PASSWORD,
202202
'GEOENGINE__POSTGRES__SCHEMA': self.db_schema,
203203
'GEOENGINE__LOGGING__LOG_SPEC': GE_LOG_SPEC,
204+
'GEOENGINE__POSTGRES__CLEAR_DATABASE_ON_START': 'true',
204205
'PATH': os.environ['PATH'],
205206
},
206207
stderr=subprocess.PIPE,

tests/test_workflow_storage.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,29 @@ def setUp(self) -> None:
1717
def test_storing_workflow(self):
1818

1919
expected_request_text = {
20-
'name': None,
21-
'displayName': 'Foo',
22-
'description': 'Bar',
23-
'query': {
24-
'spatialBounds': {
25-
'upperLeftCoordinate': {
26-
'x': -180.0,
27-
'y': 90.0
28-
},
29-
'lowerRightCoordinate': {
30-
'x': 180.0,
31-
'y': -90.0
32-
}
33-
},
34-
'timeInterval': {
35-
'start': 1396353600000,
36-
'end': 1396353600000,
37-
},
38-
'spatialResolution': {
39-
'x': 1.8,
40-
'y': 1.8
41-
}
20+
"asCog": True,
21+
"description": "Bar",
22+
"displayName": "Foo",
23+
"name": None,
24+
"query": {
25+
"spatialBounds": {
26+
"lowerRightCoordinate": {
27+
"x": 180,
28+
"y": -90
29+
},
30+
"upperLeftCoordinate": {
31+
"x": -180,
32+
"y": 90
33+
}
34+
},
35+
"spatialResolution": {
36+
"x": 1.8,
37+
"y": 1.8
38+
},
39+
"timeInterval": {
40+
"end": 1396353600000,
41+
"start": 1396353600000
42+
}
4243
}
4344
}
4445

0 commit comments

Comments
 (0)