Issue 253
Our Project: Foodsaving.world in the Backend
Repository: https://github.com/yunity/foodsaving-backend
The Plan:
Before our Rails Girls Summer of Code started, we made a great plan what we will do:
- create Feedback field to Food Pickup ( Issue #235 )
- make trusted users/group admins
- create statistics for pickups that were done by users in kilograms
- build a quiz framework
Optional: Android App, shared food & other things
Yay!
The Reality
We found out that we had no clue how difficult such an Issue can be! I mean like ABSOLUTLEY no clue. Coming from ‘Codecademy’, ‘Learn Python the Hard Way’ and some small pet projects we thought we would solve the first Issue within 1 week.
We needed 9 weeks until our first (notable) Pull request was accepted. So, how was that possible?
The First Issue
Our first task was to create Feedback field to Food Pickups. We spent a lot of our time learning about: Python, Django Framework, Django REST Framework, Swagger, how to troubleshoot our Git merge conflicts and how to solve our Docker complaints.
What We Have Learnt:
- There are no shortcuts - we have to do Django tutorial and Django REST tutorial first
- Working both on the same branch at the same time will not speed up our progress! We are going to have many merge conflicts instead and we have to solve them all. This takes many, many hours :)
- We know what is server, browser, database, models, migrations, HTTP requests, querysets, filters and all these fancy words around we did not know how they are connected before.
- And finally: This Issue is not as small as it looks like!
If you want to read more about this, go to the Foodsaving blog and read the Fairy Tale Version of that story.
What We Have Built (Status: 6. September 2017):
- a new API endpoint Feedback with HTTP methods GET, POST
- integration API tests for Feedback that ensure that the user gets the correct GET/POST output
- validation for field
about
and set the fieldgiven_by
as read-only - unit model tests for model Feedback
Our hardest part on the Issue was to fix this test:
python
def test_list_feedback_works_as_collector(self):
"""
Collector is allowed to see list of feedback.
"""
self.client.force_login(user=self.collector)
response = self.client.get(self.url)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
self.assertEqual(len(response.data), 2)
This test should return two instances of our test object and check that there are exactly 2 instances in the test database. There is also a difference between a test database and live database. We discussed this many times until we could fully understand :)