def test_users(self): """ Tests the result of org_admin_views.users """ # test #1 - return a json response with the user we added to the org's member # usergroup request = self.factory.get("/org-admin/users?org_id=%d" % (self.org.id)) request.user = self.org_admin resp = json.loads(org_admin.users(request).content) self.assertEqual(resp["status"], "ok") self.assertEqual( resp["users"], [{ "id": self.user_a.id, "name": "%s <%s, %s>" % (self.user_a.full_name, self.user_a.email, self.user_a.username), }], ) # test #2 - return 403 response when trying to access the org where org_admin # is not administrator request = self.factory.get("/org-admin/users?org_id=%d" % (self.org_other.id)) request.user = self.org_admin resp = org_admin.users(request) self.assertEqual(resp.status_code, 403) self.assertEqual(json.loads(resp.content), {})
def test_users(self): """ Tests the result of org_admin_views.users """ # test #1 - return a json response with the user we added to the org's member # usergroup request = self.factory.get( "/org-admin/users?org_id=%d" % (self.org.id)) request.user = self.org_admin resp = json.loads(org_admin.users(request).content) self.assertEqual(resp["status"], "ok") self.assertEqual(resp["users"], [{ "id": self.user_a.id, "name": "%s <%s, %s>" % (self.user_a.full_name, self.user_a.email, self.user_a.username) }]) # test #2 - return 403 response when trying to access the org where org_admin # is not administrator request = self.factory.get( "/org-admin/users?org_id=%d" % (self.org_other.id)) request.user = self.org_admin resp = org_admin.users(request) self.assertEqual(resp.status_code, 403) self.assertEqual(json.loads(resp.content), {})