Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanNoelk committed Apr 7, 2018
1 parent 739a824 commit 677f906
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Binary file added v1/fixtures/test/food.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions v1/recipe/tests/test_create_recipe.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python
# encoding: utf-8

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

Expand Down Expand Up @@ -143,14 +145,13 @@ 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:
root_path = os.path.join(settings.PROJECT_PATH, 'v1', 'fixtures', 'test', 'food.jpg')
with open(root_path, 'rb') as f:
request.FILES['photo'] = SimpleUploadedFile(
'/code/food.jpg',
root_path,
f.read(),
content_type='multipart/form-data'
)
response = view(request)

print(response.data)

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

0 comments on commit 677f906

Please sign in to comment.