當前位置: 首頁>>代碼示例>>Python>>正文


Python TitleFactory.ordered_slideshow方法代碼示例

本文整理匯總了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()]
開發者ID:,項目名稱:,代碼行數:27,代碼來源:

示例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]
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例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()]
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例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()]
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例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()]
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例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()]
開發者ID:pkimber,項目名稱:block,代碼行數:23,代碼來源:test_view_image_wizard.py


注:本文中的example_block.tests.factories.TitleFactory.ordered_slideshow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。