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

✨ Create person entity #10

Merged
merged 13 commits into from
Jan 17, 2018
Merged

✨ Create person entity #10

merged 13 commits into from
Jan 17, 2018

Conversation

dankolbman
Copy link
Contributor

@dankolbman dankolbman commented Jan 10, 2018

Create person entity for #2

  • - PUT
  • - GET
  • - PATCH
  • - DELETE
  • - docs
  • - tests

dankolbman and others added 3 commits January 11, 2018 13:11
Implement post to create one, put to update one, get to read one
get to read all and delete to delete one
Renamed existing tests to be person specific
Update model tests to include create one, update one, find one, find all
and delete one
Update api tests to include  post, put, get, and delete
headers=self._api_headers())

resp = json.loads(response.data.decode("utf-8"))
self.assertEqual(response.status_code, 404)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also worth checking that the actual row was dropped in the database. It's possible that the api could hold the transaction open making object deleted only in the api's session.



@person_api.route('/')
class NewPerson(Resource):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any reason for the addition of this class rather than placing the 'post' on the Persons resource?

Copy link
Member

Choose a reason for hiding this comment

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

This resource class pattern didn't make sense to me before but I think now I understand it a little bit better. I'm gonna go with Person and PersonList classes

Update an existing person
"""
body = request.json
person = model.Person.query.filter_by(kf_id=person_id).first_or_404()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Person.query.get_or_404(id) is equivalent.

Could also use query.get() and catch on the orm.exc.NoResultFound to abort with a relevant error message.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like get and get_or_404 can only be used with primary keys

@dankolbman dankolbman changed the title ✨ Create person entity ✨ Create person entity Jan 12, 2018

return response

def _test_response_content(self, resp, status_code):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good use case for paramatrized tests.

znatty22
znatty22 previously approved these changes Jan 16, 2018
Copy link
Member

@znatty22 znatty22 left a comment

Choose a reason for hiding this comment

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

A lot of this might be OBE, so just going to complete review for now and figure out how to move forward

def init_app(cls, app):
Config.init_app(app)

# email errors to the administrators
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how emailing errors works, but is this necessary right now?

parimalak
parimalak previously approved these changes Jan 16, 2018
@dankolbman dankolbman added feature New functionality data model Changes to the underlying data representation labels Jan 16, 2018
Create common module for common code among resources
Create new folder for person tests, move all person tests into it
Separate out model code, resource code, serialization code for Person
resources
Refactor and replace Flask-Script with built in CLI
Add support for api versioning
Clean up Flask CLI commands
Change api prefix from /api/v1 to /v1
Remove Flask-Script dependenct
Replace relative imports with absolute imports
@dankolbman dankolbman merged commit 05bc7ba into master Jan 17, 2018
@dankolbman dankolbman deleted the person-entity branch January 17, 2018 00:54
@dankolbman dankolbman changed the title ✨ Create person entity ✨ Create person entity Mar 9, 2018
@dankolbman dankolbman mentioned this pull request Apr 2, 2018
alubneuski pushed a commit that referenced this pull request Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data model Changes to the underlying data representation feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants