コード例 #1
0
def test_wizard_image_upload_single(client):
    content = TitleFactory()
    category = ImageCategoryFactory()
    ImageFactory()
    #image = ImageFactory()
    user = UserFactory(is_staff=True)
    assert content.picture is None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_image_single(content, 'block.wizard.image.upload')
    data = {
        'add_to_library': True,
        'category': category.pk,
        'image': test_file(),
        'title': 'Cricket',
    }
    response = client.post(url, data)
    # check
    content.refresh_from_db()
    expect = content.block.page_section.page.get_design_url()
    assert 302 == response.status_code
    assert expect in response['Location']
    assert 'Cricket' == content.picture.title
    assert content.picture is not None
    assert content.picture.category == category
    assert content.picture.deleted is False
    # check an image has been added to the database
    assert 2 == Image.objects.count()
コード例 #2
0
def test_wizard_image_option(client):
    user = UserFactory(is_staff=True)
    category = ImageCategoryFactory()
    image = ImageFactory(category=category)
    image.tags.add('apple')
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    content = TitleFactory()
    url = url_image_single(content, 'block.wizard.image.option')
    response = client.get(url)
    assert 200 == response.status_code
コード例 #3
0
def test_wizard_image_remove_single(client):
    """The multi test for removing is ``test_wizard_image_select_multi``."""
    image = ImageFactory()
    content = TitleFactory(picture=image)
    user = UserFactory(is_staff=True)
    assert content.picture is not None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_image_single(content, 'block.wizard.image.remove')
    response = client.post(url)
    # check
    content.refresh_from_db()
    expect = content.block.page_section.page.get_design_url()
    assert 302 == response.status_code
    assert expect in response['Location']
    assert content.picture is None
コード例 #4
0
def test_wizard_image_choose_single(client):
    content = TitleFactory()
    ImageFactory()
    image = ImageFactory()
    user = UserFactory(is_staff=True)
    assert content.picture is None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_image_single(content, 'block.wizard.image.choose')
    data = {
        'images': image.pk,
    }
    response = client.post(url, data)
    # check
    assert 302 == response.status_code
    expect = content.block.page_section.page.get_design_url()
    assert expect in response['Location']
    content.refresh_from_db()
    assert image == content.picture