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())
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
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']))
def test_update_invalid_param(self): self.assertFalse(AccountManager.update_user(5, User('user')))
def test_update_nonexistent(self): self.assertFalse( AccountManager.update_user('notauser', User(**bare_user)))
def test_username_taken(self): self.assertFalse( AccountManager.update_user(user1['username'], User(**user2)))
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)