source: dynamicfieldsplugin/trunk/dynfields/tests/options.py

Last change on this file was 16951, checked in by Ryan J Ollos, 6 years ago

TracDynamicFields 2.3.0dev: Conform to PEP and require Trac >= 1.0

Refs #13323.

File size: 1.9 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2013-2014 Ryan J Ollos <ryan.j.ollos@gmail.com>
4#
5# This software is licensed as described in the file COPYING, which
6# you should have received as part of this distribution.
7#
8
9import shutil
10import tempfile
11import unittest
12
13from trac.config import Configuration
14from trac.test import EnvironmentStub
15
16from dynfields.options import Options
17
18
19class OptionsTestCase(unittest.TestCase):
20
21    def setUp(self):
22        self.env = EnvironmentStub(default_data=True,
23                                   enable=['trac.*', 'dynfields.*'],
24                                   path=tempfile.mkdtemp())
25
26    def tearDown(self):
27        self.env.reset_db()
28        shutil.rmtree(self.env.path)
29
30    def test_options(self):
31        self.env.config['ticket-custom'].set('version.show_when_type',
32                                             'enhancement')
33        self.env.config['ticket-custom'].set('alwayshidden.clear_on_hide',
34                                             False)
35        options = Options(self.env)
36
37        self.assertEqual('enhancement', options['version.show_when_type'])
38        self.assertEqual('False', options['alwayshidden.clear_on_hide'])
39
40    def test_options_inherit(self):
41        inherited_config = Configuration('')
42        inherited_config['ticket-custom'].set('version.show_when_type',
43                                              'enhancement')
44        inherited_config['ticket-custom'].set('alwayshidden.clear_on_hide',
45                                              False)
46        self.env.config.parents.append(inherited_config)
47        options = Options(self.env)
48
49        self.assertEqual('enhancement', options['version.show_when_type'])
50        self.assertEqual('False', options['alwayshidden.clear_on_hide'])
51
52
53def test_suite():
54    suite = unittest.TestSuite()
55    suite.addTest(unittest.makeSuite(OptionsTestCase, 'test'))
56    return suite
57
58
59if __name__ == '__main__':
60    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the repository browser.