Created
February 20, 2016 18:50
-
-
Save benwillkommen/8a7150b559c38e1ce538 to your computer and use it in GitHub Desktop.
gross or nah?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_put_detail_without_pk(self): | |
payload = self.dailytotal_post_data.copy() | |
payload['carbohydrate'] = 69 | |
# I'd like to support PUT to create on detail resources. | |
# If there's no pk on the payload for a PUT, tastypie will create it. | |
# However, there needs to be a token for the pk for the route to match the resource detail route. | |
# How gross is throwing in a pk that cannot exist in the url, just to get the route to match? | |
# I haven't had to break out the tastypie source code yet today, and I kind of want to keep it that way | |
resp = self.api_client.put('/api/v1/dailytotal/-1/', format='json', data=payload) | |
self.assertEqual(resp.status_code, 201) | |
updatedModel = DailyTotal.objects.filter(carbohydrate=69) | |
self.assertEqual(updatedModel[0].carbohydrate, 69) | |
''' | |
FYI | |
self.dailytotal_post_data = { | |
"body_part_trained": "arms", | |
"body_weight": "200.00", | |
"carbohydrate": "300.00", | |
"report": "/api/v1/report/25/", | |
"log_date": "2015-12-03T01:04:40", | |
"fat": "70.00", | |
"minutes_of_cardio": 0, | |
"protein": "200.00" | |
} | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment