1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
5 from picture.models import Picture
6 from catalogue.test_utils import WLTestCase
9 class PictureTest(WLTestCase):
11 def test_import(self):
12 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))
15 for area in picture.areas.all():
17 (tag.category, tag.name)
18 for tag in area.tags if tag.category in ('theme', 'thing')])
19 assert themes == {('theme', 'nieporządek'), ('thing', 'Kosmos')}, \
20 'Bad themes on Picture areas: %s' % themes
22 pic_themes = set([tag.name for tag in picture.tags if tag.category in ('theme', 'thing')])
23 assert not pic_themes, 'Unwanted themes set on Pictures: %s' % pic_themes
27 def test_import_with_explicit_image(self):
28 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
29 path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"))
33 def test_import_2(self):
34 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
35 path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"),
37 cats = set([t.category for t in picture.tags])
38 assert 'epoch' in cats