def test_index(self):
        self.mox.StubOutWithMock(api, 'user_list')
        api.user_list(IgnoreArg()).AndReturn(self.users)

        self.mox.ReplayAll()

        res = self.client.get(reverse('syspanel_users'))

        self.assertTemplateUsed(res, 'syspanel_users.html')
        self.assertItemsEqual(res.context['users'], self.users)

        self.mox.VerifyAll()
Esempio n. 2
0
    def test_index(self):
        self.mox.StubOutWithMock(api, 'user_list')
        api.user_list(IgnoreArg()).AndReturn(self.users)

        self.mox.ReplayAll()

        res = self.client.get(reverse('syspanel_users'))

        self.assertTemplateUsed(res,
                                'django_openstack/syspanel/users/index.html')
        self.assertItemsEqual(res.context['users'], self.users)

        self.mox.VerifyAll()
Esempio n. 3
0
def index(request):
    for f in (UserDeleteForm, UserEnableDisableForm):
        _, handled = f.maybe_handle(request)
        if handled:
            return handled

    users = []
    try:
        users = api.user_list(request)
    except api_exceptions.ApiException, e:
        messages.error(request, 'Unable to list users: %s' % e.message)
Esempio n. 4
0
def index(request):
    for f in (UserDeleteForm, UserEnableDisableForm):
        _, handled = f.maybe_handle(request)
        if handled:
            return handled

    users = []
    try:
        users = api.user_list(request)
    except api_exceptions.ApiException, e:
        messages.error(request, _("Unable to list users: %s") % e.message)
Esempio n. 5
0
def users(request, tenant_id):
    for f in (AddUser, RemoveUser,):
        form, handled = f.maybe_handle(request)
        if handled:
            return handled

    add_user_form = AddUser()
    remove_user_form = RemoveUser()

    users = api.user_list(request, tenant_id)
    all_users = api.user_list(request)
    user_ids = [u.id for u in users]
    new_users = [u for u in all_users if not u.id in user_ids]
    return render_to_response(
    'django_openstack/syspanel/tenants/users.html', {
        'add_user_form': add_user_form,
        'remove_user_form': remove_user_form,
        'tenant_id': tenant_id,
        'users': users,
        'new_users': new_users,
    }, context_instance=template.RequestContext(request))
Esempio n. 6
0
def index(request):
    for f in (UserDeleteForm,):
        _, handled = f.maybe_handle(request)
        if handled:
            return handled

    users = api.user_list(request)

    user_delete_form = UserDeleteForm()
    return render_to_response(
        "syspanel_users.html",
        {"users": users, "user_delete_form": user_delete_form},
        context_instance=template.RequestContext(request),
    )
    def test_user_list(self):
        users = (TEST_USERNAME, TEST_USERNAME + "2")

        account_api = self.stub_account_api()
        account_api.users = self.mox.CreateMockAnything()
        account_api.users.list().AndReturn(users)

        self.mox.ReplayAll()

        ret_val = api.user_list(self.request)

        self.assertEqual(len(ret_val), len(users))
        for user in ret_val:
            self.assertIsInstance(user, api.User)
            self.assertIn(user._apiresource, users)

        self.mox.VerifyAll()