-
Notifications
You must be signed in to change notification settings - Fork 45
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
[62] Create API endpoint for hacknight details #172
[62] Create API endpoint for hacknight details #172
Conversation
|
I will add some unittests here as well. |
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.
@w1stler already wrote so, but, please provide unit tests here.
backend/app.py
Outdated
@@ -40,3 +40,4 @@ def initialize_extensions(app): | |||
api.add_resource(ParticipantsList, "/participants/") | |||
api.add_resource(ParticipantDetails, "/participants/<int:id>/") | |||
api.add_resource(HacknightList, "/hacknights/") | |||
api.add_resource(HacknightDetails, "/hacknights/<int:id>/details/") |
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.
also it shouldn't have /details/
at the end
backend/resources/hacknight.py
Outdated
|
||
class HacknightDetails(Resource): | ||
def get(self, id): | ||
hacknight_schema = HacknightSchema(only=('date', 'id', 'participants')) |
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 do we limit fields using only
here?
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 was intentional, as the ticket stated this (only these fields to be returned). Currently we don't have others, so could be removed. :-)
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.
I believe it should be removed. I don't even see the word only
in issue description so would assume that was to point out all fields in that 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.
two simple issues
backend/resources/hacknight.py
Outdated
|
||
class HacknightDetails(Resource): | ||
def get(self, id): | ||
hacknight_schema = HacknightSchema(only=('date', 'id', 'participants')) |
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.
I believe it should be removed. I don't even see the word only
in issue description so would assume that was to point out all fields in that model.
|
||
|
||
@pytest.fixture | ||
def add_participants_to_hacknight(app, _db): |
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.
We can simplify it:
@pytest.fixture
def add_participants_to_hacknight(app, _db):
HacknightFactory(participants=ParticipantFactory.create_batch(10))
_db.session.commit()
To test, use Postman:
GET
localhost:5000/hacknights/1/details/