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_EPUB = settings.NO_BUILD_TXT = True
16 shutil.rmtree(settings.MEDIA_ROOT, True)
17 settings.MEDIA_ROOT = self._MEDIA_ROOT
19 class PersonStub(object):
21 def __init__(self, first_names, last_name):
22 self.first_names = first_names
23 self.last_name = last_name
26 class BookInfoStub(object):
28 def __init__(self, **kwargs):
31 def __setattr__(self, key, value):
32 if not key.startswith('_'):
33 self.__dict[key] = value
34 return object.__setattr__(self, key, value)
36 def __getattr__(self, key):
37 return self.__dict[key]
40 return dict((key, unicode(value)) for key, value in self.__dict.items())
44 """ generate some keywords for comfortable BookInfoCreation """
45 slug = unicode(slughifi(title))
47 'title': unicode(title),
49 'url': u"http://wolnelektury.pl/example/%s" % slug,
50 'about': u"http://wolnelektury.pl/example/URI/%s" % slug,