def setUp(self): with logging_disabled(): # create a Iourt41 parser self.parser_conf = XmlConfigParser() self.parser_conf.loadFromString("""<configuration><settings name="server"><set name="game_log"></set></settings></configuration>""") self.console = Iourt42Parser(self.parser_conf) self.console.startup() # load the admin plugin if B3version(b3_version) >= B3version("1.10dev"): admin_plugin_conf_file = '@b3/conf/plugin_admin.ini' else: admin_plugin_conf_file = '@b3/conf/plugin_admin.xml' with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, admin_plugin_conf_file) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin) # prepare a few players from b3.fake import FakeClient self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, team=TEAM_UNKNOWN, teamId=0, squad=0) self.simon = FakeClient(self.console, name="Simon", exactName="Simon", guid="qsdfdsqfdsqf", groupBits=0, team=TEAM_UNKNOWN, teamId=0, squad=0) self.reg = FakeClient(self.console, name="Reg", exactName="Reg", guid="qsdfdsqfdsqf33", groupBits=4, team=TEAM_UNKNOWN, teamId=0, squad=0) self.moderator = FakeClient(self.console, name="Moderator", exactName="Moderator", guid="sdf455ezr", groupBits=8, team=TEAM_UNKNOWN, teamId=0, squad=0) self.admin = FakeClient(self.console, name="Level-40-Admin", exactName="Level-40-Admin", guid="875sasda", groupBits=16, team=TEAM_UNKNOWN, teamId=0, squad=0) self.superadmin = FakeClient(self.console, name="God", exactName="God", guid="f4qfer654r", groupBits=128, team=TEAM_UNKNOWN, teamId=0, squad=0)
def setUp(self): self.parser_conf = XmlConfigParser() self.parser_conf.loadFromString("""<configuration> <settings name="server"> <set name="game_log"/> </settings> </configuration>""") self.console = Iourt42Parser(self.parser_conf) self.console.PunkBuster = None # no Punkbuster support in that game self.output_mock = mock() # simulate game server actions def write(*args, **kwargs): pretty_args = map(repr, args) + [ "%s=%s" % (k, v) for k, v in kwargs.iteritems() ] log.info("write(%s)" % ', '.join(pretty_args)) return self.output_mock.write(*args, **kwargs) self.console.write = Mock(wraps=write) self.player = self.console.clients.newClient(cid="4", guid="theGuid", name="theName", ip="11.22.33.44")
def setUp(self): # create a Iourt42 parser self.parser_conf = XmlConfigParser() self.parser_conf.loadFromString( """<configuration><settings name="server"><set name="game_log"></set></settings></configuration>""" ) self.console = Iourt42Parser(self.parser_conf) self.console.startup() # load the admin plugin if B3version(b3_version) >= B3version("1.10dev"): admin_plugin_conf_file = '@b3/conf/plugin_admin.ini' else: admin_plugin_conf_file = '@b3/conf/plugin_admin.xml' with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, admin_plugin_conf_file) self.adminPlugin._commands = { } # work around known bug in the Admin plugin which makes the _command property shared between all instances self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin) # prepare a few players self.joe = FakeClient(self.console, name="Joe", guid="Joe_guid", groupBits=1, team=TEAM_UNKNOWN) self.simon = FakeClient(self.console, name="Simon", guid="Simon_guid", groupBits=0, team=TEAM_UNKNOWN) self.reg = FakeClient(self.console, name="Reg", guid="Reg_guid", groupBits=4, team=TEAM_UNKNOWN) self.moderator = FakeClient(self.console, name="Moderator", guid="Moderator_guid", groupBits=8, team=TEAM_UNKNOWN) self.admin = FakeClient(self.console, name="Level-40-Admin", guid="Admin_guid", groupBits=16, team=TEAM_UNKNOWN) self.superadmin = FakeClient(self.console, name="Superadmin", guid="Superadmin_guid", groupBits=128, team=TEAM_UNKNOWN) logging.getLogger('output').setLevel(logging.DEBUG)
def setUp(self): # create a Iourt42 parser parser_conf = XmlConfigParser() parser_conf.loadFromString(dedent(r""" <configuration> <settings name="server"> <set name="game_log"></set> </settings> </configuration> """)) self.parser_conf = MainConfig(parser_conf) self.console = Iourt42Parser(self.parser_conf) # initialize some fixed cvars which will be used by both the plugin and the iourt42 parser when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='0')) when(self.console).getCvar('fs_basepath').thenReturn(Cvar('fs_basepath', value='/fake/basepath')) when(self.console).getCvar('fs_homepath').thenReturn(Cvar('fs_homepath', value='/fake/homepath')) when(self.console).getCvar('fs_game').thenReturn(Cvar('fs_game', value='q3ut4')) when(self.console).getCvar('gamename').thenReturn(Cvar('gamename', value='q3urt42')) # start the parser self.console.startup() with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin) self.conf = CfgConfigParser() self.conf.loadFromString(dedent(r""" [settings] demorecord: no skipstandardmaps: yes minleveldelete: senioradmin [commands] delrecord: guest maprecord: guest mapinfo: guest record: guest setway: senioradmin topruns: guest map: fulladmin maps: user setnextmap: admin """)) self.p = JumperPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup() # load fixed json data (do not contact urtjumpers api for testing) when(self.p).getMapsDataFromApi().thenReturn(json.loads(MAPDATA_JSON))
def setUp(self): # create a Iourt42 parser parser_conf = XmlConfigParser() parser_conf.loadFromString(dedent(r""" <configuration> <settings name="server"> <set name="game_log"></set> </settings> </configuration> """)) self.parser_conf = MainConfig(parser_conf) self.console = Iourt42Parser(self.parser_conf) # initialize some fixed cvars which will be used by both the plugin and the iourt42 parser when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='0')) when(self.console).getCvar('fs_basepath').thenReturn(Cvar('fs_basepath', value='/fake/basepath')) when(self.console).getCvar('fs_homepath').thenReturn(Cvar('fs_homepath', value='/fake/homepath')) when(self.console).getCvar('fs_game').thenReturn(Cvar('fs_game', value='q3ut4')) when(self.console).getCvar('gamename').thenReturn(Cvar('gamename', value='q3urt42')) # start the parser self.console.startup() with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin) with logging_disabled(): from b3.fake import FakeClient # create some clients self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", team=TEAM_RED, groupBits=128) self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", team=TEAM_BLUE, groupBits=16) self.mark = FakeClient(console=self.console, name="Mark", guid="markguid", team=TEAM_RED, groupBits=2) self.sara = FakeClient(console=self.console, name="Sara", guid="saraguid", team=TEAM_SPEC, groupBits=1) self.conf = CfgConfigParser() self.p = CallvotePlugin(self.console, self.conf)
def setUp(self): # create a Iourt42 parser self.parser_conf = XmlConfigParser() self.parser_conf.loadFromString( dedent(r""" <configuration> <settings name="server"> <set name="game_log"></set> </settings> </configuration> """)) self.console = Iourt42Parser(self.parser_conf) # initialize some fixed cvars which will be used by both the plugin and the iourt42 parser when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='0')) when(self.console).getCvar('fs_basepath').thenReturn( Cvar('fs_basepath', value='/fake/basepath')) when(self.console).getCvar('fs_homepath').thenReturn( Cvar('fs_homepath', value='/fake/homepath')) when(self.console).getCvar('fs_game').thenReturn( Cvar('fs_game', value='q3ut4')) when(self.console).getCvar('gamename').thenReturn( Cvar('gamename', value='q3urt42')) # start the parser self.console.startup() with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)
def setUp(self): # create a Iourt42 parser self.parser_conf = XmlConfigParser() self.parser_conf.loadFromString( dedent(r""" <configuration> <settings name="server"> <set name="game_log"></set> </settings> </configuration> """)) self.console = Iourt42Parser(self.parser_conf) # initialize some fixed cvars which will be used by both the plugin and the iourt42 parser when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='0')) when(self.console).getCvar('fs_basepath').thenReturn( Cvar('g_maxGameClients', value='/fake/basepath')) when(self.console).getCvar('fs_homepath').thenReturn( Cvar('sv_maxclients', value='/fake/homepath')) when(self.console).getCvar('fs_game').thenReturn( Cvar('fs_game', value='q3ut4')) when(self.console).getCvar('gamename').thenReturn( Cvar('gamename', value='q3urt42')) # start the parser self.console.startup() self.admin_plugin_conf = CfgConfigParser() self.admin_plugin_conf.loadFromString( dedent(r""" [warn] pm_global: yes alert_kick_num: 3 instant_kick_num: 5 tempban_num: 6 tempban_duration: 1d max_duration: 1d message: ^1WARNING^7 [^3$warnings^7]: $reason warn_delay: 15 reason: ^7too many warnings: $reason duration_divider: 30 alert: ^1ALERT^7: $name^7 auto-kick from warnings if not cleared [^3$warnings^7] $reason warn_command_abusers: no""")) with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, self.admin_plugin_conf) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin) with logging_disabled(): from b3.fake import FakeClient # create some clients self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", team=TEAM_RED, groupBits=1) self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", team=TEAM_BLUE, groupBits=1) self.mark = FakeClient(console=self.console, name="Mark", guid="markguid", team=TEAM_BLUE, groupBits=128) self.conf = CfgConfigParser() self.p = SpawnkillPlugin(self.console, self.conf)
def setUp(self): # create a Iourt42 parser parser_conf = XmlConfigParser() parser_conf.loadFromString( dedent(r""" <configuration> <settings name="server"> <set name="game_log"></set> </settings> </configuration> """)) self.parser_conf = MainConfig(parser_conf) self.console = Iourt42Parser(self.parser_conf) # initialize some fixed cvars which will be used by both the plugin and the iourt42 parser when(self.console).getCvar('auth').thenReturn(Cvar('auth', value='0')) when(self.console).getCvar('fs_basepath').thenReturn( Cvar('fs_basepath', value='/fake/basepath')) when(self.console).getCvar('fs_homepath').thenReturn( Cvar('fs_homepath', value='/fake/homepath')) when(self.console).getCvar('fs_game').thenReturn( Cvar('fs_game', value='q3ut4')) when(self.console).getCvar('gamename').thenReturn( Cvar('gamename', value='q3urt42')) # start the parser self.console.startup() with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # make sure the admin plugin obtained by other plugins is our admin plugin when(self.console).getPlugin('admin').thenReturn(self.adminPlugin) self.conf = CfgConfigParser() self.conf.loadFromString( dedent(r""" [settings] firstkill: on firsttk: on firsths: on [commands] firstkill: superadmin firsttk: superadmin firsths: superadmin [messages] ## $client = the client who made the kill ## $target = the client who suffered the kill first_kill: ^2First Kill^3: $client killed $target first_kill_by_headshot: ^2First Kill ^5by Headshot^3: $client killed $target first_teamkill: ^1First TeamKill^3: $client teamkilled $target """)) self.p = FirstkillPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup() with logging_disabled(): from b3.fake import FakeClient # create some clients self.mike = FakeClient(console=self.console, name="Mike", guid="mikeguid", team=TEAM_BLUE, groupBits=1) self.mark = FakeClient(console=self.console, name="Mark", guid="markguid", team=TEAM_BLUE, groupBits=1) self.bill = FakeClient(console=self.console, name="Bill", guid="billguid", team=TEAM_RED, groupBits=1) self.mike.connects("1") self.bill.connects("2") self.mark.connects("3")