class JumperTestCase(unittest2.TestCase): @classmethod def setUpClass(cls): with logging_disabled(): from b3.parsers.q3a.abstractParser import AbstractParser from b3.fake import FakeConsole AbstractParser.__bases__ = (FakeConsole,) # Now parser inheritance hierarchy is : # Iourt41Parser -> abstractParser -> FakeConsole -> Parser 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 tearDown(self): self.console.working = False