예제 #1
0
    def test_delete_user_by_id(self):
        with self.client:
            """
            Test delete user by public_id
            """
            create_user_with_admin_privileges()
            user = {'email': email, 'username': username, 'password': password}
            save_changes(create_new_user(user, False))

            # user login
            resp_login = login_user(self, valid_admin_data)
            data_login = json.loads(resp_login.data.decode())

            self.assertTrue(data_login['Authorization'])
            self.assertTrue(resp_login.content_type == 'application/json')
            self.assertEqual(resp_login.status_code, 200)

            # pass valid token
            response = self.client.get(
                '/user/',
                headers=dict(
                    Authorization='Bearer ' +
                    json.loads(resp_login.data.decode())['Authorization']))
            users = json.loads(response.data.decode())['data']

            deleted_user = self.client.delete(
                '/user/{0}'.format(users[1]['public_id']),
                headers=dict(
                    Authorization='Bearer ' +
                    json.loads(resp_login.data.decode())['Authorization']))
            self.assertEqual(204, deleted_user.status_code)
예제 #2
0
def create_second_user_with_admin_privileges():
    user = {
        'email': second_admin_email,
        'username': second_admin_username,
        'password': second_admin_password
    }
    save_changes(create_new_user(user, True))
예제 #3
0
 def post(self):
     """create new user"""
     data = request.json
     return user_service.create_new_user(data)