annotate tests/__init__.py @ 51:2733871775cd

More unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 31 Jan 2013 12:28:10 -0800
parents fb6ae96756c1
children 9dfbc2a40b71
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):
51
2733871775cd More unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents: 49
diff changeset
11 # Directory you can use for temporary files.
49
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 self.root = os.path.join(
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 os.path.dirname(os.path.dirname(__file__)),
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14 'test_data')
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 def tearDown(self):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 if hasattr(self, 'root') and os.path.isdir(self.root):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 shutil.rmtree(self.root)
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 def getWiki(self, **kwargs):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 parameters = self.getParameters()
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 for key in kwargs:
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 setattr(parameters, key, kwargs[key])
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 wiki = Wiki(parameters)
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25 return wiki
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 def getStartedWiki(self, **kwargs):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 wiki = self.getWiki(**kwargs)
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
29 wiki.start()
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
30 return wiki
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
31
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
32 def getParameters(self):
fb6ae96756c1 Added unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
33 return MockWikiParameters()