Theresa Davis and Katina Carranza Sea Turtles , Solar-System-api#4
Theresa Davis and Katina Carranza Sea Turtles , Solar-System-api#4perugia33 wants to merge 11 commits into
Conversation
| planets_response.append({ | ||
| "id": planet.id, | ||
| "name": planet.name, | ||
| "description": planet.description, | ||
| "moons": planet.moons |
There was a problem hiding this comment.
this could be moved to your planets class as an instance method. Then you would call that instance method here.
def make_dict(self):
return dict(
id=self.id,
name=self.name,
description=self.description,
moons=self.moons
)| "description": planet.description, | ||
| "moons": planet.moons | ||
| }) | ||
| return jsonify(planets_response) |
There was a problem hiding this comment.
Here its nice to add a 200 status code. Even though it happens by default it adds readability to your code.
return jsonify(planets_response), 200| "description": planet.description, | ||
| "moons": planet.moons | ||
| } | ||
| def validate_planet(planet_id): |
| # app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:postgres@localhost:5432/solar_system_development' | ||
|
|
||
| if not test_config: | ||
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False |
There was a problem hiding this comment.
if you move this line to line 16 then you don't have to put it on line 23
| # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||
| # app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:postgres@localhost:5432/solar_system_development' |
| @@ -0,0 +1,8 @@ | |||
| from app import db | |||
|
|
|||
| class Planet(db.Model): | |||
There was a problem hiding this comment.
looks good. Would you make these columns nullable?
| planets_response.append({ | ||
| "id": planet.id, | ||
| "name": planet.name, | ||
| }) |
There was a problem hiding this comment.
if I'm not querying by name then I want to get all the information back from the planet. So I would want id, name, description, and moons.
| return { | ||
| "id": planet.id, | ||
| "name": planet.name, | ||
| "description": planet.description, | ||
| "moons":planet.moons | ||
| } |
There was a problem hiding this comment.
you can move this to your Planet class and make an instance method
| return app.test_client() | ||
|
|
||
| @pytest.fixture | ||
| def two_saved_planets(app): |
| assert response.status_code == 200 | ||
| assert response_body == [] | ||
|
|
||
| def test_get_planets(client, two_saved_planets): |
There was a problem hiding this comment.
this test name could be more descriptive. test_get_planet_by_id since you are looking for planet 1
Pull Request updated on May 6th to add Test Folder and Files