Mercurial > p > roundup > code
annotate test/test_config.py @ 6137:eb9d00db0923
Forgot to check in changed doc files for 2.0.0beta0
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 06 Apr 2020 10:06:08 -0400 |
| parents | 95a366d46065 |
| children | 6cf9f2f49b89 |
| 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 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
21 import os, shutil, errno |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
22 |
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
23 import pytest |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
24 from roundup import configuration |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
25 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
26 config = configuration.CoreConfig() |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
27 config.DATABASE = "db" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
28 config.RDBMS_NAME = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
29 config.RDBMS_HOST = "localhost" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
30 config.RDBMS_USER = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
31 config.RDBMS_PASSWORD = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
32 config.RDBMS_TEMPLATE = "template0" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
33 # 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
|
34 config.MAIL_DOMAIN = "your.tracker.email.domain.example" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
35 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
|
36 # 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
|
37 # 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
|
38 # to 'run_tests.py' script |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
39 #config.LOGGING_FILENAME = "/tmp/logfile" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
40 #config.LOGGING_LEVEL = "DEBUG" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
41 config.init_logging() |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
42 config.options['FOO'] = "value" |
|
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 class ConfigTest(unittest.TestCase): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
45 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
46 def test_badConfigKeyword(self): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
47 """Run configure tests looking for invalid option name |
|
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 self.assertRaises(configuration.InvalidOptionError, config._get_option, "BadOptionName") |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
50 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
51 def test_validConfigKeyword(self): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
52 """Run configure tests looking for invalid option name |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
53 """ |
|
5794
95a366d46065
Replace deprecated assertEquals with assertEqual and failUnlessRaises
John Rouillard <rouilj@ieee.org>
parents:
5774
diff
changeset
|
54 self.assertEqual(config._get_option("FOO"), "value") |
|
5770
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
55 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
56 def testTrackerWeb(self): |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
57 config = configuration.CoreConfig() |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
58 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
59 self.assertEqual(None, |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
60 config._get_option('TRACKER_WEB').set("http://foo.example/bar/")) |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
61 self.assertEqual(None, |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
62 config._get_option('TRACKER_WEB').set("https://foo.example/bar/")) |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
63 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
64 self.assertRaises(configuration.OptionValueError, |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
65 config._get_option('TRACKER_WEB').set, "https://foo.example/bar") |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
66 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
67 self.assertRaises(configuration.OptionValueError, |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
68 config._get_option('TRACKER_WEB').set, "htt://foo.example/bar/") |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
69 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
70 self.assertRaises(configuration.OptionValueError, |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
71 config._get_option('TRACKER_WEB').set, "htt://foo.example/bar") |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
72 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
73 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
74 config._get_option('TRACKER_WEB').set, "") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
75 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
76 def testLoginAttemptsMin(self): |
|
5772
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
77 config = configuration.CoreConfig() |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
78 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
79 self.assertEqual(None, |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
80 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("0")) |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
81 self.assertEqual(None, |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
82 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("200")) |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
83 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
84 self.assertRaises(configuration.OptionValueError, |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
85 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "fred") |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
86 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
87 self.assertRaises(configuration.OptionValueError, |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
88 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "-1") |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
89 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
90 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
91 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
92 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
93 def testTimeZone(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
94 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
95 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
96 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
97 config._get_option('TIMEZONE').set("0")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
98 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
99 # not a valid timezone |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
100 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
101 config._get_option('TIMEZONE').set, "Zot") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
102 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
103 # 25 is not a valid UTC offset: -12 - +14 is range |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
104 # possibly +/- 1 for DST. But roundup.date doesn't |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
105 # constrain to this range. |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
106 #self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
107 # config._get_option('TIMEZONE').set, "25") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
108 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
109 try: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
110 import pytz |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
111 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
112 config._get_option('TIMEZONE').set("UTC")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
113 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
114 config._get_option('TIMEZONE').set("America/New_York")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
115 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
116 except ImportError: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
117 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
118 config._get_option('TIMEZONE').set, "UTC") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
119 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
120 config._get_option('TIMEZONE').set, "America/New_York") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
121 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
122 def testWebSecretKey(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
123 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
124 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
125 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
126 config._get_option('WEB_SECRET_KEY').set("skskskd")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
127 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
128 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
129 config._get_option('WEB_SECRET_KEY').set, "") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
130 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
131 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
132 def testStaticFiles(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
133 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
134 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
135 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
136 config._get_option('STATIC_FILES').set("foo /tmp/bar")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
137 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
138 self.assertEqual(config.STATIC_FILES, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
139 ["./foo", "/tmp/bar"]) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
140 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
141 self.assertEqual(config['STATIC_FILES'], |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
142 ["./foo", "/tmp/bar"]) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
143 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
144 def testIsolationLevel(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
145 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
146 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
147 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
148 config._get_option('RDBMS_ISOLATION_LEVEL').set("read uncommitted")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
149 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
150 config._get_option('RDBMS_ISOLATION_LEVEL').set("read committed")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
151 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
152 config._get_option('RDBMS_ISOLATION_LEVEL').set("repeatable read")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
153 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
154 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
155 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
156 config._get_option('RDBMS_ISOLATION_LEVEL').set, "not a level") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
157 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
158 def testConfigSave(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
159 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
160 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
161 # make scratch directory to create files in |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
162 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
163 self.startdir = os.getcwd() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
164 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
165 self.dirname = os.getcwd() + '_test_config' |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
166 os.mkdir(self.dirname) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
167 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
168 try: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
169 os.chdir(self.dirname) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
170 self.assertFalse(os.access("config.ini", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
171 self.assertFalse(os.access("config.bak", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
172 config.save() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
173 config.save() # creates .bak file |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
174 self.assertTrue(os.access("config.ini", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
175 self.assertTrue(os.access("config.bak", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
176 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
177 self.assertFalse(os.access("foo.bar", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
178 self.assertFalse(os.access("foo.bak", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
179 config.save("foo.bar") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
180 config.save("foo.bar") # creates .bak file |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
181 self.assertTrue(os.access("foo.bar", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
182 self.assertTrue(os.access("foo.bak", os.F_OK)) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
183 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
184 finally: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
185 # cleanup scratch directory and files |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
186 try: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
187 os.chdir(self.startdir) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
188 shutil.rmtree(self.dirname) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
189 except OSError as error: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
190 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
191 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
192 def testFloatAndInt_with_update_option(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
193 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
194 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
195 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
196 # Update existing IntegerNumberGeqZeroOption to IntegerNumberOption |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
197 config.update_option('WEB_LOGIN_ATTEMPTS_MIN', |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
198 configuration.IntegerNumberOption, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
199 "0", description="new desc") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
200 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
201 # -1 is allowed now that it is an int. |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
202 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
203 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("-1")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
204 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
205 # but can't float this |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
206 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
207 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "2.4") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
208 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
209 # but fred is still an issue |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
210 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
211 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "fred") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
212 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
213 # Update existing IntegerNumberOption to FloatNumberOption |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
214 config.update_option('WEB_LOGIN_ATTEMPTS_MIN', |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
215 configuration.FloatNumberOption, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
216 "0.0") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
217 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
218 self.assertEqual(config['WEB_LOGIN_ATTEMPTS_MIN'], -1) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
219 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
220 # can float this |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
221 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
222 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("3.1415926")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
223 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
224 # but fred is still an issue |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
225 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
226 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "fred") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
227 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
228 self.assertAlmostEqual(config['WEB_LOGIN_ATTEMPTS_MIN'], 3.1415926, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
229 places=6) |
