Skip to content

Commit

Permalink
adding file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanNoelk committed Apr 6, 2018
1 parent ff58bb0 commit 739a824
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion v1/recipe/tests/test_create_recipe.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python
# encoding: utf-8

import json
from django.test import TestCase
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
from rest_framework.test import APIRequestFactory
from v1.recipe import views

Expand Down Expand Up @@ -142,6 +142,15 @@ def test_simple_create_recipe(self):
}
request = self.factory.post('/api/v1/recipe/recipes/', data=data)
request.user = self.staff

with open('/code/food.jpg', 'rb') as f:
request.FILES['photo'] = SimpleUploadedFile(
'/code/food.jpg',
f.read(),
content_type='multipart/form-data'
)
response = view(request)

print(response.data)

self.assertTrue(response.data.get('id', True))

0 comments on commit 739a824

Please sign in to comment.