Пример #1
0
def test_make_admin_sets_admin_to_True_if_True(get_by_username):
    """If .admin is True it should just do nothing."""
    fred = mock.Mock()
    fred.admin = True
    get_by_username.return_value = fred

    accounts.make_admin("fred")

    assert fred.admin is True
Пример #2
0
def test_make_admin_sets_admin_to_True_if_False(get_by_username):
    """It should set .admin to True if it was False."""
    fred = mock.Mock()
    fred.admin = False
    get_by_username.return_value = fred

    accounts.make_admin("fred")

    assert fred.admin is True
Пример #3
0
def admins_add(request):
    """Make a given user an admin."""
    username = request.params['add']
    try:
        accounts.make_admin(username)
    except accounts.NoSuchUserError:
        request.session.flash(
            _("User {username} doesn't exist.".format(username=username)),
            "error")
    return admins_index(request)
Пример #4
0
def admins_add(request):
    """Make a given user an admin."""
    username = request.params['add']
    try:
        accounts.make_admin(username)
    except accounts.NoSuchUserError:
        request.session.flash(
            _("User {username} doesn't exist.".format(username=username)),
            "error")
    return admins_index(request)
Пример #5
0
Файл: views.py Проект: stuk88/h
    def create(self):
        """Make a given user an admin."""
        try:
            username = self.request.params["add"]
        except KeyError:
            raise httpexceptions.HTTPNotFound

        try:
            accounts.make_admin(username)
        except accounts.NoSuchUserError:
            self.request.session.flash(_("User {username} doesn't exist.".format(username=username)), "error")
        return self.index()
Пример #6
0
def test_make_admin_gets_user_by_username(get_by_username):
    """It should pass the right value to get_by_username()."""
    accounts.make_admin("fred")

    get_by_username.assert_called_once_with("fred")
Пример #7
0
def test_make_admin_raises_if_user_does_not_exist(get_by_username):
    """It should raise NoSuchUserError if the user doesn't exist."""
    get_by_username.return_value = None

    with pytest.raises(accounts.NoSuchUserError):
        accounts.make_admin("fred")
Пример #8
0
def admin(args):
    """Make a user an admin."""
    request = bootstrap(args)
    accounts.make_admin(unicode(args.username, sys.getfilesystemencoding()))
    request.tm.commit()
Пример #9
0
def admin(args):
    """Make a user an admin."""
    request = bootstrap(args)
    accounts.make_admin(args.username)
    request.tm.commit()
Пример #10
0
def admin(args):
    """Make a user an admin."""
    request = bootstrap(args)
    accounts.make_admin(args.username)
    request.tm.commit()
Пример #11
0
Файл: script.py Проект: stuk88/h
def admin(args):
    """Make a user an admin."""
    paster.bootstrap(args.config_uri, request=Request.blank(''))
    accounts.make_admin(unicode(args.username, sys.getfilesystemencoding()))
    transaction.commit()
Пример #12
0
def admin(args):
    """Make a user an admin."""
    request = bootstrap(args)
    accounts.make_admin(unicode(args.username, sys.getfilesystemencoding()))
    request.tm.commit()