Module GameEngineTest
[hide private]
[frames] | no frames]

Source Code for Module GameEngineTest

 1  ##################################################################### 
 2  # -*- coding: iso-8859-1 -*-                                        # 
 3  #                                                                   # 
 4  # Frets on Fire                                                     # 
 5  # Copyright (C) 2006 Sami Kyöstilä                                  # 
 6  #                                                                   # 
 7  # This program is free software; you can redistribute it and/or     # 
 8  # modify it under the terms of the GNU General Public License       # 
 9  # as published by the Free Software Foundation; either version 2    # 
10  # of the License, or (at your option) any later version.            # 
11  #                                                                   # 
12  # This program is distributed in the hope that it will be useful,   # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of    # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     # 
15  # GNU General Public License for more details.                      # 
16  #                                                                   # 
17  # You should have received a copy of the GNU General Public License # 
18  # along with this program; if not, write to the Free Software       # 
19  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,        # 
20  # MA  02110-1301, USA.                                              # 
21  ##################################################################### 
22   
23  import unittest 
24  from GameEngine import GameEngine 
25   
26 -class EngineTest(unittest.TestCase):
27 - def testNetworking(self):
28 e1 = GameEngine() 29 30 e1.startServer() 31 session1 = e1.connect("localhost") 32 session2 = e1.connect("localhost") 33 34 while not session1.isConnected() or not session2.isConnected(): 35 e1.run() 36 37 session1.world.createPlayer("mario") 38 session2.world.createPlayer("luigi") 39 40 for i in range(10): 41 e1.run() 42 43 assert len(e1.server.world.players) == 2 44 assert len(session1.world.players) == 2 45 assert len(session2.world.players) == 2 46 47 session3 = e1.connect("localhost") 48 49 for i in range(10): 50 e1.run() 51 52 assert len(session3.world.players) == 2 53 54 session1.disconnect() 55 56 for i in range(10): 57 e1.run() 58 59 assert len(e1.server.world.players) == 1 60 assert len(session2.world.players) == 1 61 62 e1.quit()
63 64 if __name__ == "__main__": 65 unittest.main() 66