@@ -28,16 +28,16 @@ def tearDown(self):
2828 """Tear down test fixtures, if any."""
2929 #altdss.ClearAll()
3030
31- def test_00_basic (self ):
31+ def test_000_basic (self ):
3232 circuit = PyGridSim ()
3333 circuit .add_source_nodes ()
3434 circuit .add_load_nodes ()
3535 circuit .add_lines ([("source" , "load0" )])
3636 circuit .solve ()
37- print (circuit .results (["BusVMag " ]))
37+ print (circuit .results (["Voltages " ]))
3838 circuit .clear ()
3939
40- def test_01_one_source_one_load (self ):
40+ def test_001_one_source_one_load (self ):
4141 circuit = PyGridSim ()
4242 circuit .add_source_nodes (source_type = SourceType .TURBINE )
4343 circuit .add_load_nodes (num = 1 , load_type = LoadType .HOUSE )
@@ -49,7 +49,7 @@ def test_01_one_source_one_load(self):
4949 print (circuit .results (["Voltages" , "Losses" ]))
5050 circuit .clear ()
5151
52- def test_02_one_source_one_load_no_transformer (self ):
52+ def test_002_one_source_one_load_no_transformer (self ):
5353 # doesn't throw error, but should have stranger output VMag
5454 circuit = PyGridSim ()
5555 circuit .add_source_nodes (source_type = SourceType .TURBINE )
@@ -59,7 +59,7 @@ def test_02_one_source_one_load_no_transformer(self):
5959 print (circuit .results (["Voltages" , "Losses" ]))
6060 circuit .clear ()
6161
62- def test_03_one_source_one_load_exhaustive (self ):
62+ def test_003_one_source_one_load_exhaustive (self ):
6363 for line_type in LineType :
6464 for source_type in SourceType :
6565 for load_type in LoadType :
@@ -73,7 +73,7 @@ def test_03_one_source_one_load_exhaustive(self):
7373 circuit .clear ()
7474
7575
76- def test_04_one_source_multi_load (self ):
76+ def test_004_one_source_multi_load (self ):
7777 circuit = PyGridSim ()
7878 circuit .add_source_nodes (num_in_batch = 10 , source_type = SourceType .SOLAR_PANEL )
7979 circuit .add_load_nodes (num = 4 , load_type = LoadType .HOUSE )
@@ -82,15 +82,15 @@ def test_04_one_source_multi_load(self):
8282 print (circuit .results (["Voltages" ]))
8383 circuit .clear ()
8484
85- def test_05_bad_query (self ):
85+ def test_005_bad_query (self ):
8686 circuit = PyGridSim ()
8787 circuit .add_source_nodes ()
8888 circuit .add_load_nodes ()
8989 circuit .add_lines ([("source" , "load0" )])
9090 circuit .solve ()
9191 print (circuit .results (["BadQuery" ]))
9292
93- def test_06_multi_source_bad (self ):
93+ def test_006_multi_source_bad (self ):
9494 circuit = PyGridSim ()
9595 #circuit.add_source_nodes(num_in_batch=10, num=2, source_type=SourceType.SOLAR_PANEL)
9696 #circuit.add_load_nodes(num=1, load_type=LoadType.HOUSE)
@@ -106,8 +106,77 @@ class TestCustomizedCircuit(unittest.TestCase):
106106
107107 def setUp (self ):
108108 """Set up test fixtures, if any."""
109+ print ("\n Test" , self ._testMethodName )
110+
111+
112+ def tearDown (self ):
113+ """Tear down test fixtures, if any."""
109114 pass
110115
116+ def test_100_one_source_one_load (self ):
117+ circuit = PyGridSim ()
118+ circuit .add_source_nodes (params = {"kV" : 100 })
119+ circuit .add_load_nodes (num = 1 , params = {"kV" : 10 , "kW" : 20 , "kVar" :1 })
120+ circuit .add_lines ([("source" , "load0" )], params = {"length" : 20 })
121+ circuit .solve ()
122+ print (circuit .results (["Voltages" , "Losses" ]))
123+ circuit .clear ()
124+
125+ def test_100_one_source_multi_load (self ):
126+ """
127+ Creates 10 loads, some of which are connected to source. all loads and lines here have the same params
128+ """
129+ circuit = PyGridSim ()
130+ circuit .add_source_nodes (params = {"kV" : 100 })
131+ circuit .add_load_nodes (num = 10 , params = {"kV" : 10 , "kW" : 20 , "kVar" :1 })
132+ circuit .add_lines ([("source" , "load0" ), ("source" , "load4" ), ("source" , "load6" )], params = {"length" : 20 })
133+ circuit .solve ()
134+ print (circuit .results (["Voltages" , "Losses" ]))
135+ circuit .clear ()
136+
137+ def test_101_bad_parameter (self ):
138+ """
139+ Should error with a bad parameter and tell the user which parameter is bad
140+ """
141+ circuit = PyGridSim ()
142+ with self .assertRaises (KeyError ):
143+ circuit .add_source_nodes (params = {"kV" : 50 , "badParam" : 100 })
144+
145+ def test_102_negative_inputs (self ):
146+ """
147+ Should error with negative kv or negative length
148+ """
149+ circuit = PyGridSim ()
150+
151+ with self .assertRaises (Exception ):
152+ # openDSS has its own exception for this case
153+ circuit .add_load_nodes (params = {"kV" : - 1 })
154+
155+ with self .assertRaises (ValueError ):
156+ circuit .add_source_nodes (params = {"kV" : - 1 })
157+
158+ # properly add load and source, then create invalid line
159+ with self .assertRaises (ValueError ):
160+ circuit .add_lines ([("source" , "load0" )], params = {"length" : - 100 })
161+
162+ def test_103_invalid_nodes_in_line (self ):
163+ circuit = PyGridSim ()
164+ circuit .add_load_nodes ()
165+ circuit .add_source_nodes ()
166+ with self .assertRaises (ValueError ):
167+ # only has source, load0 for now but tries to add another one
168+ circuit .add_lines ([("source" , "load5" )])
169+
170+
171+ class TestLargeCircuit (unittest .TestCase ):
172+ """
173+ Test very large circuit (i.e. to the size of a neighborhood)
174+ """
175+ def setUp (self ):
176+ """Set up test fixtures, if any."""
177+ print ("\n Test" , self ._testMethodName )
178+
179+
111180 def tearDown (self ):
112181 """Tear down test fixtures, if any."""
113- pass
182+ pass
0 commit comments