Merge lp:~soren/surveilr/config into lp:surveilr

Proposed by Soren Hansen
Status: Merged
Approved by: Soren Hansen
Approved revision: 10
Merged at revision: 10
Proposed branch: lp:~soren/surveilr/config
Merge into: lp:surveilr
Diff against target: 93 lines (+39/-19)
3 files modified
setup.py (+1/-0)
surveilr/tests/__init__.py (+34/-0)
surveilr/tests/test_config.py (+4/-19)
To merge this branch: bzr merge lp:~soren/surveilr/config
Reviewer Review Type Date Requested Status
Soren Hansen Pending
Review via email: mp+83873@code.launchpad.net

Commit message

Move config override magic for tests into common test class.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'setup.py'
--- setup.py 2011-11-16 09:15:46 +0000
+++ setup.py 2011-11-29 23:26:26 +0000
@@ -31,6 +31,7 @@
31 packages=['surveilr'],31 packages=['surveilr'],
32 install_requires=['riakalchemy'],32 install_requires=['riakalchemy'],
33 test_suite='nose.collector',33 test_suite='nose.collector',
34 install_package_data=True,
34 classifiers=[35 classifiers=[
35 'Development Status :: 2 - Pre-Alpha',36 'Development Status :: 2 - Pre-Alpha',
36 'Environment :: Console',37 'Environment :: Console',
3738
=== modified file 'surveilr/tests/__init__.py'
--- surveilr/tests/__init__.py 2011-11-22 08:51:25 +0000
+++ surveilr/tests/__init__.py 2011-11-29 23:26:26 +0000
@@ -17,3 +17,37 @@
17 License along with this program. If not, see17 License along with this program. If not, see
18 <http://www.gnu.org/licenses/>.18 <http://www.gnu.org/licenses/>.
19"""19"""
20
21import mock
22import os.path
23import unittest
24
25from surveilr import config
26
27class TestCase(unittest.TestCase):
28 def config_files(self):
29 module = self.__module__
30 if not module.startswith('surveilr.tests'):
31 return
32
33 cfg_file = '%s.cfg' % (os.path.join(os.path.dirname(__file__),
34 *module.split('.')[2:]),)
35 return [cfg_file]
36
37 def defaults_file(self):
38 return os.path.join(os.path.dirname(__file__),
39 os.path.pardir, 'defaults.cfg')
40
41 def setUp(self):
42 super(TestCase, self).setUp()
43 with mock.patch('surveilr.config.defaults_file') as defaults_file:
44 with mock.patch('surveilr.config.config_files') as config_files:
45 config_files.return_value = self.config_files()
46 defaults_file.return_value = self.defaults_file()
47
48 config.load_default_config()
49
50 def tearDown(self):
51 config.load_default_config()
52
53
2054
=== modified file 'surveilr/tests/test_config.py'
--- surveilr/tests/test_config.py 2011-11-28 22:18:35 +0000
+++ surveilr/tests/test_config.py 2011-11-29 23:26:26 +0000
@@ -21,31 +21,16 @@
21"""21"""
2222
23from surveilr import config23from surveilr import config
24from surveilr import tests
2425
25import mock
26import os.path26import os.path
27import unittest27
2828
2929class ConfigTest(tests.TestCase):
30class ConfigTest(unittest.TestCase):
31 def config_files(self):
32 return []
33
34 def defaults_file(self):30 def defaults_file(self):
35 return os.path.join(os.path.dirname(__file__),31 return os.path.join(os.path.dirname(__file__),
36 'test_config_defaults.cfg')32 'test_config_defaults.cfg')
3733
38 def setUp(self):
39 with mock.patch('surveilr.config.defaults_file') as defaults_file:
40 with mock.patch('surveilr.config.config_files') as config_files:
41 config_files.return_value = self.config_files()
42 defaults_file.return_value = self.defaults_file()
43
44 config.load_default_config()
45
46 def tearDown(self):
47 config.load_default_config()
48
4934
50class ConfigCoercionTests(ConfigTest):35class ConfigCoercionTests(ConfigTest):
51 def test_str(self):36 def test_str(self):

Subscribers

People subscribed via source and target branches

to all changes: