本文整理汇总了Python中dashboards.models.WikiDocumentVisits._visit_counts方法的典型用法代码示例。如果您正苦于以下问题:Python WikiDocumentVisits._visit_counts方法的具体用法?Python WikiDocumentVisits._visit_counts怎么用?Python WikiDocumentVisits._visit_counts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dashboards.models.WikiDocumentVisits
的用法示例。
在下文中一共展示了WikiDocumentVisits._visit_counts方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_good_visit_count
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_good_visit_count(self):
"""Extract visit counts from good data.
It has some nasty non-ASCII chars in it.
"""
d = document(slug="hellỗ")
d.save()
d2 = document(slug="there")
d2.save()
# We get a str, not a unicode obj, out of the urllib call.
eq_(
{d.pk: 1037639, d2.pk: 213817},
WikiDocumentVisits._visit_counts(
'{"data": {"12/01/2010-12/07/2010": {"SubRows":{'
'"http://support.mozilla.com/%s/kb/hellỗ":{"Attributes":{"Title":'
'"Firefox Support Home Page | Firefox Support","UrlLink":'
'"http://support.mozilla.com/en-US/home/"},"measures":'
'{"Visits":1037639.0,"Views":3357731.0,"Average Time Viewed":23.0'
'},"SubRows":null},"http://support.mozilla.com/%s/kb/there":'
'{"Attributes":{"Title":"Startseite der Firefox-Hilfe | Firefox'
'Support","UrlLink":"http://support.mozilla.com/de/home/"},'
'"measures":{"Visits":213817.0,"Views":595329.0,"Average Time '
'Viewed":25.0},"SubRows":null}}}}}' % ((settings.LANGUAGE_CODE,) * 2)
),
)
示例2: test_bad_visit_count
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_bad_visit_count(self):
"""Skip URLs whose visit counts aren't ints."""
d = revision(is_approved=True, save=True).document
eq_({}, WikiDocumentVisits._visit_counts('{"data": {"12/01/2010-12/07/'
'2010": {"SubRows":{"http://support.mozilla.com/%s/kb/%s":{'
'"measures":{"Visits":"non-integer"}}}}}}'
% (settings.LANGUAGE_CODE, d.slug)))
示例3: test_foreign_locale
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_foreign_locale(self):
"""Skip URLs with non-English locale."""
eq_(
{},
WikiDocumentVisits._visit_counts(
'{"data": {"12/01/2010-12/07/' '2010": {"SubRows":{"http://support.mozilla.com/zh/home/":8}}}}'
),
)
示例4: test_unknown_view
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_unknown_view(self):
"""Skip URLs that don't resolve."""
eq_(
{},
WikiDocumentVisits._visit_counts(
'{"data": {"12/01/2010-12/07/'
'2010": {"SubRows":{"http://support.mozilla.com/%s/unknown/":8}}}}' % settings.LANGUAGE_CODE
),
)
示例5: test_non_document_view
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_non_document_view(self):
"""Skip URLs that don't resolve to the wiki document view."""
eq_(
{},
WikiDocumentVisits._visit_counts(
'{"data": {"12/01/2010-12/07/'
'2010": {"SubRows":{"http://support.mozilla.com/%s/contributors":8'
"}}}}" % settings.LANGUAGE_CODE
),
)
示例6: test_bad_page_info
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_bad_page_info(self):
"""Skip URLs whose page info is unsubscriptable."""
d = document()
d.save()
eq_(
{},
WikiDocumentVisits._visit_counts(
'{"data": {"12/01/2010-12/07/'
'2010": {"SubRows":{"http://support.mozilla.com/%s/kb/%s":8}}}}' % (settings.LANGUAGE_CODE, d.slug)
),
)
示例7: test_no_pages
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_no_pages(self):
"""Don't pave over current data if WebTrends returns well-formatted
data structure with no interesting data in it."""
# Get some JSON that contains no interesting data.
no_pages = '{"data": {"12/01/2010-12/07/2010": {"SubRows": {}}}}'
counts = WikiDocumentVisits._visit_counts(no_pages)
eq_({}, counts) # Make sure nothing interesting is there.
# Try to reload visits table from the uninteresting data:
d = document()
d.save()
v = WikiDocumentVisits.objects.create(document=d, visits=12, period=THIS_WEEK)
WikiDocumentVisits.reload_period_from_json(THIS_WEEK, no_pages)
# Visits table should remain unchanged:
eq_(1, WikiDocumentVisits.objects.filter(pk=v.pk).count())
示例8: test_no_locale
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_no_locale(self):
"""Skip URLs with no locale."""
eq_({}, WikiDocumentVisits._visit_counts('{"data": {"12/01/2010-12/07/'
'2010": {"SubRows":{"http://support.mozilla.com/home":8}}}}'))
示例9: test_not_subscriptable
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_not_subscriptable(self):
"""Raise a nice err if WebTrends returns an unsubscriptable obj."""
WikiDocumentVisits._visit_counts('8')
示例10: test_no_data_attr
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_no_data_attr(self):
"""Raise a nice err if WebTrends returns an obj with no 'data' attr."""
WikiDocumentVisits._visit_counts('{}')
示例11: test_bad_json
# 需要导入模块: from dashboards.models import WikiDocumentVisits [as 别名]
# 或者: from dashboards.models.WikiDocumentVisits import _visit_counts [as 别名]
def test_bad_json(self):
"""Raise a nice error if WebTrends hands us bad JSON."""
WikiDocumentVisits._visit_counts('{')