mirror of
https://github.com/rbreu/beeref.git
synced 2026-03-11 08:54:28 +00:00
Added unit tests for pinterst image download
This commit is contained in:
parent
fb8515e8ae
commit
2af6a75cc3
3 changed files with 64 additions and 1 deletions
|
|
@ -31,6 +31,7 @@ Fixed
|
|||
hangs/weird behaviour)
|
||||
* Fixed an intermittent crash when invoking New Scene
|
||||
* Fixed bee files hanging on to disk space of deleted images (issue #99)
|
||||
* Fixing Drag @ Drop from pinterest feed (by Randommist)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ from urllib import parse, request
|
|||
from PyQt6 import QtGui
|
||||
|
||||
import exif
|
||||
import plum
|
||||
from lxml import etree
|
||||
import plum
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
|||
|
|
@ -122,3 +122,65 @@ def test_load_image_loads_from_web_url_errors(view, imgfilename3x3):
|
|||
img, filename = load_image(QtCore.QUrl(url))
|
||||
assert img.isNull() is True
|
||||
assert filename == url
|
||||
|
||||
|
||||
@httpretty.activate
|
||||
def test_load_image_from_pinterest_finds_image(view, imgdata3x3):
|
||||
url = 'http://pinterest.com/a1b2c3/'
|
||||
img_url = 'http://pinterest.com/foo.png'
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
url,
|
||||
body=f'<html><body><img src="{img_url}"/></body></html>',
|
||||
)
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
img_url,
|
||||
body=imgdata3x3,
|
||||
)
|
||||
img, filename = load_image(QtCore.QUrl(url))
|
||||
assert img.isNull() is False
|
||||
assert filename == img_url
|
||||
|
||||
|
||||
@httpretty.activate
|
||||
def test_load_image_from_pinterest_when_already_image(view, imgdata3x3):
|
||||
img_url = 'http://pinterest.com/foo.png'
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
img_url,
|
||||
body=imgdata3x3,
|
||||
)
|
||||
img, filename = load_image(QtCore.QUrl(img_url))
|
||||
assert img.isNull() is False
|
||||
assert filename == img_url
|
||||
|
||||
|
||||
@httpretty.activate
|
||||
def test_load_image_from_pinterest_when_img_url_not_found(view, imgdata3x3):
|
||||
url = 'http://pinterest.com/a1b2c3/'
|
||||
img_url = 'http://pinterest.com/foo.png'
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
url,
|
||||
body='<html><body><p>no image here</p></body></html>',
|
||||
)
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
img_url,
|
||||
body=imgdata3x3,
|
||||
)
|
||||
img, filename = load_image(QtCore.QUrl(url))
|
||||
assert img.isNull() is True
|
||||
|
||||
|
||||
@httpretty.activate
|
||||
def test_load_image_from_pinterest_when_url_errors(view, imgdata3x3):
|
||||
url = 'http://pinterest.com/a1b2c3/'
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
url,
|
||||
status=500,
|
||||
)
|
||||
img, filename = load_image(QtCore.QUrl(url))
|
||||
assert img.isNull() is True
|
||||
|
|
|
|||
Loading…
Reference in a new issue