Mercurial > p > roundup > code
annotate test/test_config.py @ 5507:0db3779702d9
access exception args in a Python 3 compatible way
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Fri, 17 Aug 2018 19:44:12 +0100 |
| parents | dd642afb4440 |
| children | f91da208f26b |
| rev | line source |
|---|---|
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1 # |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
6 # |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
10 # POSSIBILITY OF SUCH DAMAGE. |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
11 # |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
17 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
18 import unittest |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
19 import logging |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
20 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
21 import pytest |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
22 from roundup import configuration |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
23 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
24 config = configuration.CoreConfig() |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
25 config.DATABASE = "db" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
26 config.RDBMS_NAME = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
27 config.RDBMS_HOST = "localhost" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
28 config.RDBMS_USER = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
29 config.RDBMS_PASSWORD = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
30 config.RDBMS_TEMPLATE = "template0" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
31 # these TRACKER_WEB and MAIL_DOMAIN values are used in mailgw tests |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
32 config.MAIL_DOMAIN = "your.tracker.email.domain.example" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
33 config.TRACKER_WEB = "http://tracker.example/cgi-bin/roundup.cgi/bugs/" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
34 # uncomment the following to have excessive debug output from test cases |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
35 # FIXME: tracker logging level should be increased by -v arguments |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
36 # to 'run_tests.py' script |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
37 #config.LOGGING_FILENAME = "/tmp/logfile" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
38 #config.LOGGING_LEVEL = "DEBUG" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
39 config.init_logging() |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
40 config.options['FOO'] = "value" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
41 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
42 class ConfigTest(unittest.TestCase): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
43 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
44 def test_badConfigKeyword(self): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
45 """Run configure tests looking for invalid option name |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
46 """ |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
47 self.assertRaises(configuration.InvalidOptionError, config._get_option, "BadOptionName") |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
48 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
49 def test_validConfigKeyword(self): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
50 """Run configure tests looking for invalid option name |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
51 """ |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
52 self.assertEquals(config._get_option("FOO"), "value") |
