def add(self, store): try: store_id = next(self._id_counter) self._stores[store_id] = store return store_id except KeyError: raise NoSuchUserError(store['manager_id'])
def get_user_by_id(self, user_id): try: return self._users[user_id] except KeyError: raise NoSuchUserError(user_id)
def update_user_by_id(self, user_id, user): if user_id in self._users: self._users[user_id] = user else: raise NoSuchUserError(user_id)
def remove_user_by_id(self, user_id): if user_id in self._users: self._users.pop(user_id) else: raise NoSuchUserError(user_id)