本文整理汇总了Python中snippets.base.tests.SnippetFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python SnippetFactory.create_batch方法的具体用法?Python SnippetFactory.create_batch怎么用?Python SnippetFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snippets.base.tests.SnippetFactory
的用法示例。
在下文中一共展示了SnippetFactory.create_batch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_snippets
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import create_batch [as 别名]
def test_snippets(self):
instance = UploadedFileFactory.build()
instance.file = MagicMock()
instance.file.url = '/media/foo.png'
snippets = SnippetFactory.create_batch(2, data='lalala {0} foobar'.format(instance.url))
template = SnippetTemplateFactory.create(code='<foo>{0}</foo>'.format(instance.url))
more_snippets = SnippetFactory.create_batch(3, template=template)
self.assertEqual(set(instance.snippets), set(list(snippets) + list(more_snippets)))
示例2: test_snippet
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import create_batch [as 别名]
def test_snippet(self):
nightly_snippets = SnippetFactory.create_batch(
2, on_release=False, on_nightly=True)
SnippetFactory.create_batch(2, on_release=False, on_beta=True)
filtr = ChannelFilter(None, {'channel': 'on_nightly'}, Snippet, SnippetAdmin)
result = filtr.queryset(None, Snippet.objects.all())
self.assertTrue(result.count(), 2)
self.assertEqual(set(result.all()), set(nightly_snippets))
示例3: test_base
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import create_batch [as 别名]
def test_base(self):
snippets = SnippetFactory.create_batch(2)
jsonsnippets = JSONSnippetFactory.create_batch(2)
SnippetFactory.create(disabled=True)
JSONSnippetFactory.create(disabled=True)
response = views.ActiveSnippetsView.as_view()(self.request)
eq_(response.get('content-type'), 'application/json')
data = json.loads(response.content)
eq_(set([snippets[0].id, snippets[1].id,
jsonsnippets[0].id, jsonsnippets[1].id]),
set([x['id'] for x in data]))
示例4: setUp
# 需要导入模块: from snippets.base.tests import SnippetFactory [as 别名]
# 或者: from snippets.base.tests.SnippetFactory import create_batch [as 别名]
def setUp(self):
self.snippet1, self.snippet2 = SnippetFactory.create_batch(2)