class AdminTestCase(unittest.TestCase): """ Test case that is suitable for testing Insurgency parser specific features with the B3 admin plugin available """ @classmethod def setUpClass(cls): from b3.fake import FakeConsole InsurgencyParser.__bases__ = (FakeConsole,) # Now parser inheritance hierarchy is : # InsurgencyParser -> FakeConsole -> Parser def setUp(self): self.status_response = None # defaults to STATUS_RESPONSE module attribute self.conf = XmlConfigParser() self.conf.loadFromString("""<configuration></configuration>""") self.parser = InsurgencyParser(self.conf) self.parser.output = Mock() self.parser.output.write = Mock(wraps=sys.stdout.write) when(self.parser).is_sourcemod_installed().thenReturn(True) adminPlugin_conf = CfgConfigParser() adminPlugin_conf.load(ADMIN_CONFIG_FILE) adminPlugin = AdminPlugin(self.parser, adminPlugin_conf) adminPlugin.onLoadConfig() adminPlugin.onStartup() when(self.parser).getPlugin('admin').thenReturn(adminPlugin) when(self.parser).getAllAvailableMaps().thenReturn (['buhriz', 'district', 'sinjar', 'siege', 'uprising', 'ministry', 'revolt', 'heights', 'contact', 'peak', 'panj', 'market']) when(self.parser).getMap().thenReturn('buhriz') self.parser.startup() self.parser.patch_b3_admin_plugin() # seems that without this the test module doesn't patch the admin plugin def tearDown(self): if hasattr(self, "parser"): del self.parser.clients self.parser.working = False
class AdminTestCase(unittest.TestCase): """ Test case that is suitable for testing Insurgency parser specific features with the B3 admin plugin available """ @classmethod def setUpClass(cls): from b3.fake import FakeConsole InsurgencyParser.__bases__ = (FakeConsole, ) # Now parser inheritance hierarchy is : # InsurgencyParser -> FakeConsole -> Parser def setUp(self): self.status_response = None # defaults to STATUS_RESPONSE module attribute self.conf = XmlConfigParser() self.conf.loadFromString("""<configuration></configuration>""") self.parser = InsurgencyParser(self.conf) self.parser.output = Mock() self.parser.output.write = Mock(wraps=sys.stdout.write) when(self.parser).is_sourcemod_installed().thenReturn(True) adminPlugin_conf = CfgConfigParser() adminPlugin_conf.load(ADMIN_CONFIG_FILE) adminPlugin = AdminPlugin(self.parser, adminPlugin_conf) adminPlugin.onLoadConfig() adminPlugin.onStartup() when(self.parser).getPlugin('admin').thenReturn(adminPlugin) when(self.parser).getAllAvailableMaps().thenReturn([ 'buhriz', 'district', 'sinjar', 'siege', 'uprising', 'ministry', 'revolt', 'heights', 'contact', 'peak', 'panj', 'market' ]) when(self.parser).getMap().thenReturn('buhriz') self.parser.startup() self.parser.patch_b3_admin_plugin( ) # seems that without this the test module doesn't patch the admin plugin def tearDown(self): if hasattr(self, "parser"): del self.parser.clients self.parser.working = False