Skip to content

Commit

Permalink
Merge pull request #12 from psrenergy/feature/tests
Browse files Browse the repository at this point in the history
Tests updates
  • Loading branch information
raphasampaio authored Nov 23, 2023
2 parents 0d46b45 + ce9d24c commit 75d97a0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ docs/site/
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml

*.csv
4 changes: 4 additions & 0 deletions test/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
example_2.csv
example_array_1.csv
example_convert_1.csv
gerter.csv
8 changes: 4 additions & 4 deletions test/read_and_write_hourly.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function read_write_csv_hourly()
FILE_GERTER = joinpath(".", "gerter")
function test_read_and_write_hourly()
FILE_GERTER = joinpath(".", "data", "gerter")

STAGES = 3
SCENARIOS = 2
Expand Down Expand Up @@ -89,6 +89,6 @@ function read_write_csv_hourly()
rm(FILE_GERTER * ".csv")
catch
end
end

read_write_csv_hourly()
return nothing
end
7 changes: 4 additions & 3 deletions test/read_and_write_monthly.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function read_write_csv_test()
FILE_PATH = joinpath(".", "example_2")
function test_read_and_write_monthly()
FILE_PATH = joinpath(".", "data", "example_2")

STAGES = 12
BLOCKS = 3
Expand Down Expand Up @@ -95,5 +95,6 @@ function read_write_csv_test()
catch
println("Failed to delete: $FILE_PATH")
end

return nothing
end
read_write_csv_test()
20 changes: 10 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ using Test

const PSRI = GrafCSV.PSRClassesInterface

@testset "GrafCSV file format" begin
@testset "Read and write with monthlydata" begin
include("read_and_write_monthly.jl")
end
@testset "Read and write with hourlydata" begin
include("read_and_write_hourly.jl")
end
@testset "Utils" begin
include("time_series_utils.jl")
end
include("read_and_write_monthly.jl")
include("read_and_write_hourly.jl")
include("time_series_utils.jl")

function test_all()
@testset "Read and write with monthly data" begin test_read_and_write_monthly() end
@testset "Read and write with hourly data" begin test_read_and_write_hourly() end
@testset "Utils" begin test_time_series_utils() end
end

test_all()
23 changes: 12 additions & 11 deletions test/time_series_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function rm_bin_hdr(file::String)
end

function test_non_unique_agents()
FILE_PATH = joinpath(".", "example_non_unique_agents")
FILE_PATH = joinpath(".", "data", "example_non_unique_agents")
@test_throws ErrorException iow = PSRI.open(
GrafCSV.Writer,
FILE_PATH,
Expand All @@ -20,14 +20,12 @@ function test_non_unique_agents()
)
end

test_non_unique_agents()

function test_convert_twice()
BLOCKS = 3
SCENARIOS = 10
STAGES = 12

FILE_PATH = joinpath(".", "example_convert_1")
FILE_PATH = joinpath(".", "data", "example_convert_1")
iow = PSRI.open(
PSRI.OpenBinary.Writer,
FILE_PATH,
Expand Down Expand Up @@ -103,7 +101,7 @@ function test_convert_twice()
PSRI.close(ior)
ior = nothing

FILE_PATH_2 = joinpath(".", "example_convert_2")
FILE_PATH_2 = joinpath(".", "data", "example_convert_2")

PSRI.convert_file(
GrafCSV.Reader,
Expand Down Expand Up @@ -157,17 +155,15 @@ function test_convert_twice()
println("Failed to remove $(FILE_PATH).csv")
end

return
return nothing
end

test_convert_twice()

function test_file_to_array()
BLOCKS = 3
SCENARIOS = 10
STAGES = 12

FILE_PATH = joinpath(".", "example_array_1")
FILE_PATH = joinpath(".", "data", "example_array_1")
iow = PSRI.open(
PSRI.OpenBinary.Writer,
FILE_PATH,
Expand Down Expand Up @@ -282,7 +278,12 @@ function test_file_to_array()
println("Failed to remove $(FILE_PATH).csv")
end

return
return nothing
end

test_file_to_array()
function test_time_series_utils()
test_non_unique_agents()
test_convert_twice()
test_file_to_array()
return nothing
end

0 comments on commit 75d97a0

Please sign in to comment.