@@ -57,3 +57,51 @@ async def test_charge_graph_in_slot(hass):
5757 expected = True
5858
5959 assert expected == result
60+
61+
62+ async def test_next_slot_no_live_no_in_progress ():
63+ """Test that the _next_slot function returns the correct result when live and in_progress are False."""
64+ TEST_DATA = [{"t" : 10 , "y" : 0 }, {"t" : 20 , "y" : 0 },
65+ {"t" : 30 , "y" : 10 }, {"t" : 40 , "y" : 20 },
66+ {"t" : 50 , "y" : 20 }, {"t" : 60 , "y" : 0 }]
67+
68+ result = utils ._next_slot (TEST_DATA , live = False , in_progress = False )
69+ expected = [None , None , 4 , 0 ]
70+
71+ assert expected == result
72+
73+
74+ async def test_next_slot_live_no_in_progress ():
75+ """Test that the _next_slot function returns the correct result when live is True and in_progress is False."""
76+ TEST_DATA = [{"t" : 10 , "y" : 0 }, {"t" : 20 , "y" : 0 },
77+ {"t" : 30 , "y" : 10 }, {"t" : 40 , "y" : 20 },
78+ {"t" : 50 , "y" : 20 }, {"t" : 60 , "y" : 0 }]
79+
80+ result = utils ._next_slot (TEST_DATA , live = True , in_progress = False )
81+ expected = [None , 41 , 4 , 20 ]
82+
83+ assert expected == result
84+
85+
86+ async def test_next_slot_no_live_in_progress ():
87+ """Test that the _next_slot function returns the correct result when live is False and in_progress is True."""
88+ TEST_DATA = [{"t" : 10 , "y" : 0 }, {"t" : 20 , "y" : 0 },
89+ {"t" : 30 , "y" : 10 }, {"t" : 40 , "y" : 20 },
90+ {"t" : 50 , "y" : 20 }, {"t" : 60 , "y" : 0 }]
91+
92+ result = utils ._next_slot (TEST_DATA , live = False , in_progress = True )
93+ expected = [None , None , 4 , 0 ]
94+
95+ assert expected == result
96+
97+
98+ async def test_next_slot_live_in_progress ():
99+ """Test that the _next_slot function returns the correct result when live and in_progress are True."""
100+ TEST_DATA = [{"t" : 10 , "y" : 0 }, {"t" : 20 , "y" : 0 },
101+ {"t" : 30 , "y" : 10 }, {"t" : 40 , "y" : 20 },
102+ {"t" : 50 , "y" : 20 }, {"t" : 60 , "y" : 0 }]
103+
104+ result = utils ._next_slot (TEST_DATA , live = True , in_progress = True )
105+ expected = [None , 41 , 4 , 20 ]
106+
107+ assert expected == result
0 commit comments