Skip to content

Ihovanna + Maria Fernanda#41

Open
Ihovanna wants to merge 28 commits intoAda-C18:mainfrom
Mfpr603:main
Open

Ihovanna + Maria Fernanda#41
Ihovanna wants to merge 28 commits intoAda-C18:mainfrom
Mfpr603:main

Conversation

@Ihovanna
Copy link
Copy Markdown

No description provided.

Mfpr603 and others added 28 commits October 24, 2022 11:51
…pdate your own database with upgrade commands
…ed. HTTP GET request returns all entries in database.
Copy link
Copy Markdown

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

Overall nice work. I left some suggestions for future APIs. Also try to remember to include venv in your .gitignore file so it doesn't get included in the Pull Request.

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String)
description = db.Column(db.String)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

some helper methods like

    def to_dict(self):

        return {
            "name": self.name,
            "color": self.color,
            "description": self.description,
            "id": self.id
        }
    @classmethod   
    def from_json(cls, input_dict):
        return cls(
            name= input_dict["name"],
            color= input_dict["color"],
            description= input_dict["description"]
        )

Might be helpful

Comment thread app/routes.py
planets_bp = Blueprint('planets_bp', __name__, url_prefix='/planets')

@planets_bp.route("", methods=["POST"])
def create_planet():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some input validation on the request body would be appropriate here.

Comment thread app/routes.py
Comment on lines +27 to +31
planets_response.append({
"id": planet.id,
"name": planet.name,
"description": planet.description
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This would be a great place to use that helper method I listed in the Planet Class.

Comment thread app/routes.py


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

Choose a reason for hiding this comment

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

Why name this handle_planet instead of get_planet?

Comment thread tests/test_routes.py
assert len(response_body) == 1


def test_create_planet(client):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should also test the create action with an invalid input.

Comment thread tests/test_routes.py
assert response_body == "Planet Earth has been added to the Planets database."


def test_update_planet_entry(client, one_planet_in_database):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should also have a test for the update action with invalid input

Comment thread tests/test_routes.py
assert response_body == "Planet Earth has been updated in the Planets database."


def test_delete_planet_entry(client, one_planet_in_database):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should also try to test delete actions with invalid planet ids. Basically testing the 404 response.

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