Beispiel #1
0
def test_staff_delete_errors(staff_user, customer_user, admin_user):
    info = Mock(context=Mock(user=staff_user))
    errors = StaffDelete.clean_instance(info, customer_user, [])
    assert errors[0].field == 'id'
    assert errors[0].message == 'Cannot delete a non-staff user.'

    info = Mock(context=Mock(user=admin_user))
    errors = StaffDelete.clean_instance(info, staff_user, [])
    assert not errors
Beispiel #2
0
def test_staff_delete_errors(staff_user, customer_user, admin_user):
    errors = StaffDelete.clean_user(customer_user, staff_user, [])
    assert errors[0].field == 'id'
    assert errors[0].message == (
        'Only staff users can be deleted with this mutation.')
    errors = StaffDelete.clean_user(staff_user, staff_user, [])
    assert errors[0].field == 'id'
    assert errors[0].message == (
        'You cannot delete your own account via dashboard.')

    errors = StaffDelete.clean_user(admin_user, staff_user, [])
    assert errors[0].field == 'id'
    assert errors[0].message == 'Only superuser can delete his own account.'
    errors = StaffDelete.clean_user(staff_user, admin_user, [])
    assert not errors