Package: sorl-thumbnail / 12.5.0-1

disable_http_tests.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From 8d83ae645900b535160dbe3becc7c0cc651b13cd Mon Sep 17 00:00:00 2001
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Thu, 8 Oct 2015 13:53:16 -0700
Update: 2017-04-26, W. Martin Borgert <debacle@debian.org>
Subject: Disable HTTP requests during build

 Remote resources such as images fetched over HTTP are not allowed at build
 time so this patch skips these tests if the environment variable
 LOCAL_BUILD is present.
Last-Update: 2015-01-27
Forwarded: not-needed

Patch-Name: disable_http_tests.patch
---
 tests/thumbnail_tests/test_engines.py      | 13 +++++++------
 tests/thumbnail_tests/test_templatetags.py |  2 ++
 2 files changed, 9 insertions(+), 6 deletions(-)

--- a/tests/thumbnail_tests/test_engines.py
+++ b/tests/thumbnail_tests/test_engines.py
@@ -192,12 +192,13 @@
             default.kvstore.get(im).serialize_storage(),
             'tests.thumbnail_tests.storage.TestStorage',
         )
-        im = ImageFile('http://dummyimage.com/300x300/')
-        default.kvstore.set(im)
-        self.assertEqual(
-            default.kvstore.get(im).serialize_storage(),
-            'sorl.thumbnail.images.UrlStorage',
-        )
+        if not os.environ.get('LOCAL_BUILD', False):
+            im = ImageFile('http://dummyimage.com/300x300/')
+            default.kvstore.set(im)
+            self.assertEqual(
+                default.kvstore.get(im).serialize_storage(),
+                'sorl.thumbnail.images.UrlStorage',
+            )
 
     def test_abspath(self):
         item = Item.objects.get(image='500x500.jpg')
--- a/tests/thumbnail_tests/test_templatetags.py
+++ b/tests/thumbnail_tests/test_templatetags.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 import os
 import re
+import unittest
 from subprocess import Popen, PIPE
 from PIL import Image
 
@@ -117,10 +118,12 @@
 
 
 class TemplateTestCaseB(BaseTestCase):
+    @unittest.skipIf(os.environ.get('LOCAL_BUILD', False), "No remote resources desired")
     def test_url(self):
         val = render_to_string('thumbnail3.html', {}).strip()
         self.assertEqual(val, '<img style="margin:0px 0px 0px 0px" width="20" height="20">')
 
+    @unittest.skipIf(os.environ.get('LOCAL_BUILD', False), "No remote resources desired")
     def test_portrait(self):
         val = render_to_string('thumbnail4.html', {
             'source': 'http://dummyimage.com/120x100/',
--- a/tests/thumbnail_tests/test_filters.py
+++ b/tests/thumbnail_tests/test_filters.py
@@ -1,4 +1,8 @@
 # -*- coding: utf-8 -*-
+
+import os
+import unittest
+
 import pytest
 from django.template.loader import render_to_string
 
@@ -9,6 +13,7 @@
 
 
 class FilterTestCase(BaseTestCase):
+    @unittest.skipIf(os.environ.get('LOCAL_BUILD', False), "No remote resources desired")
     def test_html_filter(self):
         text = '<img alt="A image!" src="http://dummyimage.com/800x800" />'
         val = render_to_string('htmlfilter.html', {'text': text, }).strip()
@@ -29,6 +34,7 @@
             val
         )
 
+    @unittest.skipIf(os.environ.get('LOCAL_BUILD', False), "No remote resources desired")
     def test_markdown_filter(self):
         text = '![A image!](http://dummyimage.com/800x800)'
         val = render_to_string('markdownfilter.html', {'text': text, }).strip()