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