Skip to content

Commit

Permalink
Adapt tests to allow for tabulated yz shapes without friction value a…
Browse files Browse the repository at this point in the history
…nd catch tabulated yz shapes with neither friction value or friction values defined
  • Loading branch information
margrietpalm committed Jan 22, 2024
1 parent d44bbe4 commit 70f9393
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions threedi_modelchecker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@ def is_none_or_empty(col):
CHECKS: List[BaseCheck] = []

## 002x: FRICTION
## Use same error code as other null checks
CHECKS += [
QueryCheck(
error_code=3,
column=models.CrossSectionLocation.friction_value,
invalid=(
Query(models.CrossSectionLocation)
.join(
models.CrossSectionDefinition,
models.CrossSectionLocation.definition_id
== models.CrossSectionDefinition.id,
)
.filter(
models.CrossSectionDefinition.shape
!= constants.CrossSectionShape.TABULATED_YZ
)
.filter(models.CrossSectionLocation.friction_value == None)
),
message=f"{models.CrossSectionLocation.friction_value.name} cannot be null or empty",
)
]
CHECKS += [
RangeCheck(
error_code=21,
Expand Down Expand Up @@ -532,7 +553,30 @@ def is_none_or_empty(col):
]

## 008x: CROSS SECTION DEFINITIONS

CHECKS += [
QueryCheck(
error_code=80,
column=models.CrossSectionLocation.friction_value,
invalid=(
Query(models.CrossSectionDefinition)
.filter(
models.CrossSectionDefinition.shape
== constants.CrossSectionShape.TABULATED_YZ
)
.join(
models.CrossSectionLocation,
models.CrossSectionLocation.definition_id
== models.CrossSectionDefinition.id,
)
.filter(models.CrossSectionLocation.friction_value == None)
.filter(
(models.CrossSectionDefinition.friction_values == None)
| (models.CrossSectionDefinition.friction_values == "")
)
),
message="Either friction value or friction values must be defined for a TABULATED YZ shape",
)
]
CHECKS += [
CrossSectionNullCheck(
error_code=81,
Expand Down Expand Up @@ -2770,6 +2814,8 @@ def is_none_or_empty(col):
)
]

# TODO: reconsider number because 01xx exists!
# TODO add friction value / friction_values check here
## 018x cross section parameters (continues 008x)
veg_par_cols = [
models.CrossSectionDefinition.vegetation_drag_coefficients,
Expand Down Expand Up @@ -2810,7 +2856,7 @@ def is_none_or_empty(col):
]
CHECKS += [
QueryCheck(
error_code=188,
error_code=182,
level=CheckLevel.WARNING,
column=col_csloc,
invalid=Query(models.CrossSectionDefinition)
Expand Down Expand Up @@ -2848,7 +2894,7 @@ def is_none_or_empty(col):
]
CHECKS += [
QueryCheck(
error_code=188,
error_code=182,
level=CheckLevel.WARNING,
column=col_csloc,
invalid=Query(models.CrossSectionDefinition)
Expand Down

0 comments on commit 70f9393

Please sign in to comment.