2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-02 03:30:54 +00:00

Remove code left over from previous commit (#3385)

* Remove code left over from previous commit

* Handle invalid image loaded with uploaded_image report template tag

* Add option to *not* use a custom logo

* Fix unit tests
This commit is contained in:
Oliver
2022-07-22 17:33:28 +10:00
committed by GitHub
parent 779646771d
commit d32054b53b
4 changed files with 23 additions and 8 deletions

View File

@ -9,6 +9,8 @@ from django.http.response import StreamingHttpResponse
from django.test import TestCase
from django.urls import reverse
from PIL import Image
import report.models as report_models
from build.models import Build
from common.models import InvenTreeSetting, InvenTreeUserSetting
@ -74,9 +76,17 @@ class ReportTagTest(TestCase):
with open(img_file, 'w') as f:
f.write("dummy data")
# Test in debug mode
# Test in debug mode. Returns blank image as dummy file is not a valid image
self.debug_mode(True)
img = report_tags.uploaded_image('part/images/test.jpg')
self.assertEqual(img, '/static/img/blank_image.png')
# Now, let's create a proper image
img = Image.new('RGB', (128, 128), color='RED')
img.save(img_file)
# Try again
img = report_tags.uploaded_image('part/images/test.jpg')
self.assertEqual(img, '/media/part/images/test.jpg')
self.debug_mode(False)