Skip to content
Snippets Groups Projects
Commit 63c39670 authored by phit0's avatar phit0
Browse files

[test] Helpful error message for new xml tags

parent 8d1b6912
No related branches found
No related tags found
3 merge requests!38Draft: standardize files references during prj import/export,!35Resolve "Manual CI job to run all benchmarks",!33Resolve "Update to OGSv6.4.1"
......@@ -261,12 +261,15 @@ order_parameters <- function(parameters, class_name){
class_args <- get_class_args(class_name)
# cat("\nParameter names not in", class_name, "class arguments:")
# print(names(parameters)[!names(parameters) %in% class_args])
# logical vector of length(parameters) to exclude r2ogs6 specific parameters
standard_parameters <-
names(parameters) %in%
c("xpath", "attr_names", "flatten_on_exp", "unwrap_on_exp")
#Check for length and value mismatches if class does not have Ellipsis
if(!"..." %in% class_args){
assertthat::assert_that(length(parameters) <= length(class_args))
assertthat::assert_that(length(parameters[!standard_parameters]) <=
length(class_args))
for(i in seq_len(length(parameters))){
# cat("\n", names(parameters)[[i]], "\n")
......
......@@ -66,4 +66,19 @@ test_that("order_parameters works for classes with Ellipsis argument", {
index_values = list("1", "1 2")))
})
test_that("order_parameters throws a helpful error message for missing
class arguments", {
# e.g. a new process node in a *.prj file is found and the corresponding
# class in prj_process is missing
ogs6_process <- prj_pr_property(name = "test", # use a class that does not have "..."
type = "LIQUID_FLOW")
# replace one parameter
names(ogs6_process)[4] <- "Frodos_Ring"
expect_error(
order_parameters(parameters = ogs6_process,
class_name = "prj_pr_property"),
regexp = "Frodos_Ring not in class_args of class prj_pr_property")
}
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment