1 # -*- coding: utf-8 -*-
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from librarian import picture, dcparser
7 from nose.tools import *
8 from tests.utils import get_all_fixtures, get_fixture
12 def test_wlpictureuri():
13 uri = picture.WLPictureURI('http://wolnelektury.pl/katalog/obraz/angelus-novus')
16 def check_load(xml_file):
17 pi = dcparser.parse(xml_file, picture.PictureInfo)
19 assert isinstance(pi, picture.PictureInfo)
23 for fixture in get_all_fixtures('picture', '*.xml'):
24 yield check_load, fixture
28 wlp = picture.WLPicture.from_file(open(get_fixture('picture', 'angelus-novus.xml')))
31 # from nose.tools import set_trace; set_trace()
32 assert pi.type[0] == u"Image"
33 assert pi.mime_type == u'image/jpeg' == wlp.mime_type
34 assert wlp.slug == 'angelus-novus'
36 assert path.exists(wlp.image_path)
38 f = wlp.image_file('r')
42 def test_picture_parts():
43 wlp = picture.WLPicture.from_file(open(get_fixture('picture', 'angelus-novus.xml')))
44 parts = list(wlp.partiter())
45 assert len(parts) == 5, "there should be %d parts of the picture" % 5
55 names.add(p['object'])
57 assert motifs == {u'anioł historii', u'spojrzenie'}, "missing motifs, got: %s" % motifs
58 assert names == {u'obraz cały', u'skrzydło'}, 'missing objects, got: %s' % names