Fix: typo
[wolnelektury.git] / apps / picture / tests / picture_import.py
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.
4 #
5 from __future__ import with_statement
6
7 from os import path
8 from picture.models import Picture
9 from catalogue.test_utils import WLTestCase
10
11
12 class PictureTest(WLTestCase):
13
14     def test_import(self):
15         picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))
16
17         motifs = set([tag.name for tag in picture.tags if tag.category == 'theme'])
18         assert motifs == set([u'nieporządek']), 'theme tags are wrong. %s' % motifs
19
20         picture.delete()
21
22     def test_import_with_explicit_image(self):
23         picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
24                                         path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"))
25
26         picture.delete()
27
28
29     def test_import_2(self):
30         picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/pejzaz-i-miasto-krzyzanowski-chmury.xml"),
31                                         path.join(path.dirname(__file__), "files/pejzaz-i-miasto-krzyzanowski-chmury.jpg"),
32                                         overwrite=True)
33         cats = set([t.category for t in picture.tags])
34         assert 'genre' in cats
35         assert 'kind' in cats
36