Exemple #1
0
 def test_update_new_username(self):
     # update to a new username
     before = User(**updated_user1)
     before.username = '******'
     AccountManager.update_user(user1['username'], before)
     after = get_user(before.username)
     self.assertDictEqual(after.to_dict(), before.to_dict())
Exemple #2
0
    def put():
        json_data = request.get_json(force=True)
        if not json_data:
            return {'message': 'No input data provided'}, 400
        data, errors = user_update_request_schema.load(json_data)

        if errors:
            return errors, 422

        username = data["username"]
        updated_user = data["updated_user"]

        from AccountManager.account_manager import AccountManager
        results = AccountManager.update_user(username, updated_user)
        if results:
            return user_response_schema.dump({"success": results})
        else:
            return {"success": results}, 404
Exemple #3
0
 def test_deleted_prev(self):
     # update to a new username
     user = User(**updated_user1)
     user.username = '******'
     AccountManager.update_user(user1['username'], user)
     self.assertIsNone(get_user(user1['username']))
Exemple #4
0
 def test_update_invalid_param(self):
     self.assertFalse(AccountManager.update_user(5, User('user')))
Exemple #5
0
 def test_update_nonexistent(self):
     self.assertFalse(
         AccountManager.update_user('notauser', User(**bare_user)))
Exemple #6
0
 def test_username_taken(self):
     self.assertFalse(
         AccountManager.update_user(user1['username'], User(**user2)))
Exemple #7
0
 def test_update_user(self):
     # update everything but keep the username
     AccountManager.update_user(user1['username'], User(**updated_user1))
     user = get_user(user1['username']).to_dict()
     self.assertDictEqual(user, updated_user1)