def setUp(self): self.server = Server.Server("TF2") self.server.rcon_connection = RconConnection() self.server.ip = "202.138.3.55" self.server.port = 27045 self.server.rcon_password = "******" self.pug = Pug.Pug(pid=1) # add some players to the pug for stats testing... self.pug.add_player(76561197960265729, "1", Pug.PlayerStats()) self.pug.add_player(76561197960265730, "2", Pug.PlayerStats()) self.pug.add_player(76561197960265731, "3", Pug.PlayerStats()) for i in xrange(9): stat = Pug.PlayerStats() self.pug.add_player(i, str(i), stat) self.pug.begin_map_vote() self.pug.end_map_vote() self.pug.shuffle_teams() self.server.reserve(self.pug) self.server.prepare() self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.socket.connect(('127.0.0.1', self.server.log_port))
def test_get_player_stats(): print "GETTING PLAYER STATS FOR %s: " % PLAYER_IDS stats = dbif.get_player_stats(PLAYER_IDS) for cid in stats: stats[cid] = Pug.PlayerStats(stats[cid]) print "Player stats equal? %s" % (stats == player_stats)
dsn = "dbname=%s user=%s password=%s host=%s port=%s" % ( settings.db_name, settings.db_user, settings.db_pass, settings.db_host, settings.db_port) conn = psycopg2.pool.SimpleConnectionPool(dsn=dsn, minconn=1, maxconn=1) dbif = PSQLDatabaseInterface(conn) PLAYER_IDS = [1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L] api_key = "123abc" server_group = 1 player_stats = {} for cid in PLAYER_IDS: player_stats[cid] = Pug.PlayerStats() pugs = [Pug.Pug()] # we want to use the various methods supplied in PSQLDatabaseInterface and # see if they have the correct output def test_user_info(): # single user print "User info for '%s':" % api_key user = dbif.get_user_info(api_key) pprint(user) # all users print "All users:" users = dbif.get_user_info()
from entities import Pug, Server from pprint import pprint s = Server.Server("TF2") p = Pug.Pug(pid = 1) p.add_player(76561197960265729, "1", Pug.PlayerStats()) p.add_player(76561197960265730, "2", Pug.PlayerStats()) p.add_player(76561197960265731, "3", Pug.PlayerStats()) p.begin_game() #pprint(p.game_stats) s.reserve(p) s.prepare() log = s._log_interface kill = 'L 10/01/2012 - 22:20:45: "1<0><[U:1:1]><Blue>" killed "2<2><[U:1:2]><Red>" with "scattergun" (attacker_position "-1803 129 236") (victim_position "-1767 278 218")' log._dispatch_parse(kill) pprint(p.game_stats)