Repository navigation
Add create and update restaurant endpoints (#21, #22) - #41
Merged
Merged
Conversation
Lets routes return 404 and 409 without guessing from ValueError, which is already used for invalid data files.
Builds the full restaurant from the request (server sets id, type and no menu), rejects a duplicate name + address, and saves it.
Returns 201 with the new restaurant, 422 for invalid input and 409 for a duplicate. Tests check the restaurant is still there after a restart.
Changes only the fields that were sent, keeps the id, rejects an unknown id and an update that would duplicate another restaurant, then saves.
Returns the updated restaurant, 404 for an unknown id, 409 for a duplicate and 422 for invalid or empty input. Tests check the change is still there after a restart.
…update-restaurant # Conflicts: # backend/app/services/restaurant_service.py
CookieLynx
approved these changes
Oct 17, 2026
CookieLynx
left a comment
Collaborator
There was a problem hiding this comment.
Creation and modification of the restaurants are looking good!
Summary for the repsonses is a nice touch.
Good error handling!
Good tests!
overall looking good, approved!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
POST /restaurantsandPATCH /restaurants/{restaurant_id}with the service logic and tests.Closes #21
Closes #22
Closes #29
Note: this branch has Casey's #39 merged in because it needs
save_restaurants. Please merge this only after #39 is merged, then this PR will only show my changes.Create (
POST /restaurants, body:RestaurantCreate)hasMenu: null(works with the "uncategorized section" plan for menu items).Update (
PATCH /restaurants/{restaurant_id}, body:RestaurantUpdate)Design:
RestaurantNotFoundErrorandDuplicateRestaurantErrorincore/exceptions.pyso routes don't have to guess fromValueError, which is already used for invalid data files. Might be good for us to use these for "not found" everywhere later./docs.Testing:
test_restaurant_management_service.py: service tests with a mock repository.test_restaurant_management_endpoints.py: endpoint tests, including checking the change is still there after restarting the app.