Ejemplo n.º 1
0
    async def test_delete_user_user_with_accounts(self):
        resp = await self.client.delete(
            f"/users/{USER_WITH_MULTIPLE_ACCOUNTS_ID}",
            headers={
                "Authorization":
                f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
        )
        self.assertEqual(200, resp.status)
        resp_data = await resp.json()
        self.assertEqual(
            UserResource(user=User(**USER_WITH_MULTIPLE_ACCOUNTS_DICT)).dict(),
            resp_data,
        )
        other_users = await self.client.get(
            f"/users",
            headers={
                "Authorization": f"Token {USER_WITH_ONE_ACCOUNT_AUTH_KEY}"
            },
        )

        other_users_data = await other_users.json()
        self.assertCountEqual(
            UserListResource(users=[
                User(**USER_WITH_NO_ACCOUNTS_DICT),
                User(**USER_WITH_ONE_ACCOUNT_DICT),
            ]).dict(),
            other_users_data,
        )
Ejemplo n.º 2
0
 async def test_users_endpoint_list_users(self):
     resp = await self.client.get(
         "/users",
         headers={
             "Authorization": f"Token {USER_WITH_ONE_ACCOUNT_AUTH_KEY}"
         },
     )
     users_data = await resp.json()
     self.assertCountEqual(
         UserListResource(users=[
             User(**USER_WITH_MULTIPLE_ACCOUNTS_DICT),
             User(**USER_WITH_NO_ACCOUNTS_DICT),
             User(**USER_WITH_ONE_ACCOUNT_DICT),
         ]).dict(),
         users_data,
     )
Ejemplo n.º 3
0
async def users_list(request: web.Request):
    users = await UsersService.get_users(UsersBackend())
    return web.json_response(UserListResource(users=users).dict())