From adc9f5065ab78c7694c696e6eb4ed037cf73ad74 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 28 Aug 2020 15:10:09 +0200 Subject: Documents: do not move images on hard drive after associations --- archaeological_finds/tests.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'archaeological_finds') diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 2360d4ca6..2e3026f6e 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -1202,11 +1202,15 @@ class FindSearchTest(FindInit, TestCase, SearchText): self.assertEqual(res['recordsTotal'], 0) # add an image to the first find - image = Document.objects.create(title="Image!") - img = settings.ROOT_PATH + \ + document = Document.objects.create(title="Image!") + image_path = settings.ROOT_PATH + \ '../ishtar_common/static/media/images/ishtar-bg.jpg' - image.image.save('ishtar-bg.jpg', File(open(img))) - self.finds[0].documents.add(image) + document.image = SimpleUploadedFile( + name='ishtar-bg.jpg', content=open(image_path, 'rb').read(), + content_type='image/jpeg') + document.save() + + self.finds[0].documents.add(document) self.finds[0].save() response = c.get(reverse('get-find'), search) self.assertEqual(response.status_code, 200) -- cgit v1.2.3