def main(): console = ConsoleClient() teama = FootballTeam() \ .name('teama') teamb = FootballTeam().name('teamb') game = FootballGame() \ .gameid(1) \ .team1(teama) \ .team2(teamb) \ .add_client(console) game.run()
def test_add_client_should_get_events_from_simulation(self): # Arrange event = Event('my event') def mock_run_game(game): for client in game.get_clients(): client.on_event(event=event) mock_client = Mock(spec=FootballGameClient) mock_simulation = Mock(spec=type(football_simulation)) mock_simulation.run_game = mock_run_game # Act game = FootballGame() \ .team1(FootballTeam(name='team1')) \ .team2(FootballTeam(name='team2')) \ .simulation(mock_simulation) \ .add_client(mock_client) game.run() # Assert mock_client.on_event.assert_called_once_with(event=event)
def test_running_game_should_call_and_return_simulation_rungame(self): # Arrange & Act mock_simulation = Mock(spec=type(football_simulation)) team1 = FootballTeam(name='team1') team2 = FootballTeam(name='team2') # Act game = FootballGame() \ .team1(team1) \ .team2(team2) \ .simulation(mock_simulation) game_result = game.run() # Assert mock_simulation.run_game.assert_called_once_with(game)