1111 BATTERY_LIFE_TIME_UNKNOWN ,
1212 BatteryFlag ,
1313 PowerState ,
14+ ReportContext ,
1415 SystemPowerStatus ,
1516 _getSpeechForBatteryStatus ,
1617)
@@ -23,118 +24,118 @@ def setUp(self) -> None:
2324 MagicMock (SystemPowerStatus ())
2425 )
2526
26- def test_unknownPowerStatus_failedFetch (self ):
27+ def test_fetch_status_fetchFailed (self ):
2728 actualSpeech = _getSpeechForBatteryStatus (
2829 systemPowerStatus = None ,
29- onlyReportIfStatusChanged = False ,
30+ context = ReportContext . FETCH_STATUS ,
3031 oldPowerState = PowerState .UNKNOWN ,
3132 )
3233 self .assertEqual (
3334 ["Unknown power status" ],
3435 actualSpeech ,
3536 )
3637
37- def test_unknownPowerStatus_fetchSuccessful (self ):
38+ def test_fetch_status_fetchSuccessful_unknownPowerStatus (self ):
3839 self .testPowerStatus .BatteryFlag = BatteryFlag .UNKNOWN
3940 actualSpeech = _getSpeechForBatteryStatus (
4041 systemPowerStatus = self .testPowerStatus ,
41- onlyReportIfStatusChanged = False ,
42+ context = ReportContext . FETCH_STATUS ,
4243 oldPowerState = PowerState .UNKNOWN ,
4344 )
4445 self .assertEqual (
4546 ["Unknown power status" ],
4647 actualSpeech ,
4748 )
4849
49- def test_noSystemBattery (self ):
50+ def test_fetch_status_fetchSuccessful_noSystemBattery (self ):
5051 self .testPowerStatus .BatteryFlag = 0 ^ BatteryFlag .NO_SYSTEM_BATTERY
5152 actualSpeech = _getSpeechForBatteryStatus (
5253 systemPowerStatus = self .testPowerStatus ,
53- onlyReportIfStatusChanged = False ,
54+ context = ReportContext . FETCH_STATUS ,
5455 oldPowerState = PowerState .UNKNOWN ,
5556 )
5657 self .assertEqual (
5758 ["No system battery" ],
5859 actualSpeech ,
5960 )
6061
61- def test_statusUnchanged_ignore (self ):
62+ def test_fetch_status_full_report (self ):
6263 self .testPowerStatus .ACLineStatus = PowerState .AC_OFFLINE
6364 self .testPowerStatus .BatteryFlag = BatteryFlag .HIGH
65+ self .testPowerStatus .BatteryLifeTime = 3660
6466 actualSpeech = _getSpeechForBatteryStatus (
6567 systemPowerStatus = self .testPowerStatus ,
66- onlyReportIfStatusChanged = True ,
68+ context = ReportContext . FETCH_STATUS ,
6769 oldPowerState = PowerState .AC_OFFLINE ,
6870 )
6971 self .assertEqual (
70- [],
72+ ['1 percent' , '1 hours and 1 minutes remaining' , "AC disconnected" ],
7173 actualSpeech ,
7274 )
7375
74- def test_statusUnchanged_report (self ):
76+ def test_ac_status_change_statusUnchanged_ignore (self ):
7577 self .testPowerStatus .ACLineStatus = PowerState .AC_OFFLINE
7678 self .testPowerStatus .BatteryFlag = BatteryFlag .HIGH
77- self .testPowerStatus .BatteryLifeTime = 3660
7879 actualSpeech = _getSpeechForBatteryStatus (
7980 systemPowerStatus = self .testPowerStatus ,
80- onlyReportIfStatusChanged = False ,
81+ context = ReportContext . AC_STATUS_CHANGE ,
8182 oldPowerState = PowerState .AC_OFFLINE ,
8283 )
8384 self .assertEqual (
84- ["AC disconnected" , '1 percent' , '1 hours and 1 minutes remaining' ],
85+ [],
8586 actualSpeech ,
8687 )
8788
88- def test_statusChanged_connected (self ):
89+ def test_ac_status_change_statusChanged_connected (self ):
8990 self .testPowerStatus .ACLineStatus = PowerState .AC_ONLINE
9091 self .testPowerStatus .BatteryFlag = BatteryFlag .HIGH
9192 self .testPowerStatus .BatteryLifeTime = 3660
9293 actualSpeech = _getSpeechForBatteryStatus (
9394 systemPowerStatus = self .testPowerStatus ,
94- onlyReportIfStatusChanged = True ,
95+ context = ReportContext . AC_STATUS_CHANGE ,
9596 oldPowerState = PowerState .AC_OFFLINE ,
9697 )
9798 self .assertEqual (
9899 ["Charging battery" , '1 percent' , '1 hours and 1 minutes remaining' ],
99100 actualSpeech ,
100101 )
101102
102- def test_statusChanged_disconnected (self ):
103+ def test_ac_status_change_statusChanged_disconnected (self ):
103104 self .testPowerStatus .ACLineStatus = PowerState .AC_OFFLINE
104105 self .testPowerStatus .BatteryFlag = BatteryFlag .HIGH
105106 self .testPowerStatus .BatteryLifeTime = 3660
106107 actualSpeech = _getSpeechForBatteryStatus (
107108 systemPowerStatus = self .testPowerStatus ,
108- onlyReportIfStatusChanged = True ,
109+ context = ReportContext . AC_STATUS_CHANGE ,
109110 oldPowerState = PowerState .AC_ONLINE ,
110111 )
111112 self .assertEqual (
112113 ["AC disconnected" , '1 percent' , '1 hours and 1 minutes remaining' ],
113114 actualSpeech ,
114115 )
115116
116- def test_batteryLifetimeUnknown (self ):
117+ def test_ac_status_change_batteryLifetimeUnknown (self ):
117118 self .testPowerStatus .ACLineStatus = PowerState .AC_OFFLINE
118119 self .testPowerStatus .BatteryFlag = BatteryFlag .HIGH
119120 self .testPowerStatus .BatteryLifeTime = BATTERY_LIFE_TIME_UNKNOWN
120121 actualSpeech = _getSpeechForBatteryStatus (
121122 systemPowerStatus = self .testPowerStatus ,
122- onlyReportIfStatusChanged = True ,
123+ context = ReportContext . AC_STATUS_CHANGE ,
123124 oldPowerState = PowerState .AC_ONLINE ,
124125 )
125126 self .assertEqual (
126127 ["AC disconnected" , '1 percent' ],
127128 actualSpeech ,
128129 )
129130
130- def test_batteryLifePercent (self ):
131+ def test_ac_status_change_batteryLifePercent (self ):
131132 self .testPowerStatus .ACLineStatus = PowerState .AC_OFFLINE
132133 self .testPowerStatus .BatteryFlag = BatteryFlag .HIGH
133134 self .testPowerStatus .BatteryLifePercent = 7
134135 self .testPowerStatus .BatteryLifeTime = BATTERY_LIFE_TIME_UNKNOWN
135136 actualSpeech = _getSpeechForBatteryStatus (
136137 systemPowerStatus = self .testPowerStatus ,
137- onlyReportIfStatusChanged = True ,
138+ context = ReportContext . AC_STATUS_CHANGE ,
138139 oldPowerState = PowerState .AC_ONLINE ,
139140 )
140141 self .assertEqual (
0 commit comments