def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: db = MySQLdb.connect(host=MYSQL_HOST, user=MYSQL_USER, passwd=MYSQL_PASSWORD) except MySQLdb.OperationalError, message: self.fail("Error %d:\n%s" % (message[0], message[1]))
def setUp(self): B3TestCase.setUp(self) self.console.gameName = 'f00' self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.conf = CfgConfigParser() self.conf.loadFromString( dedent(r""" [commands] plugin: superadmin """)) self.p = PluginmanagerPlugin(self.console, self.conf) when(self.console).getPlugin("pluginmanager").thenReturn( self.adminPlugin) self.p.onLoadConfig() self.p.onStartup() when(self.console.config).get_external_plugins_dir().thenReturn( b3.getAbsolutePath('@b3\\extplugins')) # store them also in the console _plugins dict self.console._plugins['admin'] = self.adminPlugin self.console._plugins['pluginmanager'] = self.p
def setUp(self): """ This method is called before each test. It is meant to set up the SUT (System Under Test) in a manner that will ease the testing of its features. """ with logging_disabled(): # The B3TestCase class provides us a working B3 environment that does not require any database connexion. # The B3 console is then accessible with self.console B3TestCase.setUp(self) # set additional B3 console stuff that will be used by the XLRstats plugin self.console.gameName = "MyGame" self.parser_conf.add_section('b3') self.parser_conf.set('b3', 'time_zone', 'GMT') # we make our own AdminPlugin and make sure it is the one return in any case self.adminPlugin = AdminPlugin(self.console, DEFAULT_ADMIN_CONFIG_FILE) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() # We need a config for the Xlrstats plugin self.conf = CfgConfigParser() # It is an empty config but we can fill it up later # Now we create an instance of the SUT (System Under Test) which is the XlrstatsPlugin self.p = XlrstatsPlugin(self.console, self.conf) when(self.console).getPlugin("xlrstats").thenReturn(self.p) # create a client object to represent the game server with patch("b3.clients.Clients.authorizeClients"): # we patch authorizeClients or it will spawn a thread # with a 5 second timer self.console.clients.newClient(-1, name="WORLD", guid="WORLD", hide=True)
def setUp(self): B3TestCase.setUp(self) self.console.gameName = 'f00' self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.conf = CfgConfigParser() self.conf.loadFromString(dedent(r""" [commands] plugin: superadmin """)) self.p = PluginmanagerPlugin(self.console, self.conf) when(self.console).getPlugin("pluginmanager").thenReturn(self.adminPlugin) self.p.onLoadConfig() self.p.onStartup() when(self.console.config).get_external_plugins_dir().thenReturn(b3.getAbsolutePath('@b3\\extplugins')) # store them also in the console _plugins dict self.console._plugins['admin'] = self.adminPlugin self.console._plugins['pluginmanager'] = self.p
def setUp(self): logger = logging.getLogger('output') logger.propagate = False B3TestCase.setUp(self) self.pb = PunkBuster(self.console) logger.setLevel(VERBOSE2) logger.propagate = True
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: db = MySQLdb.connect(host='localhost', user='******', passwd='test') except MySQLdb.OperationalError, message: self.fail("Error %d:\n%s" % (message[0], message[1]))
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) self.storage = self.console.storage = SqliteStorage( 'sqlite://' + SQLITE_DB, splitDSN('sqlite://' + SQLITE_DB), self.console) self.storage.connect()
def setUp(self): B3TestCase.setUp(self) self.console.gameName = 'f00' self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.conf = CfgConfigParser() self.conf.loadFromString(dedent(r""" [settings] update_config_file: no [commands] cmdlevel: fulladmin cmdalias: fulladmin cmdgrant: superadmin cmdrevoke: superadmin cmduse: superadmin """)) self.p = CmdmanagerPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup()
def setUp(self): B3TestCase.setUp(self) when(self.console.config).get_external_plugins_dir().thenReturn(external_plugins_dir) self.conf = CfgConfigParser(testplugin_config_file) self.plugin_list = [ {'name': 'admin', 'conf': '@b3/conf/plugin_admin.ini', 'path': None, 'disabled': False}, ] fp, pathname, description = imp.find_module('testplugin1', [os.path.join(b3.getB3Path(True), '..', 'tests', 'plugins', 'fakeplugins')]) pluginModule1 = imp.load_module('testplugin1', fp, pathname, description) if fp: fp.close() fp, pathname, description = imp.find_module('testplugin3', [os.path.join(b3.getB3Path(True), '..', 'tests', 'plugins', 'fakeplugins')]) pluginModule3 = imp.load_module('testplugin3', fp, pathname, description) if fp: fp.close() fp, pathname, description = imp.find_module('admin', [os.path.join(b3.getB3Path(True), 'plugins')]) adminModule = imp.load_module('admin', fp, pathname, description) if fp: fp.close() when(self.console.config).get_plugins().thenReturn(self.plugin_list) when(self.console).pluginImport('admin', ANY).thenReturn(adminModule) when(self.console).pluginImport('testplugin1', ANY).thenReturn(pluginModule1) when(self.console).pluginImport('testplugin3', ANY).thenReturn(pluginModule3)
def setUp(self): B3TestCase.setUp(self) with logging_disabled(): self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini') when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.conf = CfgConfigParser() self.p = WelcomePlugin(self.console, self.conf) self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED) self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED) self.bill = FakeClient(self.console, name="Bill", guid="billguid", groupBits=1, team=b3.TEAM_RED) self.superadmin = FakeClient(self.console, name="SuperAdmin", guid="superadminguid", groupBits=128, team=b3.TEAM_RED)
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: conn = psycopg2.connect(host='localhost', user='******', password='******', database='postgres') except psycopg2.OperationalError, message: self.fail("Error %d:\n%s" % (message[0], message[1]))
def setUp(self): B3TestCase.setUp(self) with logging_disabled(): admin_conf = CfgConfigParser() admin_plugin = AdminPlugin(self.console, admin_conf) admin_plugin.onLoadConfig() admin_plugin.onStartup() when(self.console).getPlugin('admin').thenReturn(admin_plugin) conf = CfgConfigParser() conf.loadFromString(dedent(r""" [commands] mapstats-stats: 0 testscore-ts: 0 topstats-top: 0 topxp: 0 [settings] startPoints: 100 resetscore: no resetxp: no show_awards: no show_awards_xp: no """)) self.p = StatsPlugin(self.console, conf) self.p.onLoadConfig() self.p.onStartup() self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=TEAM_RED) self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=TEAM_RED) self.joe.connects(1) self.mike.connects(2)
def setUp(self): B3TestCase.setUp(self) self.conf = XmlConfigParser() self.conf.load(ADMIN_CONFIG_FILE) self.p = AdminPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup()
def setUp(self): B3TestCase.setUp(self) self.conf = XmlConfigParser() self.conf.setXml(""" <configuration plugin="admin"> </configuration> """) self.p = AdminPlugin(b3.console, self.conf)
def setUp(self): B3TestCase.setUp(self) self.queueEvent_patcher = patch.object(self.console, 'queueEvent') self.queueEvent_mock = self.queueEvent_patcher.start() self.admin = Client(console=self.console) self.client = Client(console=self.console) self.client.save()
def setUp(self): from b3.fake import fakeConsole B3TestCase.setUp(self) self.conf = XmlConfigParser() self.conf.setXml(""" <configuration plugin="admin"> </configuration> """) self.p = AdminPlugin(fakeConsole, self.conf)
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: db = driver.connect(host=MYSQL_TEST_HOST, user=MYSQL_TEST_USER, password=MYSQL_TEST_PASSWORD) except driver.OperationalError, message: self.fail("Error %d:\n%s" % (message[0], message[1]))
def setUp(self): B3TestCase.setUp(self) logging.getLogger('output').setLevel(logging.DEBUG) with logging_disabled(): self.console.startup() self.conf = CfgConfigParser() self.p = ChatloggerPlugin(self.console, self.conf) ## prepare the mysql test database db = MySQLdb.connect(host=MYSQL_TEST_HOST, user=MYSQL_TEST_USER, passwd=MYSQL_TEST_PASSWORD) db.query("DROP DATABASE IF EXISTS %s" % MYSQL_TEST_DB) db.query("CREATE DATABASE %s CHARACTER SET utf8;" % MYSQL_TEST_DB) self.console.storage = DatabaseStorage( 'mysql://%s:%s@%s/%s' % (MYSQL_TEST_USER, MYSQL_TEST_PASSWORD, MYSQL_TEST_HOST, MYSQL_TEST_DB), self.console) self.console.storage.executeSql("@b3/sql/b3.sql") self.console.storage.executeSql(CHATLOGGER_SQL_FILE) when(self.console.config).get('b3', 'time_zone').thenReturn('GMT') self.p.setup_fileLogger = Mock() self.conf.loadFromString( dedent(""" [general] save_to_database: Yes save_to_file: no [file] logfile: @conf/chat.log rotation_rate: D [purge] max_age: 0 hour: 0 min: 0 """)) with logging_disabled(): self.p.onLoadConfig() self.p.onStartup() self.joe = FakeClient(self.console, name="Joe", guid="joe_guid", team=TEAM_RED) self.simon = FakeClient(self.console, name="Simon", guid="simon_guid", team=TEAM_BLUE) self.joe.connects(1) self.simon.connects(3) self.assertEqual(0, self.count_chatlog_lines()) self.assertEqual(0, self.count_cmdlog_lines())
def setUp(self): B3TestCase.setUp(self) self.conf = XmlConfigParser() self.conf.load(ADMIN_CONFIG_FILE) self.p = AdminPlugin(self.console, self.conf) self.p.onLoadConfig() self.p.onStartup() self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="joeguid", groupBits=128, team=TEAM_RED) self.mike = FakeClient(self.console, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=TEAM_BLUE)
def setUp(self): self.timer_patcher = patch('threading.Timer') self.timer_patcher.start() self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.console.startup() self.log.propagate = True
def setUp(self): B3TestCase.setUp(self) mockito.when(self.console.config).get_external_plugins_dir().thenReturn(external_plugins_dir) self.conf = CfgConfigParser(testplugin_config_file) self.plugin_list = [ {'name': 'admin', 'conf': '@b3/conf/plugin_admin.ini', 'path': None, 'disabled': False}, ] mockito.when(self.console.config).get_plugins().thenReturn(self.plugin_list)
def setUp(self): B3TestCase.setUp(self) self.conf = XmlConfigParser() self.conf.setXml(""" <configuration plugin="test"> <settings name="settings"> <set name="output_file">@conf/status.xml</set> </settings> </configuration> """)
def setUp(self): B3TestCase.setUp(self) self.client = Client(console=self.console) self.group_guest = self.console.storage.getGroup(Group(keyword="guest")) self.group_user = self.console.storage.getGroup(Group(keyword="user")) self.group_reg = self.console.storage.getGroup(Group(keyword="reg")) self.group_mod = self.console.storage.getGroup(Group(keyword="mod")) self.group_admin = self.console.storage.getGroup(Group(keyword="admin")) self.group_fulladmin = self.console.storage.getGroup(Group(keyword="fulladmin")) self.group_senioradmin = self.console.storage.getGroup(Group(keyword="senioradmin")) self.group_superadmin = self.console.storage.getGroup(Group(keyword="superadmin"))
def setUp(self): B3TestCase.setUp(self) with logging_disabled(): self.console.startup() logging.getLogger('output').setLevel(logging.DEBUG) self.conf = CfgConfigParser() self.p = ChatloggerPlugin(self.console, self.conf) when(self.console.config).get('b3', 'time_zone').thenReturn('GMT') self.p.setup_fileLogger = Mock()
def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.adminPlugin = AdminPlugin(self.console, ADMIN_CONFIG) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.console.startup() self.log.propagate = True
def setUp(self): # Timer needs to be patched or the Censor plugin would schedule a 2nd check one minute after # penalizing a player. self.timer_patcher = patch('threading.Timer') self.timer_patcher.start() self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.console.startup() self.log.propagate = True self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, team=b3.TEAM_UNKNOWN)
def setUp(self): B3TestCase.setUp(self) self.conf = XmlConfigParser() self.conf.setXml(""" <configuration plugin="admin"> <settings name="warn"> <set name="warn_delay">5</set> </settings> </configuration> """) self.p = AdminPlugin(b3.console, self.conf) self.mock_client = Mock(spec=Client, name="client") self.mock_client.maxLevel = 0 self.mock_client.exactName = "MockClient" self.mock_command = Mock(spec=Command, name='cmd')
def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) admin_conf = XmlConfigParser() admin_conf.load(ADMIN_CONFIG_FILE) self.adminPlugin = AdminPlugin(self.console, admin_conf) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.console.gameName = "theGame" self.console.startup() self.log.propagate = True
def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) admin_conf = CfgConfigParser() admin_conf.load(b3.getAbsolutePath('@b3/conf/plugin_admin.ini')) self.adminPlugin = AdminPlugin(self.console, admin_conf) when(self.console).getPlugin("admin").thenReturn(self.adminPlugin) self.adminPlugin.onLoadConfig() self.adminPlugin.onStartup() self.console.gameName = "theGame" self.console.startup() self.log.propagate = True
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: dsn = "postgresql://%s:%s@%s/%s" % (POSTGRESQL_TEST_USER, POSTGRESQL_TEST_PASSWORD, POSTGRESQL_TEST_HOST, POSTGRESQL_TEST_DB) self.storage = self.console.storage = PostgresqlStorage(dsn, splitDSN(dsn), self.console) self.storage.connect() tables = self.storage.getTables() if tables: # dont remove the groups table since we would need it in next tests tables.remove('groups') self.storage.truncateTable(tables) except Exception, e: self.fail("Error: %s" % e)
def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.console.startup() self.log.propagate = True self.log.setLevel(logging.DEBUG) self.conf = XmlConfigParser() self.p = ChatloggerPlugin(self.console, self.conf) when(self.console.config).get('b3', 'time_zone').thenReturn('GMT') when(b3).getB3Path().thenReturn("c:\\b3_folder") when(b3).getConfPath().thenReturn("c:\\b3_conf_folder") self.p.setup_fileLogger = Mock()
def setUp(self): self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.console.screen = Mock() self.console.time = time.time self.console.upTime = Mock(return_value=3) self.p = GeolocationPlugin(self.console) self.p.onLoadConfig() self.p.onStartup() self.log.propagate = True self.mike = FakeClient(console=self.console, name="Mike", guid="MIKEGUID", groupBits=1)
def setUp(self): # Timer needs to be patched or the Censor plugin would schedule a 2nd check one minute after # penalizing a player. self.timer_patcher = patch('threading.Timer') self.timer_patcher.start() self.log = logging.getLogger('output') self.log.propagate = False B3TestCase.setUp(self) self.console.startup() self.log.propagate = True self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, team=b3.TEAM_UNKNOWN) self.conf = XmlConfigParser() self.p = CensorurtPlugin(self.console, self.conf)
def setUp(self): B3TestCase.setUp(self) logging.getLogger('output').setLevel(logging.DEBUG) with logging_disabled(): self.console.startup() self.conf = CfgConfigParser() self.p = ChatloggerPlugin(self.console, self.conf) ## prepare the mysql test database db = MySQLdb.connect(host=MYSQL_TEST_HOST, user=MYSQL_TEST_USER, passwd=MYSQL_TEST_PASSWORD) db.query("DROP DATABASE IF EXISTS %s" % MYSQL_TEST_DB) db.query("CREATE DATABASE %s CHARACTER SET utf8;" % MYSQL_TEST_DB) self.console.storage = DatabaseStorage( 'mysql://%s:%s@%s/%s' % (MYSQL_TEST_USER, MYSQL_TEST_PASSWORD, MYSQL_TEST_HOST, MYSQL_TEST_DB), self.console) self.console.storage.executeSql("@b3/sql/b3.sql") self.console.storage.executeSql(CHATLOGGER_SQL_FILE) when(self.console.config).get('b3', 'time_zone').thenReturn('GMT') self.p.setup_fileLogger = Mock() self.conf.loadFromString(dedent(""" [general] save_to_database: Yes save_to_file: no [file] logfile: @conf/chat.log rotation_rate: D [purge] max_age: 0 hour: 0 min: 0 """)) with logging_disabled(): self.p.onLoadConfig() self.p.onStartup() self.joe = FakeClient(self.console, name="Joe", guid="joe_guid", team=TEAM_RED) self.simon = FakeClient(self.console, name="Simon", guid="simon_guid", team=TEAM_BLUE) self.joe.connects(1) self.simon.connects(3) self.assertEqual(0, self.count_chatlog_lines()) self.assertEqual(0, self.count_cmdlog_lines())
def setUp(self): """ This method is called before each test. It is meant to set up the SUT (System Under Test) in a manner that will ease the testing of its features. """ # The B3TestCase class provides us a working B3 environment that does not require any database connexion. # The B3 console is then accessible with self.console B3TestCase.setUp(self) # We need a config for the Xlrstats plugin self.conf = CfgConfigParser() # It is an empty config but we can fill it up later # Now we create an instance of the SUT (System Under Test) which is the XlrstatsPlugin self.p = XlrstatsPlugin(self.console, self.conf) # Setup the logging level we'd like to be spammed with during the tests logger = logging.getLogger('output') logger.setLevel(logging.DEBUG)
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: dsn = "postgresql://%s:%s@%s/%s" % ( POSTGRESQL_TEST_USER, POSTGRESQL_TEST_PASSWORD, POSTGRESQL_TEST_HOST, POSTGRESQL_TEST_DB) self.storage = self.console.storage = PostgresqlStorage( dsn, splitDSN(dsn), self.console) self.storage.connect() tables = self.storage.getTables() if tables: # dont remove the groups table since we would need it in next tests tables.remove('groups') self.storage.truncateTable(tables) except Exception, e: self.fail("Error: %s" % e)
def setUp(self): """ This method is called before each test. It is meant to set up the SUT (System Under Test) in a manner that will ease the testing of its features. """ # The B3TestCase class provides us a working B3 environment that does not require any database connexion. # The B3 console is then accessible with self.console B3TestCase.setUp(self) # We need a config for the Xlrstats plugin self.conf = CfgConfigParser( ) # It is an empty config but we can fill it up later # Now we create an instance of the SUT (System Under Test) which is the XlrstatsPlugin self.p = XlrstatsPlugin(self.console, self.conf) # Setup the logging level we'd like to be spammed with during the tests logger = logging.getLogger('output') logger.setLevel(logging.DEBUG)
def setUp(self): B3TestCase.setUp(self) with logging_disabled(): admin_conf = CfgConfigParser() admin_plugin = AdminPlugin(self.console, admin_conf) admin_plugin.onLoadConfig() admin_plugin.onStartup() when(self.console).getPlugin('admin').thenReturn(admin_plugin) conf = CfgConfigParser() conf.loadFromString( dedent(r""" [commands] mapstats-stats: 0 testscore-ts: 0 topstats-top: 0 topxp: 0 [settings] startPoints: 100 resetscore: no resetxp: no show_awards: no show_awards_xp: no """)) self.p = StatsPlugin(self.console, conf) self.p.onLoadConfig() self.p.onStartup() self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=TEAM_RED) self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=TEAM_RED) self.joe.connects(1) self.mike.connects(2)
def setUp(self): """this method is called before each test""" B3TestCase.setUp(self) try: db = driver.connect(host=MYSQL_TEST_HOST, user=MYSQL_TEST_USER, password=MYSQL_TEST_PASSWORD) except driver.OperationalError as message: self.fail("Error %d:\n%s" % (message[0], message[1])) db.query("DROP DATABASE IF EXISTS `%s`" % MYSQL_TEST_DB) db.query("CREATE DATABASE `%s` CHARACTER SET utf8;" % MYSQL_TEST_DB) dsn = "mysql://%s:%s@%s/%s" % (MYSQL_TEST_USER, MYSQL_TEST_PASSWORD, MYSQL_TEST_HOST, MYSQL_TEST_DB) self.storage = self.console.storage = MysqlStorage( dsn, splitDSN(dsn), self.console) self.storage.connect()
def setUp(self): B3TestCase.setUp(self) self.conf = CfgConfigParser() self.conf.loadFromString(dedent(""" [section_foo] option_str: string value with spaces option_int: 7 option_bool1: false option_bool2: true option_bool3: 0 option_bool4: 1 option_bool5: 2 option_float: 0.97 option_level1: senioradmin option_level2: guest option_level3: badkeyword option_duration1: 300 option_duration2: 3h option_path: @b3/conf/b3.distribution.ini """)) self.p = MyPlugin(self.console, self.conf)