Skip to content

Commit 2161162

Browse files
committed
Remove remaining uses of JUNCTION components in tests
Also adjust component graph connections such that there are no broken connections from the removal of `JUNCTION` components. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent fe2979b commit 2161162

File tree

7 files changed

+20
-55
lines changed

7 files changed

+20
-55
lines changed

tests/actor/test_battery_status.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def component_graph() -> Tuple[Set[Component], Set[Connection]]:
116116
components = {
117117
Component(1, ComponentCategory.GRID),
118118
Component(2, ComponentCategory.METER),
119-
Component(3, ComponentCategory.JUNCTION),
120119
Component(104, ComponentCategory.METER),
121120
Component(105, ComponentCategory.INVERTER),
122121
Component(106, ComponentCategory.BATTERY),
@@ -130,14 +129,13 @@ def component_graph() -> Tuple[Set[Component], Set[Connection]]:
130129

131130
connections = {
132131
Connection(1, 2),
133-
Connection(2, 3),
134-
Connection(3, 104),
132+
Connection(2, 104),
135133
Connection(104, 105),
136134
Connection(105, 106),
137-
Connection(3, 204),
135+
Connection(2, 204),
138136
Connection(204, 205),
139137
Connection(205, 206),
140-
Connection(3, 304),
138+
Connection(2, 304),
141139
Connection(304, 305),
142140
Connection(305, 306),
143141
}

tests/actor/test_data_sourcing.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ async def test_data_sourcing_actor(self) -> None:
3030
servicer.add_component(
3131
1, microgrid_pb2.ComponentCategory.COMPONENT_CATEGORY_GRID
3232
)
33-
servicer.add_component(
34-
3, microgrid_pb2.ComponentCategory.COMPONENT_CATEGORY_JUNCTION
35-
)
3633
servicer.add_component(
3734
4, microgrid_pb2.ComponentCategory.COMPONENT_CATEGORY_METER
3835
)
@@ -46,9 +43,8 @@ async def test_data_sourcing_actor(self) -> None:
4643
9, microgrid_pb2.ComponentCategory.COMPONENT_CATEGORY_BATTERY
4744
)
4845

49-
servicer.add_connection(1, 3)
50-
servicer.add_connection(3, 4)
51-
servicer.add_connection(3, 7)
46+
servicer.add_connection(1, 4)
47+
servicer.add_connection(1, 7)
5248
servicer.add_connection(7, 8)
5349
servicer.add_connection(8, 9)
5450

tests/actor/test_power_distributing.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def component_graph(self) -> tuple[set[Component], set[Connection]]:
5353
components = {
5454
Component(1, ComponentCategory.GRID),
5555
Component(2, ComponentCategory.METER),
56-
Component(3, ComponentCategory.JUNCTION),
5756
Component(104, ComponentCategory.METER),
5857
Component(105, ComponentCategory.INVERTER),
5958
Component(106, ComponentCategory.BATTERY),
@@ -67,14 +66,13 @@ def component_graph(self) -> tuple[set[Component], set[Connection]]:
6766

6867
connections = {
6968
Connection(1, 2),
70-
Connection(2, 3),
71-
Connection(3, 104),
69+
Connection(2, 104),
7270
Connection(104, 105),
7371
Connection(105, 106),
74-
Connection(3, 204),
72+
Connection(2, 204),
7573
Connection(204, 205),
7674
Connection(205, 206),
77-
Connection(3, 304),
75+
Connection(2, 304),
7876
Connection(304, 305),
7977
Connection(305, 306),
8078
}

tests/microgrid/test_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ async def test_components(self) -> None:
106106
microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_UNSPECIFIED,
107107
),
108108
(101, microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_GRID),
109-
(103, microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_JUNCTION),
110109
(104, microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_METER),
111110
(105, microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_INVERTER),
112111
(106, microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_BATTERY),
@@ -117,7 +116,6 @@ async def test_components(self) -> None:
117116
assert set(await microgrid.components()) == {
118117
Component(100, ComponentCategory.NONE),
119118
Component(101, ComponentCategory.GRID),
120-
Component(103, ComponentCategory.JUNCTION),
121119
Component(104, ComponentCategory.METER),
122120
Component(105, ComponentCategory.INVERTER, InverterType.NONE),
123121
Component(106, ComponentCategory.BATTERY),

tests/microgrid/test_component.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ def test_component_category_from_protobuf() -> None:
2828
== cp.ComponentCategory.GRID
2929
)
3030

