1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from __future__ import with_statement
8 from picture.models import Picture
9 from catalogue.test_utils import WLTestCase
12 class PictureTest(WLTestCase):
14 def test_import(self):
15 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))
18 for area in picture.areas.all():
20 (tag.category, tag.name)
21 for tag in area.tags if tag.category in (u'theme', u'thing')])
22 assert themes == {(u'theme', u'nieporządek'), (u'thing', u'Kosmos')}, \
23 'Bad themes on Picture areas: %s' % themes
25 pic_themes = set([tag.name for tag in picture.tags if tag.category in ('theme', 'thing')])
26 assert not pic_themes, 'Unwanted themes set on Pictures: %s' % pic_themes
30 def test_import_with_explicit_image(self):
31 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
32 path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"))
36 def test_import_2(self):
37 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
38 path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"),
40 cats = set([t.category for t in picture.tags])
41 assert 'epoch' in cats