Ejemplo n.º 1
0
def test_remove_already():
    """content has already been removed and cannot be removed again."""
    block = TitleBlockFactory()
    TitleFactory(block=block)
    block.remove(UserFactory())
    with pytest.raises(BlockError) as e:
        block.remove(UserFactory())
    assert 'Cannot find pending or published content to remove' in str(e.value)
Ejemplo n.º 2
0
def test_remove_pending():
    """remove pending content."""
    page_section = PageSectionFactory()
    # block_1
    block_1 = TitleBlockFactory(page_section=page_section)
    TitleFactory(block=block_1, title='content_1')
    # block_2
    block_2 = TitleBlockFactory(page_section=page_section)
    TitleFactory(block=block_2, title='content_2')
    # check pending
    assert [
        'content_1', 'content_2'
    ] == [c.title for c in Title.objects.pending(page_section)]
    # remove block 1
    block_1.remove(UserFactory())
    # check removed
    assert [
        'content_2'
    ] == [c.title for c in Title.objects.pending(page_section)]
Ejemplo n.º 3
0
def test_remove_published():
    """remove published content."""
    page_section = PageSectionFactory()
    # block_1
    block_1 = TitleBlockFactory(page_section=page_section)
    TitleFactory(block=block_1, title='content_1')
    block_1.publish(UserFactory())
    # block_2
    block_2 = TitleBlockFactory(page_section=page_section)
    TitleFactory(block=block_2, title='content_2')
    block_2.publish(UserFactory())
    # block_3 (not published)
    block_3 = TitleBlockFactory(page_section=page_section)
    TitleFactory(block=block_3, title='content_3')
    # check published
    assert [
        'content_1', 'content_2'
    ] == [c.title for c in Title.objects.published(page_section)]
    # remove block
    block_2.remove(UserFactory())
    # check removed
    assert [
        'content_1'
    ] == [c.title for c in Title.objects.published(page_section)]
Ejemplo n.º 4
0
def test_is_removed():
    block = TitleBlockFactory()
    content = TitleFactory(block=block)
    block.remove(UserFactory())
    content = Title.objects.get(title=content.title)
    assert content.is_removed is True