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():
19 themes.update([(tag.category, tag.name)
20 for tag in area.tags if tag.category in (u'theme', u'thing')])
21 assert themes == set([(u'theme', u'nieporządek'), (u'thing', u'kosmos')]), \
22 'Bad themes on Picture areas: %s' % themes
24 pic_themes = set([tag.name for tag in picture.tags if tag.category in ('theme', 'object')])
25 assert not pic_themes, 'Unwanted themes set on Pictures: %s' % pic_themes
29 def test_import_with_explicit_image(self):
30 picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
31 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