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_')
15 shutil.rmtree(settings.MEDIA_ROOT, True)
16 settings.MEDIA_ROOT = self._MEDIA_ROOT
18 class PersonStub(object):
20 def __init__(self, first_names, last_name):
21 self.first_names = first_names
22 self.last_name = last_name
25 class BookInfoStub(object):
27 def __init__(self, **kwargs):
30 def __setattr__(self, key, value):
31 if not key.startswith('_'):
32 self.__dict[key] = value
33 return object.__setattr__(self, key, value)
35 def __getattr__(self, key):
36 return self.__dict[key]
39 return dict((key, unicode(value)) for key, value in self.__dict.items())
43 """ generate some keywords for comfortable BookInfoCreation """
44 slug = unicode(slughifi(title))
46 'title': unicode(title),
48 'url': u"http://wolnelektury.pl/example/%s" % slug,
49 'about': u"http://wolnelektury.pl/example/URI/%s" % slug,