X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/60b06883b6d5a336ef47c01103ec1ce25aafae69..b65636fcd90b21946fead6813d7f1312e7ade6ce:/apps/api/tests.py diff --git a/apps/api/tests.py b/apps/api/tests.py index 2c2e51ce8..5a981a26a 100644 --- a/apps/api/tests.py +++ b/apps/api/tests.py @@ -8,6 +8,14 @@ from django.conf import settings from api.helpers import timestamp from catalogue.models import Book, Tag +from picture.tests.utils import RequestFactory +from picture.forms import PictureImportForm +from picture.models import Picture, picture_storage +import picture.tests +from django.core.files.uploadedfile import SimpleUploadedFile + + +from os import path class ApiTest(TestCase): @@ -135,3 +143,22 @@ class TagTests(TestCase): tag = json.loads(self.client.get('/api/authors/joe/').content) self.assertEqual(tag['name'], self.tag.name, 'Wrong tag details.') + + +class PictureTests(ApiTest): + def test_publish(self): + slug = "kandinsky-composition-viii" + xml = SimpleUploadedFile('composition8.xml', open(path.join(picture.tests.__path__[0], "files", slug + ".xml")).read()) + img = SimpleUploadedFile('kompozycja-8.png', open(path.join(picture.tests.__path__[0], "files", slug + ".png")).read()) + + import_form = PictureImportForm({}, { + 'picture_xml_file': xml, + 'picture_image_file': img + }) + + assert import_form.is_valid() + if import_form.is_valid(): + import_form.save() + + pic = Picture.objects.get(slug=slug) +