Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCore-Python-Common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSCore-Python-Common
Commits
36b1e767
Commit
36b1e767
authored
2 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
CamelCasing when deserializing Result objects
parent
ad51c615
No related branches found
No related tags found
No related merge requests found
Pipeline
#729
failed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/vipscore_common/entities.py
+10
-5
10 additions, 5 deletions
src/vipscore_common/entities.py
tests/test_entities.py
+15
-0
15 additions, 0 deletions
tests/test_entities.py
with
25 additions
and
5 deletions
src/vipscore_common/entities.py
+
10
−
5
View file @
36b1e767
...
...
@@ -25,18 +25,23 @@ along with VIPSCore-Python-Common. If not, see <http://www.nibio.no/licenses/>.
from
datetime
import
datetime
from
shapely.geometry
import
Point
,
Polygon
from
pydantic
import
BaseModel
,
validator
,
constr
,
Field
from
typing
import
Any
,
Union
,
ClassVar
from
typing
import
Any
,
Union
,
ClassVar
,
Optional
import
pytz
class
Result
(
BaseModel
):
"""
Represents a set of DSS model result values for a given point in space (Point, Polygon, MultiPolygon) and time (Period or immediate)
"""
valid_time_start
:
datetime
=
Field
(
alias
=
"
validTimeStart
"
)
# TODO make sure it's always timezone aware
valid_time_end
:
datetime
=
Field
(...,
alias
=
"
validTimeStart
"
)
# TODO make sure it's always timezone aware
valid_geometry
:
Any
=
Field
(
alias
=
"
validGeometry
"
)
"""
Represents a set of DSS model result values for a given point in space (Point, Polygon, MultiPolygon) and time (Period or immediate)
"""
valid_time_start
:
datetime
=
Field
(
alias
=
"
validTimeStart
"
)
valid_time_end
:
Optional
[
datetime
]
=
Field
(
alias
=
"
validTimeStart
"
)
valid_geometry
:
Optional
[
Any
]
=
Field
(
alias
=
"
validGeometry
"
)
warning_status
:
int
=
Field
(
alias
=
"
warningStatus
"
)
all_values
:
dict
=
Field
(
alias
=
"
allValues
"
)
class
Config
:
allow_population_by_field_name
=
True
WARNING_STATUS_NO_WARNING
:
ClassVar
[
int
]
=
0
WARNING_STATUS_NO_WARNING_MISSING_DATA
:
ClassVar
[
int
]
=
1
WARNING_STATUS_NO_RISK
:
ClassVar
[
int
]
=
2
...
...
This diff is collapsed.
Click to expand it.
tests/test_entities.py
0 → 100644
+
15
−
0
View file @
36b1e767
import
unittest
import
datetime
from
src.vipscore_common.entities
import
*
class
TestEntities
(
unittest
.
TestCase
):
def
test_create_result
(
self
):
r
=
Result
(
valid_time_start
=
datetime
.
fromisoformat
(
"
2015-03-01T00:00:00+01:00
"
),
# valid_time_start
valid_time_end
=
None
,
warning_status
=
2
,
all_values
=
{
"
TM
"
:
2
}
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment