Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_player_create_instance_dep_error_indirect():
Config.data = {'player': ''}
SomePlayer.check_dependencies.side_effect = PlayerDependencyError()
with pytest.raises(PlayerDependencyError):
Player.create_instance(available_players, "t", "p", episode)
assert SomePlayer.check_dependencies.call_count == 1
def test_player_create_instance_dep_error_direct():
Config.data = {'player': 'someplayer'}
SomePlayer.check_dependencies.side_effect = PlayerDependencyError()
with pytest.raises(PlayerDependencyError):
Player.create_instance(available_players, "t", "p", episode)
assert SomePlayer.check_dependencies.call_count == 1
def test_player_create_instance_success_indirect():
Config.data = {'player': ''}
Player.create_instance(available_players, "t", "p", episode)
SomePlayer.check_dependencies.assert_called = 2
SomePlayer.assert_called_with("t", "p", episode)
def _restore_queue(self) -> None:
"""Recreate players in queue from the database.
"""
for episode in self.database.queue():
player = Player.create_instance(
self.AVAILABLE_PLAYERS, str(episode),
episode.get_playable(), episode)
self.queue.add(player)