31-
assert (
32-
cp._component_category_from_protobuf(
33-
microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_JUNCTION
34-
)
35-
== cp.ComponentCategory.JUNCTION
36-
)
37-
3831
assert (
3932
cp._component_category_from_protobuf(
4033
microgrid_pb.ComponentCategory.COMPONENT_CATEGORY_METER
@@ -80,9 +73,6 @@ def test_Component() -> None:
8073
c1 = cp.Component(1, cp.ComponentCategory.GRID)
8174
assert c1.is_valid()
8275

83-
c3 = cp.Component(3, cp.ComponentCategory.JUNCTION)
84-
assert c3.is_valid()
85-
8676
c4 = cp.Component(4, cp.ComponentCategory.METER)
8777
assert c4.is_valid()
8878

tests/microgrid/test_graph.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def sample_input_components(self) -> Set[Component]:
6262
return {
6363
Component(11, ComponentCategory.GRID),
6464
Component(21, ComponentCategory.METER),
65-
Component(31, ComponentCategory.JUNCTION),
6665
Component(41, ComponentCategory.METER),
6766
Component(51, ComponentCategory.INVERTER),
6867
Component(61, ComponentCategory.BATTERY),
@@ -72,8 +71,7 @@ def sample_input_components(self) -> Set[Component]:
7271
def sample_input_connections(self) -> Set[Connection]:
7372
return {
7473
Connection(11, 21),
75-
Connection(21, 31),
76-
Connection(31, 41),
74+
Connection(21, 41),
7775
Connection(41, 51),
7876
Connection(51, 61),
7977
}
@@ -142,15 +140,13 @@ def test_without_filters(self) -> None:
142140
input_components = {
143141
101: Component(101, ComponentCategory.GRID),
144142
102: Component(102, ComponentCategory.METER),
145-
103: Component(103, ComponentCategory.JUNCTION),
146143
104: Component(104, ComponentCategory.METER),
147144
105: Component(105, ComponentCategory.INVERTER),
148145
106: Component(106, ComponentCategory.BATTERY),
149146
}
150147
input_connections = {
151148
Connection(101, 102),
152-
Connection(102, 103),
153-
Connection(103, 104),
149+
Connection(102, 104),
154150
Connection(104, 105),
155151
Connection(105, 106),
156152
}
@@ -186,16 +182,14 @@ def test_without_filters(self) -> None:
186182
({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, set()),
187183
({11}, {Component(11, ComponentCategory.GRID)}),
188184
({21}, {Component(21, ComponentCategory.METER)}),
189-
({31}, {Component(31, ComponentCategory.JUNCTION)}),
190185
({41}, {Component(41, ComponentCategory.METER)}),
191186
({51}, {Component(51, ComponentCategory.INVERTER)}),
192187
({61}, {Component(61, ComponentCategory.BATTERY)}),
193188
(
194-
{31, 11, 61},
189+
{11, 61},
195190
{
196191
Component(11, ComponentCategory.GRID),
197192
Component(61, ComponentCategory.BATTERY),
198-
Component(31, ComponentCategory.JUNCTION),
199193
},
200194
),
201195
(
@@ -560,23 +554,20 @@ def test_refresh_from(self) -> None:
560554
components={
561555
Component(1, ComponentCategory.GRID),
562556
Component(2, ComponentCategory.METER),
563-
Component(3, ComponentCategory.JUNCTION),
564557
Component(4, ComponentCategory.METER),
565558
Component(5, ComponentCategory.INVERTER),
566559
Component(6, ComponentCategory.BATTERY),
567560
},
568561
connections={
569562
Connection(1, 2),
570-
Connection(2, 3),
571-
Connection(3, 4),
563+
Connection(2, 4),
572564
Connection(4, 5),
573565
Connection(5, 6),
574566
},
575567
)
576568
expected = {
577569
Component(1, ComponentCategory.GRID),
578570
Component(2, ComponentCategory.METER),
579-
Component(3, ComponentCategory.JUNCTION),
580571
Component(4, ComponentCategory.METER),
581572
Component(5, ComponentCategory.INVERTER),
582573
Component(6, ComponentCategory.BATTERY),
@@ -585,8 +576,7 @@ def test_refresh_from(self) -> None:
585576
assert set(graph.components()) == expected
586577
assert graph.connections() == {
587578
Connection(1, 2),
588-
Connection(2, 3),
589-
Connection(3, 4),
579+
Connection(2, 4),
590580
Connection(4, 5),
591581
Connection(5, 6),
592582
}
@@ -614,8 +604,7 @@ def test_refresh_from(self) -> None:
614604

615605
assert graph.connections() == {
616606
Connection(1, 2),
617-
Connection(2, 3),
618-
Connection(3, 4),
607+
Connection(2, 4),
619608
Connection(4, 5),
620609
Connection(5, 6),
621610
}

tests/microgrid/test_microgrid_api.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def components(self) -> List[List[Component]]:
3232
components = [
3333
[
3434
Component(1, ComponentCategory.GRID),
35-
Component(3, ComponentCategory.JUNCTION),
3635
Component(4, ComponentCategory.METER),
3736
Component(5, ComponentCategory.METER),
3837
Component(6, ComponentCategory.PV_ARRAY),
@@ -45,7 +44,6 @@ def components(self) -> List[List[Component]]:
4544
],
4645
[
4746
Component(1, ComponentCategory.GRID),
48-
Component(3, ComponentCategory.JUNCTION),
4947
Component(4, ComponentCategory.METER),
5048
Component(7, ComponentCategory.METER),
5149
Component(8, ComponentCategory.INVERTER),
@@ -67,21 +65,19 @@ def connections(self) -> List[List[Connection]]:
6765
"""
6866
connections = [
6967
[
70-
Connection(1, 3),
71-
Connection(3, 4),
72-
Connection(3, 5),
68+
Connection(1, 4),
69+
Connection(1, 5),
7370
Connection(5, 6),
74-
Connection(3, 7),
71+
Connection(1, 7),
7572
Connection(7, 8),
7673
Connection(8, 9),
77-
Connection(3, 10),
74+
Connection(1, 10),
7875
Connection(10, 11),
7976
Connection(11, 12),
8077
],
8178
[
82-
Connection(1, 3),
83-
Connection(3, 4),
84-
Connection(3, 7),
79+
Connection(1, 4),
80+
Connection(1, 7),
8581
Connection(7, 8),
8682
Connection(8, 9),
8783
],

0 commit comments

Comments
 (0)