@@ -130,7 +130,7 @@ async def test_trophy_title_coordinator(
130130 assert config_entry .state is ConfigEntryState .LOADED
131131 assert len (mock_psnawpapi .user .return_value .trophy_titles .mock_calls ) == 1
132132
133- freezer .tick (timedelta (days = 1 , seconds = 1 ))
133+ freezer .tick (timedelta (days = 1 ))
134134 async_fire_time_changed (hass )
135135 await hass .async_block_till_done ()
136136
@@ -155,7 +155,7 @@ async def test_trophy_title_coordinator_auth_failed(
155155 PSNAWPAuthenticationError
156156 )
157157
158- freezer .tick (timedelta (days = 1 , seconds = 1 ))
158+ freezer .tick (timedelta (days = 1 ))
159159 async_fire_time_changed (hass )
160160 await hass .async_block_till_done (wait_background_tasks = True )
161161 await hass .async_block_till_done (wait_background_tasks = True )
@@ -192,7 +192,7 @@ async def test_trophy_title_coordinator_update_data_failed(
192192
193193 mock_psnawpapi .user .return_value .trophy_titles .side_effect = exception
194194
195- freezer .tick (timedelta (days = 1 , seconds = 1 ))
195+ freezer .tick (timedelta (days = 1 ))
196196 async_fire_time_changed (hass )
197197 await hass .async_block_till_done (wait_background_tasks = True )
198198 await hass .async_block_till_done (wait_background_tasks = True )
@@ -223,7 +223,7 @@ async def test_trophy_title_coordinator_doesnt_update(
223223 assert config_entry .state is ConfigEntryState .LOADED
224224 assert len (mock_psnawpapi .user .return_value .trophy_titles .mock_calls ) == 1
225225
226- freezer .tick (timedelta (days = 1 , seconds = 1 ))
226+ freezer .tick (timedelta (days = 1 ))
227227 async_fire_time_changed (hass )
228228 await hass .async_block_till_done ()
229229
@@ -247,14 +247,23 @@ async def test_trophy_title_coordinator_play_new_game(
247247
248248 assert config_entry .state is ConfigEntryState .LOADED
249249
250+ assert len (mock_psnawpapi .user .return_value .trophy_titles .mock_calls ) == 1
251+
250252 assert (state := hass .states .get ("media_player.playstation_vita" ))
251253 assert state .attributes .get ("entity_picture" ) is None
252254
253255 mock_psnawpapi .user .return_value .trophy_titles .return_value = _tmp
254256
255- freezer .tick (timedelta (days = 1 , seconds = 1 ))
257+ # Wait one day to trigger PlaystationNetworkTrophyTitlesCoordinator refresh
258+ freezer .tick (timedelta (days = 1 ))
256259 async_fire_time_changed (hass )
257260 await hass .async_block_till_done (wait_background_tasks = True )
261+
262+ # Wait another 30 seconds in case the PlaystationNetworkUserDataCoordinator,
263+ # which has a 30 second update interval, updated before the
264+ # PlaystationNetworkTrophyTitlesCoordinator.
265+ freezer .tick (timedelta (seconds = 30 ))
266+ async_fire_time_changed (hass )
258267 await hass .async_block_till_done (wait_background_tasks = True )
259268
260269 assert len (mock_psnawpapi .user .return_value .trophy_titles .mock_calls ) == 2
0 commit comments