本文整理汇总了Python中logger.accesschecker.AccessChecker._parse_line方法的典型用法代码示例。如果您正苦于以下问题:Python AccessChecker._parse_line方法的具体用法?Python AccessChecker._parse_line怎么用?Python AccessChecker._parse_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.accesschecker.AccessChecker
的用法示例。
在下文中一共展示了AccessChecker._parse_line方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_line_with_apache_line
# 需要导入模块: from logger.accesschecker import AccessChecker [as 别名]
# 或者: from logger.accesschecker.AccessChecker import _parse_line [as 别名]
def test_parse_line_with_apache_line(self):
accesschecker = self.mocker.patch(AccessChecker)
accesschecker._allowed_collections()
self.mocker.result([u'scl', u'arg'])
accesschecker._acronym_to_issn_dict()
self.mocker.result({u'zool': u'1984-4670', u'bjmbr': u'1414-431X'})
self.mocker.replay()
ac = AccessChecker(collection='scl')
line = '187.19.211.179 - - [30/May/2013:00:01:01 -0300] "GET http://www.scielo.br/scielo.php?pid=S0100-736X2000000300007&script=sci_arttext HTTP/1.1" 200 25084 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"'
expected = {
'%l': '-',
'%>s': '200',
'%h': '187.19.211.179',
'%{User-Agent}i': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)',
'%b': '25084',
'%{Referer}i': '-',
'%u': '-',
'%t': '[30/May/2013:00:01:01 -0300]',
'%r': 'GET http://www.scielo.br/scielo.php?pid=S0100-736X2000000300007&script=sci_arttext HTTP/1.1'
}
self.assertEqual(ac._parse_line(line), expected)
line = '123.125.71.39 - - [30/Dec/2012:23:59:57 -0200] "GET /scielo.php?script=sci_nlinks&ref=000144&pid=S0103-4014200000020001300010&lng=pt HTTP/1.1" 200 1878 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"'
expected = {
'%l': '-',
'%>s': '200',
'%h': '123.125.71.39',
'%{User-Agent}i': 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)',
'%b': '1878',
'%{Referer}i': '-',
'%u': '-',
'%t': '[30/Dec/2012:23:59:57 -0200]',
'%r': 'GET /scielo.php?script=sci_nlinks&ref=000144&pid=S0103-4014200000020001300010&lng=pt HTTP/1.1'
}
self.assertEqual(ac._parse_line(line), expected)
示例2: test_parse_line_invalid_line
# 需要导入模块: from logger.accesschecker import AccessChecker [as 别名]
# 或者: from logger.accesschecker.AccessChecker import _parse_line [as 别名]
def test_parse_line_invalid_line(self):
accesschecker = self.mocker.patch(AccessChecker)
accesschecker._allowed_collections()
self.mocker.result([u'scl', u'arg'])
accesschecker._acronym_to_issn_dict()
self.mocker.result({u'zool': u'1984-4670', u'bjmbr': u'1414-431X'})
self.mocker.replay()
ac = AccessChecker(collection='scl')
line = ''
self.assertEqual(ac._parse_line(line), None)