Skip to content
Snippets Groups Projects
Commit f782f261 authored by Ruben Heinrich's avatar Ruben Heinrich
Browse files

[tests] Deleted unused tests, altered to fit new devtools::check() workflow

parent c262c4c6
No related branches found
No related tags found
1 merge request!2Basic import and export functionality
......@@ -150,7 +150,7 @@ test_that("to_node works for classes that have attributes", {
reltols = "5e-8 1e10 1e10"
),
time_discretization = list(type = "BackwardEuler"),
time_stepping = list(
time_stepping = r2ogs6_time_stepping(
type = "FixedTimeStepping",
t_initial = 0,
t_end = 100,
......
......@@ -16,6 +16,13 @@ test_that("read_in works for process objects", {
"/OpenGeoSysProject/processes/process")
expect_equal(length(ogs6_obj$processes), 1)
process <- ogs6_obj$processes[[1]]
expect_equal(process$name, "HM")
expect_equal(process$type, "HYDRO_MECHANICS")
expect_equal(process$integration_order, 3)
expect_equal(length(process$process_variables), 2)
})
......@@ -55,6 +62,9 @@ test_that("read_in works for time_loop objects", {
"/OpenGeoSysProject/time_loop")
expect_equal(is.null(ogs6_obj$time_loop), FALSE)
expect_equal(ogs6_obj$time_loop$output$type, "VTK")
expect_equal(names(ogs6_obj$time_loop$output$timesteps), c("pair"))
expect_equal(ogs6_obj$time_loop$output$timesteps[[1]][["repeat"]], 1)
})
......
......@@ -7,7 +7,7 @@
# })
test_that("guess_structure works", {
test_that("guess_structure works for simple r2ogs6 classes", {
prj_path <- (system.file("extdata/flow_free_expansion",
"flow_free_expansion.prj", package = "r2ogs6"))
......@@ -27,52 +27,13 @@ test_that("guess_structure works", {
})
test_that("is_het_wrapper works", {
ogs6_obj <- OGS6$new(sim_name = "sim",
sim_id = 1,
sim_path = "sim_path",
ogs_bin_path = "ogs_bin_path",
test_mode = TRUE)
xml_doc <- xml2::read_xml(system.file("extdata/flow_free_expansion",
"flow_free_expansion.prj", package = "r2ogs6"))
time_stepping_node <- xml2::xml_find_first(xml_doc, "//time_stepping")
expect_equal(is_het_wrapper(time_stepping_node), TRUE)
})
test_that("guess_structure works for simple lists", {
my_xml <- xml2::read_xml("<a><b>1</b><b>2</b></a>")
my_node <- xml2::xml_find_first(my_xml, "/a")
test_that("get_grandchild_length_vector works", {
xml_doc <- xml2::read_xml("<a><b><c>1.1</c></b><b><c>2.1</c><c>2.2</c></b></a>")
expect_equal(get_grandchild_length_vector(xml_doc), c(1, 2))
my_list <- guess_structure(my_xml, "/a")
expect_equal(my_list, list(b = "1", b = "2"))
})
test_that("list_from_nodeset works", {
xml_doc_1 <- xml2::read_xml("<a><b>1</b><b>2</b><b>3</b></a>")
xml_nodeset_1 <- xml2::xml_children(xml_doc_1)
xml_doc_2 <- xml2::read_xml("<a><b id=\"1\" name=\"first\"/><b id=\"2\" name=\"second\"/></a>")
xml_nodeset_2 <- xml2::xml_children(xml_doc_2)
expect_equal(list_from_nodeset(xml_nodeset_1), list(b = "1", b = "2", b = "3"))
expect_equal(list_from_nodeset(xml_nodeset_2), list(b = c(id = "1", name = "first"),
b = c(id = "2", name = "second")))
})
test_that("find_read_in_func_call works", {
node_name_1 <- "Mamma mia"
node_name_2 <- "timesteps"
expect_equal(find_read_in_func_call(node_name_1), "")
expect_equal(find_read_in_func_call(node_name_2), "read_in_timesteps_node(xml_node)")
})
\ No newline at end of file
......@@ -10,10 +10,15 @@
# })
test_that("download_benchmark works", {
path <- system.file("extdata/benchmarks/", package = "r2ogs6")
# Get extdata directory and create folder for the test
extdata_path <- system.file("extdata/", package = "r2ogs6")
path <- paste0(extdata_path, "/dl_benchmark_test")
dir.create(path)
download_benchmark(
prj_url = paste0("https://gitlab.opengeosys.org/ogs/ogs/-/raw/master/",
......@@ -22,6 +27,10 @@ test_that("download_benchmark works", {
path = path)
expect_equal(file.exists(paste0(path, "/flow_no_strain.prj")), TRUE)
expect_equal(file.exists(paste0(path, "/square_1x1.gml")), TRUE)
expect_equal(file.exists(paste0(path, "/square_1x1_quad8_1e2.vtu")), TRUE)
# Tidy up by deleting the folder we created
do.call(file.remove, list(list.files(path, full.names = TRUE)))
})
\ No newline at end of file
unlink(path, recursive = TRUE)
})
# This test may fail on your machine because ogs_bin_path is system dependent.
# Before you run it, alter ogs_bin_path to fit your system!
# test_that("run_simulation works", {
#
# ogs_bin_path <- paste0("D:\\Programme\\OpenGeoSys\\",
# "ogs-6.3.2-Windows-10.0.14393-x64-python-3.7.2","
# -de-utils\\bin\\")
#
# sim_path <- system.file("extdata/test_sim/", package = "r2ogs6")
# sim_path <- validate_is_dir_path(sim_path)
#
# # Define OGS6 object
# ogs6_obj <- OGS6$new(sim_name = "sim",
# sim_id = 1,
# sim_path = simdir_path,
# ogs_bin_path = ogs_bin_path)
#
# # Define path to .prj file
# prj_path <- (system.file("extdata/flow_free_expansion",
# "flow_free_expansion.prj", package = "r2ogs6"))
#
#
# # Read in .prj data
# read_in_prj(ogs6_obj, prj_path)
#
# # Run simulation
# run_simulation(ogs6_obj)
#
# # Check if output file was written
# expect_equal(file.exists(paste0(sim_path, "flow_no_strain.prj")), TRUE)
#
# # Check if log file was written
# expect_equal(file.exists(paste0(sim_path, "sim_log.txt")), TRUE)
#
# # Clean up folder
# do.call(file.remove, list(list.files(sim_path, full.names = TRUE)))
# })
......@@ -32,3 +32,20 @@ test_that("select_fitting_subclass works for linear_solver objects", {
expect_equal(subclass_name, "r2ogs6_eigen")
})
#===== General validation =====
test_that("validate_is_dir_path works", {
path <- "test/path"
path_2 <- "test\\path\\"
path <- validate_is_dir_path(path)
path_2 <- validate_is_dir_path(path_2)
expect_equal(path, "test/path/")
expect_equal(path_2, "test\\path\\")
})
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