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) 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): 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) when(self.console.config).get('b3', 'time_zone').thenReturn('GMT') self.conf.loadFromString(dedent(""" [general] save_to_database: no save_to_file: yes [file] logfile: @conf/chat.log rotation_rate: D [purge] max_age: 0 hour: 0 min: 0 """)) self.temp_conf_folder = mkdtemp(suffix="b3_conf") when(b3).getConfPath().thenReturn(self.temp_conf_folder) with logging_disabled(): self.p.onLoadConfig() self.p.onStartup() self.chat_log_file = os.path.join(self.temp_conf_folder, 'chat.log') with logging_disabled(): 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)