Merge branch 'production' into pretty
[wolnelektury.git] / apps / picture / tests / picture_import.py
1 # -*- coding: utf-8 -*-
2 from __future__ import with_statement
3
4 from django.core.files.base import ContentFile, File
5 from catalogue.test_utils import *
6 from catalogue import models
7 from librarian import WLURI
8 from picture.models import Picture
9
10 from nose.tools import raises
11 import tempfile
12 from os import unlink, path, makedirs
13
14
15 class PictureTest(TestCase):
16     
17     def test_import(self):
18         picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))
19
20         motifs = set([tag.name for tag in picture.tags if tag.category == 'theme'])
21         assert motifs == set([u'nieporządek']), 'theme tags are wrong. %s' % motifs
22
23         picture.delete()
24
25     def test_import_with_explicit_image(self):
26         picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
27                                         path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"))
28
29         picture.delete()
30