示例#1
0
def test_category_delete(client):
    user = UserFactory(is_staff=True)
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    category = ImageCategoryFactory()
    assert category.deleted is False
    # test
    url = reverse('block.image.category.delete', args=[category.pk])
    response = client.post(url)
    # check
    assert 302 == response.status_code
    expect = reverse('block.image.category.list')
    assert expect in response['Location']
    category.refresh_from_db()
    assert category.deleted is True
示例#2
0
def test_category_update(client):
    user = UserFactory(is_staff=True)
    assert client.login(username=user.username, password=TEST_PASSWORD) is True
    category = ImageCategoryFactory()
    url = reverse('block.image.category.update', args=[category.pk])
    data = {
        'name': 'Cricket',
    }
    response = client.post(url, data)
    # check
    assert 302 == response.status_code
    expect = reverse('block.image.category.list')
    assert expect in response['Location']
    category.refresh_from_db()
    assert 'Cricket' == category.name