From e50a9914c0846323265bcc3d4f72cc1141b504b5 Mon Sep 17 00:00:00 2001 From: Lauren Clisby Date: Wed, 18 Oct 2023 13:51:32 +0200 Subject: [PATCH 1/2] Added new test to achieve full coverage --- test/runtests.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 25eaec69..e541b56f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -51,6 +51,7 @@ end df = CSV.read(joinpath(dir, "bad-assets-data.csv"), DataFrame; header = 2) # FIXME: instead of examples, mutate and test + # Example 1 - bad data, silent col_err, col_type_err = TulipaEnergyModel.validate_df( df, TulipaEnergyModel.AssetData; @@ -60,5 +61,13 @@ end @test col_err == [:id] @test col_type_err == [(:investable, Bool, String7), (:peak_demand, Float64, String7)] + + # Example 2 - bad data, verbose + expected_error_message = "bad-assets-data.csv failed validation\n [1] missing columns: [:id]\n [2] incompatible column types:\n - investable::String7 (expected: Bool)\n - peak_demand::String7 (expected: Float64)" + @test_throws expected_error_message TulipaEnergyModel.validate_df( + df, + TulipaEnergyModel.AssetData; + fname = "bad-assets-data.csv", + ) end end From 23ad125fd0a1831e406f2a5316663d334d8e2545 Mon Sep 17 00:00:00 2001 From: Lauren Clisby Date: Wed, 18 Oct 2023 14:14:57 +0200 Subject: [PATCH 2/2] Rewrote test to be compatible with Julia 1.6 --- test/runtests.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index e541b56f..7f17b72a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -63,8 +63,7 @@ end [(:investable, Bool, String7), (:peak_demand, Float64, String7)] # Example 2 - bad data, verbose - expected_error_message = "bad-assets-data.csv failed validation\n [1] missing columns: [:id]\n [2] incompatible column types:\n - investable::String7 (expected: Bool)\n - peak_demand::String7 (expected: Float64)" - @test_throws expected_error_message TulipaEnergyModel.validate_df( + @test_throws ErrorException TulipaEnergyModel.validate_df( df, TulipaEnergyModel.AssetData; fname = "bad-assets-data.csv",