From 677f906736a58c56e916166377487e4991096544 Mon Sep 17 00:00:00 2001 From: "ryan.noelk" Date: Sat, 7 Apr 2018 13:55:02 +0200 Subject: [PATCH] fixing tests --- v1/fixtures/test/food.jpg | Bin 0 -> 631 bytes v1/recipe/tests/test_create_recipe.py | 9 +++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 v1/fixtures/test/food.jpg diff --git a/v1/fixtures/test/food.jpg b/v1/fixtures/test/food.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1cda9a53dc357ce07d3c67051b7615ebf7dc2f64 GIT binary patch literal 631 zcmex=^(PF6}rMnOeST|r4lSw=>~TvNxu(8R<ECr+Na zbot8FYu9hwy!G(W<0ns_J%91?)yGetzkL1n{m0K=Ab&A3Fhjfr_ZgbM1cClyVqsxs zVF&q(k*OSrnFU!`6%E;h90S=C3x$=88aYIqCNA7~kW<+>=!0ld(M2vX6_bamA3L7B$%azX<@d&d)*s literal 0 HcmV?d00001 diff --git a/v1/recipe/tests/test_create_recipe.py b/v1/recipe/tests/test_create_recipe.py index 1ab0b6f..dd1c3d4 100644 --- a/v1/recipe/tests/test_create_recipe.py +++ b/v1/recipe/tests/test_create_recipe.py @@ -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 @@ -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))