annotate tests/__init__.py @ 49:fb6ae96756c1

Added unit tests. Refactored core APIs to make them more testable. Removed unused stuff like caching the configuration in the SQL database. Fixed the web bootstrap. Some cosmetic changes to be PEP8 compliant.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 28 Jan 2013 23:13:04 -0800
parents
children 2733871775cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 import os
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 import os.path
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 import shutil
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 import unittest
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 from wikked.wiki import Wiki
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 from mock import MockWikiParameters
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 class WikkedTest(unittest.TestCase):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 def setUp(self):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 self.root = os.path.join(
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 os.path.dirname(os.path.dirname(__file__)),
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 'test_data')
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 def tearDown(self):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 if hasattr(self, 'root') and os.path.isdir(self.root):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 shutil.rmtree(self.root)
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 def getWiki(self, **kwargs):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 parameters = self.getParameters()
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 for key in kwargs:
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 setattr(parameters, key, kwargs[key])
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 wiki = Wiki(parameters)
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 return wiki
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 def getStartedWiki(self, **kwargs):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 wiki = self.getWiki(**kwargs)
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 wiki.start()
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29 return wiki
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
31 def getParameters(self):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
32 return MockWikiParameters()