1 # -*- coding: utf-8 -*-
3 from django.core.files.base import ContentFile
5 from catalogue.test_utils import *
6 from catalogue import models
8 class BookMediaTests(WLTestCase):
11 WLTestCase.setUp(self)
12 self.file = ContentFile('X')
14 def test_diacritics(self):
15 bm = models.BookMedia.objects.create(type="ogg",
16 name="Zażółć gęślą jaźń")
17 bm.file.save(bm.name, self.file)
18 self.assertEqual(bm.file.name.rsplit('/', 1)[-1], 'zazolc-gesla-jazn.ogg')
21 def test_long_name(self):
22 bm = models.BookMedia.objects.create(type="ogg",
23 name="Some very very very very very very very very very very very very very very very very long file name")
25 # save twice so Django adds some stuff
26 bm.file.save(bm.name, self.file)
27 bm.file.save(bm.name, self.file)
30 # reload to see what was really saved
31 bm = models.BookMedia.objects.get(pk=bm.pk)
32 self.assertEqual(bm.file.size, 1)