def testLogPrint(self): """Test equality of log_print function and access_log""" options = { 'limit': 20, 'requester': None, 'method': None, 'reverse': None, 'code': None, 'start': None, 'end': None } try: wtf = WTFttp(AccessLog('tests/access_log'), options) result = wtf.log_print(suppress_print=True) self.assertEqual(result, _ACCESS_LOG) finally: wtf.access_log.close()
def testLogRequestsWithCodes(self): """Test response code argument accuracy""" options = { 'limit': 20, 'requester': None, 'method': None, 'reverse': None, 'code': 403, 'start': None, 'end': None } try: wtf = WTFttp(AccessLog('tests/access_log'), options) result = wtf.log_requests(suppress_print=True) self.assertEqual(result, _REQUESTS_WITH_CODE) finally: wtf.access_log.close()
def testLogDomains(self): """Test log_domains function accuracy""" options = { 'limit': 20, 'requester': None, 'method': None, 'reverse': None, 'code': None, 'start': None, 'end': None } try: wtf = WTFttp(AccessLog('tests/access_log'), options) result = wtf.log_domains(suppress_print=True) self.assertEqual(result, _DOMAINS) finally: wtf.access_log.close()
def testLogRequesters(self): """Test log_requesters function accuracy""" m = self._datetime_re.match('2011/02/24') date_list = [ int(x) for x in m.groups() if x is not None ] start = datetime(*date_list) m = self._datetime_re.match('2011/02/25') date_list = [ int(x) for x in m.groups() if x is not None ] end = datetime(*date_list) options = { 'limit': 3, 'requester': None, 'method': 'GET', 'reverse': None, 'code': None, 'start': start, 'end': end } try: wtf = WTFttp(AccessLog('tests/access_log'), options) result = wtf.log_requesters(suppress_print=True) self.assertEqual(result, _REQUESTERS) finally: wtf.access_log.close()