|
| 1 | +using JSON |
| 2 | + |
1 | 3 | @testset "test matpower parser" begin
|
2 | 4 | @testset "30-bus case file" begin
|
3 | 5 | result = run_opf("../test/data/case30.m", ACPPowerModel, ipopt_solver)
|
|
8 | 10 |
|
9 | 11 | @testset "30-bus case matpower data" begin
|
10 | 12 | data = PowerModels.parse_file("../test/data/case30.m")
|
| 13 | + @test isa(JSON.json(data), String) |
| 14 | + |
11 | 15 | result = run_opf(data, ACPPowerModel, ipopt_solver)
|
12 | 16 |
|
13 | 17 | @test result["status"] == :LocalOptimal
|
|
17 | 21 | @testset "14-bus case file with names" begin
|
18 | 22 | data = PowerModels.parse_file("../test/data/case14.m")
|
19 | 23 | @test data["bus"][1]["bus_name"] == "Bus 1 HV"
|
| 24 | + @test isa(JSON.json(data), String) |
20 | 25 | end
|
21 | 26 |
|
22 | 27 | @testset "2-bus case file with spaces" begin
|
|
56 | 61 | @test data["const_int"] == 123
|
57 | 62 | @test data["const_float"] == 4.56
|
58 | 63 | @test data["const_str"] == "a string"
|
| 64 | + @test isa(JSON.json(data), String) |
59 | 65 | end
|
60 | 66 |
|
61 | 67 | @testset "3-bus extended matrix" begin
|
|
66 | 72 | @test data["areas"][1]["col_2"] == 1
|
67 | 73 | @test data["areas"][2]["col_1"] == 2
|
68 | 74 | @test data["areas"][2]["col_2"] == 3
|
| 75 | + @test isa(JSON.json(data), String) |
69 | 76 | end
|
70 | 77 |
|
71 | 78 | @testset "3-bus extended named matrix" begin
|
|
76 | 83 | @test data["areas_named"][1]["refbus"] == 5
|
77 | 84 | @test data["areas_named"][2]["area"] == 5
|
78 | 85 | @test data["areas_named"][2]["refbus"] == 6
|
| 86 | + @test isa(JSON.json(data), String) |
79 | 87 | end
|
80 | 88 |
|
81 | 89 | @testset "3-bus extended predefined matrix" begin
|
|
88 | 96 | @test data["branch"][2]["rate_p"] == 60.1
|
89 | 97 | @test data["branch"][3]["rate_i"] == 12
|
90 | 98 | @test data["branch"][3]["rate_p"] == 30
|
| 99 | + @test isa(JSON.json(data), String) |
91 | 100 | end
|
92 | 101 |
|
93 | 102 |
|
|
103 | 112 | @test data["areas_cells"][2]["col_2"] == 456
|
104 | 113 | @test data["areas_cells"][2]["col_4"] == "Slack Bus 3"
|
105 | 114 | @test data["areas_cells"][2]["col_5"] == 4.56
|
| 115 | + @test isa(JSON.json(data), String) |
106 | 116 | end
|
107 | 117 |
|
108 | 118 | @testset "3-bus extended named matrix from cell" begin
|
|
119 | 129 | @test data["areas_named_cells"][2]["area2"] == 987
|
120 | 130 | @test data["areas_named_cells"][2]["refbus_name"] == "Slack Bus 3"
|
121 | 131 | @test data["areas_named_cells"][2]["refbus"] == 4.56
|
| 132 | + @test isa(JSON.json(data), String) |
122 | 133 | end
|
123 | 134 |
|
124 | 135 | @testset "3-bus extended predefined matrix from cell" begin
|
|
131 | 142 | @test data["branch"][2]["number_id"] == 456
|
132 | 143 | @test data["branch"][3]["name"] == "Branch 3"
|
133 | 144 | @test data["branch"][3]["number_id"] == 789
|
| 145 | + @test isa(JSON.json(data), String) |
| 146 | + end |
| 147 | + |
| 148 | + @testset "3-bus tnep case" begin |
| 149 | + data = PowerModels.parse_file("../test/data/case3_tnep.m") |
| 150 | + |
| 151 | + @test haskey(data, "ne_branch") |
| 152 | + @test data["ne_branch"][1]["f_bus"] == 1 |
| 153 | + @test data["ne_branch"][1]["construction_cost"] == 1 |
| 154 | + @test isa(JSON.json(data), String) |
134 | 155 | end
|
135 | 156 | end
|
136 | 157 |
|
0 commit comments