test_player_launcher.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import unittest
  2. import mock
  3. from kalliope.core.Models.Player import Player
  4. from kalliope.core.Models.Settings import Settings
  5. from kalliope.core.PlayerLauncher import PlayerLauncher
  6. class TestPlayerLauncher(unittest.TestCase):
  7. """
  8. Class to test Launchers Classes (PlayerLauncher) and methods
  9. """
  10. def setUp(self):
  11. pass
  12. ####
  13. # Player Launcher
  14. def test_get_player(self):
  15. """
  16. Test the PlayerLauncher trying to run the Player
  17. """
  18. player1 = Player("Player", {})
  19. player2 = Player("Player2", {'test': "hitheparamtest"})
  20. settings = Settings()
  21. settings.players = [player1, player2]
  22. with mock.patch("kalliope.core.Utils.get_dynamic_class_instantiation") as mock_get_class_instantiation:
  23. # Get the player1
  24. settings.default_player_name = "Player"
  25. PlayerLauncher.get_player(settings=settings)
  26. mock_get_class_instantiation.assert_called_once_with(package_name="players",
  27. module_name=player1.name,
  28. parameters=player1.parameters)
  29. mock_get_class_instantiation.reset_mock()
  30. # Get the player 2
  31. settings.default_player_name = "Player2"
  32. PlayerLauncher.get_player(settings=settings)
  33. mock_get_class_instantiation.assert_called_once_with(package_name="players",
  34. module_name=player2.name,
  35. parameters=player2.parameters)
  36. mock_get_class_instantiation.reset_mock()