本文整理汇总了Python中kitsune.questions.tests.QuestionFactory.add_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionFactory.add_metadata方法的具体用法?Python QuestionFactory.add_metadata怎么用?Python QuestionFactory.add_metadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kitsune.questions.tests.QuestionFactory
的用法示例。
在下文中一共展示了QuestionFactory.add_metadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_weird_list_troubleshooting_info
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import add_metadata [as 别名]
def test_weird_list_troubleshooting_info(self):
"""Test the corner case in which 'modifiedPReferences' is in a
list in troubleshooting data. This is weird, but caused a bug."""
q = QuestionFactory()
q.add_metadata(troubleshooting='["modifiedPreferences"]')
# This case should not raise an error.
response = get(self.client, 'questions.details', args=[q.id])
eq_(200, response.status_code)
示例2: test_empty_troubleshooting_info
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import add_metadata [as 别名]
def test_empty_troubleshooting_info(self):
"""Test a troubleshooting value that is valid JSON, but junk.
This should trigger the parser to return None, which should not
cause a 500.
"""
q = QuestionFactory()
q.add_metadata(troubleshooting='{"foo": "bar"}')
# This case should not raise an error.
response = get(self.client, 'questions.details', args=[q.id])
eq_(200, response.status_code)
示例3: TestQuestionMetadata
# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import add_metadata [as 别名]
class TestQuestionMetadata(TestCaseBase):
"""Tests handling question metadata"""
def setUp(self):
super(TestQuestionMetadata, self).setUp()
# add a new Question to test with
self.question = QuestionFactory(title='Test Question', content='Lorem Ipsum Dolor')
def test_add_metadata(self):
"""Test the saving of metadata."""
metadata = {'version': u'3.6.3', 'os': u'Windows 7'}
self.question.add_metadata(**metadata)
saved = QuestionMetaData.objects.filter(question=self.question)
eq_(dict((x.name, x.value) for x in saved), metadata)
def test_metadata_property(self):
"""Test the metadata property on Question model."""
self.question.add_metadata(crash_id='1234567890')
eq_('1234567890', self.question.metadata['crash_id'])
def test_product_property(self):
"""Test question.product property."""
self.question.add_metadata(product='desktop')
eq_(config.products['desktop'], self.question.product_config)
def test_category_property(self):
"""Test question.category property."""
self.question.add_metadata(product='desktop')
self.question.add_metadata(category='fix-problems')
eq_(config.products['desktop']['categories']['fix-problems'],
self.question.category_config)
def test_clear_mutable_metadata(self):
"""Make sure it works and clears the internal cache.
crash_id should get cleared, while product, category, and useragent
should remain.
"""
q = self.question
q.add_metadata(product='desktop', category='fix-problems',
useragent='Fyerfocks', crash_id='7')
q.metadata
q.clear_mutable_metadata()
md = q.metadata
assert 'crash_id' not in md, \
"clear_mutable_metadata() didn't clear the cached metadata."
eq_(dict(product='desktop', category='fix-problems',
useragent='Fyerfocks'),
md)
def test_auto_tagging(self):
"""Make sure tags get applied based on metadata on first save."""
Tag.objects.create(slug='green', name='green')
Tag.objects.create(slug='Fix problems', name='fix-problems')
q = self.question
q.add_metadata(product='desktop', category='fix-problems',
ff_version='3.6.8', os='GREen')
q.save()
q.auto_tag()
tags_eq(q, ['desktop', 'fix-problems', 'Firefox 3.6.8', 'Firefox 3.6',
'green'])
def test_auto_tagging_aurora(self):
"""Make sure versions with prerelease suffix are tagged properly."""
q = self.question
q.add_metadata(ff_version='18.0a2')
q.save()
q.auto_tag()
tags_eq(q, ['Firefox 18.0'])
def test_auto_tagging_restraint(self):
"""Auto-tagging shouldn't tag unknown Firefox versions or OSes."""
q = self.question
q.add_metadata(ff_version='allyourbase', os='toaster 1.0')
q.save()
q.auto_tag()
tags_eq(q, [])
def test_tenths_version(self):
"""Test the filter that turns 1.2.3 into 1.2."""
eq_(_tenths_version('1.2.3beta3'), '1.2')
eq_(_tenths_version('1.2rc'), '1.2')
eq_(_tenths_version('1.w'), '')
def test_has_beta(self):
"""Test the _has_beta helper."""
assert _has_beta('5.0', {'5.0b3': '2011-06-01'})
assert not _has_beta('6.0', {'5.0b3': '2011-06-01'})
assert not _has_beta('5.5', {'5.0b3': '2011-06-01'})
assert _has_beta('5.7', {'5.7b1': '2011-06-01'})
assert _has_beta('11.0', {'11.0b7': '2011-06-01'})
assert not _has_beta('10.0', {'11.0b7': '2011-06-01'})