X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/a3c860f00c7d12ae5852ddab056c98f52ee43072..482477cced586463d7f342cdde8482a4d97d7685:/tests/test_picture.py diff --git a/tests/test_picture.py b/tests/test_picture.py index 4e3b252..40ca21c 100644 --- a/tests/test_picture.py +++ b/tests/test_picture.py @@ -4,21 +4,20 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from librarian import picture, dcparser -from lxml import etree from nose.tools import * -from os.path import splitext from tests.utils import get_all_fixtures, get_fixture -import codecs from os import path + def test_wlpictureuri(): uri = picture.WLPictureURI('http://wolnelektury.pl/katalog/obraz/angelus-novus') + def check_load(xml_file): pi = dcparser.parse(xml_file, picture.PictureInfo) assert pi is not None assert isinstance(pi, picture.PictureInfo) - + def test_load(): for fixture in get_all_fixtures('picture', '*.xml'): @@ -31,10 +30,29 @@ def test_wlpicture(): # from nose.tools import set_trace; set_trace() assert pi.type[0] == u"Image" - assert pi.mime_type == u'image/png' == wlp.mime_type + assert pi.mime_type == u'image/jpeg' == wlp.mime_type assert wlp.slug == 'angelus-novus' assert path.exists(wlp.image_path) - + f = wlp.image_file('r') f.close() + + +def test_picture_parts(): + wlp = picture.WLPicture.from_file(open(get_fixture('picture', 'angelus-novus.xml'))) + parts = list(wlp.partiter()) + assert len(parts) == 5, "there should be %d parts of the picture" % 5 + motifs = set() + names = set() + + print parts + for p in parts: + for m in p['themes']: + motifs.add(m) + for p in parts: + if p['object']: + names.add(p['object']) + + assert motifs == {u'anioł historii', u'spojrzenie'}, "missing motifs, got: %s" % motifs + assert names == {u'obraz cały', u'skrzydło'}, 'missing objects, got: %s' % names