本文整理汇总了Python中example_block.tests.factories.TitleFactory.ordered_slideshow方法的典型用法代码示例。如果您正苦于以下问题:Python TitleFactory.ordered_slideshow方法的具体用法?Python TitleFactory.ordered_slideshow怎么用?Python TitleFactory.ordered_slideshow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类example_block.tests.factories.TitleFactory
的用法示例。
在下文中一共展示了TitleFactory.ordered_slideshow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wizard_image_choose_category_multi
# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import ordered_slideshow [as 别名]
def test_wizard_image_choose_category_multi(client):
"""Choose from images in the selected category."""
content = TitleFactory()
category = ImageCategoryFactory()
ImageFactory()
image_2 = ImageFactory(category=category)
ImageFactory(category=category)
image_4 = ImageFactory(category=category)
user = UserFactory(is_staff=True)
assert content.picture is None
assert client.login(username=user.username, password=TEST_PASSWORD) is True
url = url_image_multi(content, 'block.wizard.image.choose', category=category)
assert category.slug in url
data = {
'images': [image_2.pk, image_4.pk],
}
response = client.post(url, data)
# check
assert 302 == response.status_code
expect = url_image_multi(content, 'block.wizard.image.option')
assert expect in response['Location']
content.refresh_from_db()
assert 2 == content.slideshow.count()
# ordering controlled by 'ordering' on 'TitleImage' model
assert [1, 2] == [item.order for item in content.ordered_slideshow()]
示例2: test_wizard_image_select_multi
# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import ordered_slideshow [as 别名]
def test_wizard_image_select_multi(client):
"""The single test for removing is ``test_wizard_image_remove_single``."""
image_1 = ImageFactory()
image_2 = ImageFactory()
image_3 = ImageFactory()
image_4 = ImageFactory()
content = TitleFactory()
through_1 = TitleImageFactory(content=content, image=image_1, order=4)
TitleImageFactory(content=content, image=image_2, order=3)
through_3 = TitleImageFactory(content=content, image=image_3, order=2)
TitleImageFactory(content=content, image=image_4, order=1)
user = UserFactory(is_staff=True)
assert client.login(username=user.username, password=TEST_PASSWORD) is True
url = url_image_multi(content, 'block.wizard.image.select')
data = {
'many_to_many': [through_1.pk, through_3.pk],
}
response = client.post(url, data)
# check
assert 302 == response.status_code
expect = url_image_multi(content, 'block.wizard.image.option')
assert expect in response['Location']
content.refresh_from_db()
assert 2 == content.slideshow.count()
qs = content.ordered_slideshow()
result = [item.image.pk for item in qs]
assert image_1.pk in result and image_3.pk in result
# ordering controlled by 'ordering' on 'TitleImage' model
assert [1, 2] == [item.order for item in qs]
示例3: test_wizard_image_order_multi_up_4
# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import ordered_slideshow [as 别名]
def test_wizard_image_order_multi_up_4(client):
content = TitleFactory()
t1, t2, t3, t4 = _set_up_order_multi(content)
_post_multi_order(client, content, {'up': t4.pk})
assert [
t1.pk, t2.pk, t4.pk, t3.pk
] == [item.pk for item in content.ordered_slideshow()]
示例4: test_wizard_image_order_multi_up_invalid
# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import ordered_slideshow [as 别名]
def test_wizard_image_order_multi_up_invalid(client):
content = TitleFactory()
t1, t2, t3, t4 = _set_up_order_multi(content)
with pytest.raises(BlockError) as e:
_post_multi_order(client, content, {'up': t1.pk+t2.pk+t3.pk+t4.pk})
assert 'Cannot find item' in str(e.value)
assert [
t1.pk, t2.pk, t3.pk, t4.pk
] == [item.pk for item in content.ordered_slideshow()]
示例5: test_wizard_image_order_multi_up_1
# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import ordered_slideshow [as 别名]
def test_wizard_image_order_multi_up_1(client):
"""Trying to move the first item up, should raise an exception."""
content = TitleFactory()
t1, t2, t3, t4 = _set_up_order_multi(content)
with pytest.raises(BlockError) as e:
_post_multi_order(client, content, {'up': t1.pk})
assert 'Cannot move the first item up' in str(e.value)
assert [
t1.pk, t2.pk, t3.pk, t4.pk
] == [item.pk for item in content.ordered_slideshow()]
示例6: test_wizard_image_choose_multi
# 需要导入模块: from example_block.tests.factories import TitleFactory [as 别名]
# 或者: from example_block.tests.factories.TitleFactory import ordered_slideshow [as 别名]
def test_wizard_image_choose_multi(client):
content = TitleFactory()
ImageFactory(title='0')
image_1 = ImageFactory(title='1')
image_2 = ImageFactory(title='2')
user = UserFactory(is_staff=True)
assert content.picture is None
assert client.login(username=user.username, password=TEST_PASSWORD) is True
url = url_image_multi(content, 'block.wizard.image.choose')
data = {
'images': [image_2.pk, image_1.pk],
}
response = client.post(url, data)
# check
assert 302 == response.status_code, response.context['form'].errors
expect = url_image_multi(content, 'block.wizard.image.option')
assert expect in response['Location']
content.refresh_from_db()
assert 2 == content.slideshow.count()
# ordering controlled by 'ordering' on 'TitleImage' model
assert [1, 2] == [item.order for item in content.ordered_slideshow()]