Skip to content

Commit 02aa062

Browse files
committed
Moving tests to own file
1 parent 56621a9 commit 02aa062

3 files changed

Lines changed: 69 additions & 61 deletions

File tree

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ global_logger(logger_new)
4141

4242
# Test specific GUI functionalities related to interactivity
4343
include("test_interactivity.jl")
44+
45+
# Test descriptive names functionalities
46+
include("test_descriptive_names.jl")
4447
end
4548
end
4649
global_logger(logger_org)

test/test_descriptive_names.jl

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
case, model, m, gui = run_case()
2+
3+
# Test specific miscellaneous descriptive names
4+
@testset "Test descriptive names" verbose = true begin
5+
6+
@testset "Test customizing descriptive names" begin
7+
path_to_descriptive_names = joinpath(pkgdir(EMGUI), "src", "descriptive_names.yml")
8+
str1 = "<a test description 1>"
9+
str2 = "<a test description 2>"
10+
str3 = "<a test description 3>"
11+
str4 = "<a test description 4>"
12+
str5 = "<a test description 5>"
13+
str6 = "<a test description 6>"
14+
descriptive_names_dict = Dict(
15+
:structures => Dict( # Input parameter from the case Dict
16+
:RefStatic => Dict(:trans_cap => str1, :opex_fixed => str2),
17+
:RefDynamic => Dict(:opex_var => str3, :directions => str4),
18+
),
19+
:variables => Dict( # variables from the JuMP model
20+
:stor_discharge_use => str5,
21+
:trans_cap_rem => str6,
22+
),
23+
)
24+
gui2 = GUI(
25+
case;
26+
path_to_descriptive_names = path_to_descriptive_names,
27+
descriptive_names_dict = descriptive_names_dict,
28+
)
29+
descriptive_names = EMGUI.get_var(gui2, :descriptive_names)
30+
@test descriptive_names[:structures][:RefStatic][:trans_cap] == str1
31+
@test descriptive_names[:structures][:RefStatic][:opex_fixed] == str2
32+
@test descriptive_names[:structures][:RefDynamic][:opex_var] == str3
33+
@test descriptive_names[:structures][:RefDynamic][:directions] == str4
34+
@test descriptive_names[:variables][:stor_discharge_use] == str5
35+
@test descriptive_names[:variables][:trans_cap_rem] == str6
36+
EMGUI.close(gui2)
37+
end
38+
39+
@testset "Test inheritance of descriptive names" begin
40+
path_to_descriptive_names = joinpath(pkgdir(EMGUI), "src", "descriptive_names.yml")
41+
descriptive_names_raw =
42+
YAML.load_file(path_to_descriptive_names; dicttype = Dict{Symbol,Any})
43+
str1 = "Relative fixed operating expense per installed capacity"
44+
str2 = "Initial stored energy in the dam"
45+
gui3 = GUI(
46+
case;
47+
path_to_descriptive_names = path_to_descriptive_names,
48+
)
49+
50+
@test descriptive_names_raw[:structures][:Node][:opex_fixed] == str1
51+
@test :StorCapOpexFixed keys(descriptive_names_raw[:structures])
52+
@test :RefNetworkNode keys(descriptive_names_raw[:structures])
53+
54+
@test descriptive_names_raw[:structures][:HydroStorage][:level_init] == str2
55+
@test :HydroStor keys(descriptive_names_raw[:structures])
56+
@test :PumpedHydroStor keys(descriptive_names_raw[:structures])
57+
58+
descriptive_names = EMGUI.get_var(gui3, :descriptive_names)
59+
@test descriptive_names[:structures][:StorCapOpexFixed][:opex_fixed] == str1
60+
@test descriptive_names[:structures][:RefNetworkNode][:opex_fixed] == str1
61+
62+
@test descriptive_names[:structures][:HydroStor][:level_init] == str2
63+
@test descriptive_names[:structures][:PumpedHydroStor][:level_init] == str2
64+
EMGUI.close(gui3)
65+
end
66+
end

test/test_interactivity.jl

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -59,67 +59,6 @@ pin_plot_button = get_button(gui, :pin_plot)
5959
system = EMGUI.parse_case(case)
6060
@test Base.show(system) == dump(system; maxdepth = 1)
6161
end
62-
63-
@testset "Test customizing descriptive names" begin
64-
path_to_descriptive_names = joinpath(pkgdir(EMGUI), "src", "descriptive_names.yml")
65-
str1 = "<a test description 1>"
66-
str2 = "<a test description 2>"
67-
str3 = "<a test description 3>"
68-
str4 = "<a test description 4>"
69-
str5 = "<a test description 5>"
70-
str6 = "<a test description 6>"
71-
descriptive_names_dict = Dict(
72-
:structures => Dict( # Input parameter from the case Dict
73-
:RefStatic => Dict(:trans_cap => str1, :opex_fixed => str2),
74-
:RefDynamic => Dict(:opex_var => str3, :directions => str4),
75-
),
76-
:variables => Dict( # variables from the JuMP model
77-
:stor_discharge_use => str5,
78-
:trans_cap_rem => str6,
79-
),
80-
)
81-
gui2 = GUI(
82-
case;
83-
path_to_descriptive_names = path_to_descriptive_names,
84-
descriptive_names_dict = descriptive_names_dict,
85-
)
86-
descriptive_names = EMGUI.get_var(gui2, :descriptive_names)
87-
@test descriptive_names[:structures][:RefStatic][:trans_cap] == str1
88-
@test descriptive_names[:structures][:RefStatic][:opex_fixed] == str2
89-
@test descriptive_names[:structures][:RefDynamic][:opex_var] == str3
90-
@test descriptive_names[:structures][:RefDynamic][:directions] == str4
91-
@test descriptive_names[:variables][:stor_discharge_use] == str5
92-
@test descriptive_names[:variables][:trans_cap_rem] == str6
93-
EMGUI.close(gui2)
94-
end
95-
96-
@testset "Test inheritance of descriptive names" begin
97-
path_to_descriptive_names = joinpath(pkgdir(EMGUI), "src", "descriptive_names.yml")
98-
descriptive_names_raw =
99-
YAML.load_file(path_to_descriptive_names; dicttype = Dict{Symbol,Any})
100-
str1 = "Relative fixed operating expense per installed capacity"
101-
str2 = "Initial stored energy in the dam"
102-
gui3 = GUI(
103-
case;
104-
path_to_descriptive_names = path_to_descriptive_names,
105-
)
106-
107-
@test descriptive_names_raw[:structures][:Node][:opex_fixed] == str1
108-
@test :StorCapOpexFixed keys(descriptive_names_raw[:structures])
109-
@test :RefNetworkNode keys(descriptive_names_raw[:structures])
110-
111-
@test descriptive_names_raw[:structures][:HydroStorage][:level_init] == str2
112-
@test :HydroStor keys(descriptive_names_raw[:structures])
113-
@test :PumpedHydroStor keys(descriptive_names_raw[:structures])
114-
115-
descriptive_names = EMGUI.get_var(gui3, :descriptive_names)
116-
@test descriptive_names[:structures][:StorCapOpexFixed][:opex_fixed] == str1
117-
@test descriptive_names[:structures][:RefNetworkNode][:opex_fixed] == str1
118-
119-
@test descriptive_names[:structures][:HydroStor][:level_init] == str2
120-
@test descriptive_names[:structures][:PumpedHydroStor][:level_init] == str2
121-
EMGUI.close(gui3)
122-
end
12362
end
12463

12564
# Test specific GUI functionalities

0 commit comments

Comments
 (0)