Skip to content
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

Sea Turtles Hope W. & Natalia W. #25

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

NataliaWoodson
Copy link

No description provided.

Comment on lines +25 to +30
planets_response.append({
"id": planet.id,
"name": planet.name,
"moons": planet.moons,
"description": planet.description
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
            moons=self.moons,
            description=self.description,
        )

app/routes.py Outdated


@planets_bp.route("", methods=["GET"])
def handle_planets():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conventionally you would see the naming of the function be similar to the CRUD operation you are performing. Like get_planets or get_all_planets

return jsonify(planets_response)

@planets_bp.route("<planet_id>", methods=["GET"])
def handle_planet(planet_id):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conventionally you would see the naming of the function be similar to the CRUD operation you are performing. Like get_one_planet or get_a_planet

"description": planet.description
}

def validate_planet(planet_id):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃🏽💃🏽💃🏽

"moons": planet.moons,
"description": planet.description
})
return jsonify(planets_response)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here its nice to add a 200 status code. Even though it happens by default it adds readability to your code.

return jsonify(planets_result), 200

@@ -0,0 +1,23 @@
from app import db

class Planet(db.Model):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition of instance methods. For your columns, would you make them nullable? Like nullable = False .

Comment on lines +62 to +64
planet.name = request_body["name"]
planet.moons = request_body["moons"]
planet.description = request_body["description"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use your class method that you made here

from app.models.planet import Planet

@pytest.fixture
def app():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@@ -0,0 +1,48 @@
def test_get_all_books_with_no_records(client):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests look good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants