-
Notifications
You must be signed in to change notification settings - Fork 79
Tigers - Neema and Maria Silva - Solar System API #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Maria Silva
moons in assert statement
CheezItMan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Neema & Maria, you hit the basics here pretty well. I left some minor comments/suggestions. Ping me on slack if you have questions.
|
|
||
| return planet_as_dict | ||
|
|
||
| def from_json(cls, req_body): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a class method
| def validate_model(cls, model_id): | ||
| try: | ||
| model_id = int(model_id) | ||
| except: | ||
| abort(make_response({"message":f"{cls.__name__} {model_id} invalid"}, 400)) | ||
|
|
||
| model = cls.query.get(model_id) | ||
|
|
||
| if not model: | ||
| abort(make_response({"message":f"{cls.__name__} {model_id} not found"}, 404)) | ||
|
|
||
| return model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great helper function
|
|
||
|
|
||
| @planets_bp.route("", methods=["POST"]) | ||
| def handle_planets(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why name the function handle_planets instead of create_planet?
| @pytest.fixture | ||
| def two_saved_planets(app): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not include a fixture for one planet as well?
| assert response.status_code == 201 | ||
| assert response_body == "Planet New Planet successfully created" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also assert that the number of planets in the DB has increased.
| @@ -0,0 +1,70 @@ | |||
| def test_get_all_planets_with_no_records(client): | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that there are no tests for the delete or update actions.
No description provided.