Skip to content

Commit

Permalink
updated test model
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvlaminck committed Dec 19, 2024
1 parent cda3da4 commit ce8d220
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
11 changes: 5 additions & 6 deletions UnitTests/TestModel/OtlmowModel/BaseClasses/WKTField.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import warnings
from typing import Any

from otlmow_model.OtlmowModel.BaseClasses.OTLField import OTLField
from otlmow_model.OtlmowModel.BaseClasses.StringField import StringField
from otlmow_model.OtlmowModel.BaseClasses.WKTValidator import WKTValidator
from otlmow_model.OtlmowModel.Exceptions.WrongGeometryWarning import WrongGeometryWarning
from otlmow_model.OtlmowModel.Exceptions.WrongGeometryTypeError import WrongGeometryTypeError


class WKTField(StringField):
Expand All @@ -17,9 +16,9 @@ class WKTField(StringField):

@classmethod
def convert_to_correct_type(cls, value: str, log_warnings: bool = True) -> str:
value = (value.replace(' Z(', ' Z (').replace('T(', 'T (')
.replace('G(', 'G (').replace('N(', 'N ('))
return value
return (value.replace(' Z(', ' Z (').replace('T(', 'T (')
.replace('G(', 'G (').replace('N(', 'N ('))


@classmethod
def validate(cls, value: Any, attribuut) -> bool:
Expand All @@ -34,7 +33,7 @@ def validate(cls, value: Any, attribuut) -> bool:
verkorte_uri = attribuut.owner.typeURI.split('#')[1]
error_msg = f"Asset type {verkorte_uri} shouldn't be assigned a {geo_type} as geometry, " \
f"valid types are {expected_types}"
warnings.warn(message=error_msg, category=WrongGeometryWarning)
raise WrongGeometryTypeError(error_msg)
return True

def __str__(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class WrongGeometryTypeError(Exception):
pass
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
import warnings


class WrongGeometryWarning(Warning):
pass
def __init__(self, message: str = ''):
self.message = message
warnings.warn('WrongGeometryWarning is now deprecated and replaced by an error', DeprecationWarning)

0 comments on commit ce8d220

Please sign in to comment.