1 from django.conf import settings
2 from django.test import TestCase
5 from slughifi import slughifi
7 class WLTestCase(TestCase):
9 Generic base class for tests. Adds settings freeze and clears MEDIA_ROOT.
12 self._MEDIA_ROOT, settings.MEDIA_ROOT = settings.MEDIA_ROOT, tempfile.mkdtemp(prefix='djangotest_')
13 settings.NO_BUILD_PDF = settings.NO_BUILD_MOBI = settings.NO_BUILD_EPUB = settings.NO_BUILD_TXT = True
14 settings.CELERY_ALWAYS_EAGER = True
17 shutil.rmtree(settings.MEDIA_ROOT, True)
18 settings.MEDIA_ROOT = self._MEDIA_ROOT
20 class PersonStub(object):
22 def __init__(self, first_names, last_name):
23 self.first_names = first_names
24 self.last_name = last_name
27 class BookInfoStub(object):
29 def __init__(self, **kwargs):
32 def __setattr__(self, key, value):
33 if not key.startswith('_'):
34 self.__dict[key] = value
35 return object.__setattr__(self, key, value)
37 def __getattr__(self, key):
38 return self.__dict[key]
41 return dict((key, unicode(value)) for key, value in self.__dict.items())
45 """ generate some keywords for comfortable BookInfoCreation """
46 slug = unicode(slughifi(title))
48 'title': unicode(title),
50 'url': u"http://wolnelektury.pl/example/%s" % slug,
51 'about': u"http://wolnelektury.pl/example/URI/%s" % slug,