예제 #1
0
def test_upload_single(client):
    content = TitleFactory()
    category = LinkCategoryFactory()
    DocumentFactory()
    #image = ImageFactory()
    user = UserFactory(is_staff=True)
    assert content.link is None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_link_single(content, 'block.wizard.link.upload')
    # create a document ready to upload
    data = {
        'add_to_library': True,
        'category': category.pk,
        'document': 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.link.title
    assert content.link is not None
    assert category == content.link.category
    assert content.link.document.deleted is False
    # check a document has been added to the database
    assert 2 == Document.objects.count()
예제 #2
0
def test_external_single(client):
    content = TitleFactory()
    #category = ImageCategoryFactory()
    #DocumentFactory()
    #image = ImageFactory()
    user = UserFactory(is_staff=True)
    assert content.link is None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_link_single(content, 'block.wizard.link.external')
    # create a document ready to upload
    data = {
        'add_to_library': True,
        #'category': category.pk,
        'url_external': 'https://www.pkimber.net',
        'title': 'Rugby',
    }
    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 'Rugby' == content.link.title
    assert content.link is not None
    assert 'https://www.pkimber.net' == content.link.url_external
예제 #3
0
def test_remove_single(client):
    """The multi test for removing is ````."""
    link = LinkFactory()
    content = TitleFactory(link=link)
    user = UserFactory(is_staff=True)
    assert content.link is not None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_link_single(content, 'block.wizard.link.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.link is None
예제 #4
0
def test_choose_single(client):
    content = TitleFactory()
    LinkFactory()
    link = LinkFactory()
    user = UserFactory(is_staff=True)
    assert content.link is None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_link_single(content, 'block.wizard.link.choose')
    data = {
        'links': link.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 link == content.link
예제 #5
0
def test_page_single(client):
    content = TitleFactory()
    #category = ImageCategoryFactory()
    page = PageFactory(name='Information', slug='info', slug_menu='')
    url_internal = Url.objects.init_page_url(page)
    user = UserFactory(is_staff=True)
    assert content.link is None
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    url = url_link_single(content, 'block.wizard.link.page')
    # create a document ready to upload
    data = {
        #'add_to_library': True,
        #'category': category.pk,
        'url_internal': url_internal.pk,
        '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.link.title
    assert url_internal == content.link.url_internal