Mercurial > p > roundup > code
annotate test/test_config.py @ 8010:c10df5dfed95 2.4.0b1
Removed tag 2.4.1b1
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 27 May 2024 17:01:45 -0400 |
| parents | 1e38ca6fb16e |
| children | 94eed885e958 |
| 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 |
|
7900
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
18 import errno |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
19 import fileinput |
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
20 import logging |
|
7900
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
21 import os |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
22 import pytest |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
23 import shutil |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
24 import sys |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
25 import unittest |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
26 |
|
7913
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
27 from os.path import normpath |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
28 |
|
7900
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
29 from roundup import configuration |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
30 from roundup.backends import get_backend, have_backend |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
31 from roundup.hyperdb import DatabaseError |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
32 |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
33 from .db_test_base import config |
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
34 |
|
7900
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
35 if not have_backend('postgresql'): |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
36 # FIX: workaround for a bug in pytest.mark.skip(): |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
37 # https://github.com/pytest-dev/pytest/issues/568 |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
38 from .pytest_patcher import mark_class |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
39 skip_postgresql = mark_class(pytest.mark.skip( |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
40 reason='Skipping PostgreSQL tests: backend not available')) |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
41 else: |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
42 try: |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
43 from roundup.backends.back_postgresql import psycopg2, db_command,\ |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
44 get_database_schema_names |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
45 db_command(config, 'select 1') |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
46 skip_postgresql = lambda func, *args, **kwargs: func |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
47 except( DatabaseError ) as msg: |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
48 from .pytest_patcher import mark_class |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
49 skip_postgresql = mark_class(pytest.mark.skip( |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
50 reason='Skipping PostgreSQL tests: database not available')) |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
51 |
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
52 |
|
6367
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
53 try: |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
54 import xapian |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
55 skip_xapian = lambda func, *args, **kwargs: func |
|
6368
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
56 from .pytest_patcher import mark_class |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
57 include_no_xapian = mark_class(pytest.mark.skip( |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
58 "Skipping missing Xapian indexer tests: 'xapian' is installed")) |
|
6367
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
59 except ImportError: |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
60 # FIX: workaround for a bug in pytest.mark.skip(): |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
61 # https://github.com/pytest-dev/pytest/issues/568 |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
62 from .pytest_patcher import mark_class |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
63 skip_xapian = mark_class(pytest.mark.skip( |
|
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
64 "Skipping Xapian indexer tests: 'xapian' not installed")) |
|
6368
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
65 include_no_xapian = lambda func, *args, **kwargs: func |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
66 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
67 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
68 try: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
69 import redis |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
70 skip_redis = lambda func, *args, **kwargs: func |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
71 except ImportError: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
72 # FIX: workaround for a bug in pytest.mark.skip(): |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
73 # https://github.com/pytest-dev/pytest/issues/568 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
74 from .pytest_patcher import mark_class |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
75 skip_redis = mark_class(pytest.mark.skip( |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
76 "Skipping redis tests: 'redis' not installed")) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
77 |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
78 _py3 = sys.version_info[0] > 2 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
79 if _py3: |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
80 skip_py2 = lambda func, *args, **kwargs: func |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
81 else: |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
82 # FIX: workaround for a bug in pytest.mark.skip(): |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
83 # https://github.com/pytest-dev/pytest/issues/568 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
84 from .pytest_patcher import mark_class |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
85 skip_py2 = mark_class(pytest.mark.skip( |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
86 reason='Skipping test under python2.')) |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
87 |
|
6367
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
88 |
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
89 config = configuration.CoreConfig() |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
90 config.DATABASE = "db" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
91 config.RDBMS_NAME = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
92 config.RDBMS_HOST = "localhost" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
93 config.RDBMS_USER = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
94 config.RDBMS_PASSWORD = "rounduptest" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
95 config.RDBMS_TEMPLATE = "template0" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
96 # 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
|
97 config.MAIL_DOMAIN = "your.tracker.email.domain.example" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
98 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
|
99 # 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
|
100 # 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
|
101 # to 'run_tests.py' script |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
102 #config.LOGGING_FILENAME = "/tmp/logfile" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
103 #config.LOGGING_LEVEL = "DEBUG" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
104 config.init_logging() |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
105 config.options['FOO'] = "value" |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
106 |
|
6331
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
107 # for TrackerConfig test class |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
108 from roundup import instance |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
109 from . import db_test_base |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
110 |
|
5126
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
111 class ConfigTest(unittest.TestCase): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
112 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
113 def test_badConfigKeyword(self): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
114 """Run configure tests looking for invalid option name |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
115 """ |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
116 self.assertRaises(configuration.InvalidOptionError, config._get_option, "BadOptionName") |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
117 |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
118 def test_validConfigKeyword(self): |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
119 """Run configure tests looking for invalid option name |
|
dd642afb4440
starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
120 """ |
|
5794
95a366d46065
Replace deprecated assertEquals with assertEqual and failUnlessRaises
John Rouillard <rouilj@ieee.org>
parents:
5774
diff
changeset
|
121 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
|
122 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
123 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
|
124 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
|
125 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 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
|
130 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
131 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
|
132 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
|
133 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
134 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
|
135 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
|
136 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5126
diff
changeset
|
137 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
|
138 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
|
139 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
140 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
141 config._get_option('TRACKER_WEB').set, "") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
142 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
143 def testRedis_Url(self): |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
144 config = configuration.CoreConfig() |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
145 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
146 with self.assertRaises(configuration.OptionValueError) as cm: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
147 config._get_option('SESSIONDB_REDIS_URL').set( |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
148 "redis://foo.example/bar?decode_responses=False") |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
149 self.assertIn('decode_responses', cm.exception.__str__()) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
150 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
151 config._get_option('SESSIONDB_REDIS_URL').set( |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
152 "redis://localhost:6379/0?health_check_interval=2") |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
153 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
154 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
|
155 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
|
156 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 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
|
161 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
162 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
|
163 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
|
164 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
165 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
|
166 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
|
167 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
168 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
169 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
|
170 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
171 def testTimeZone(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
172 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
173 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
174 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
175 config._get_option('TIMEZONE').set("0")) |
|
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 # not a valid timezone |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
178 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
179 config._get_option('TIMEZONE').set, "Zot") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
180 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
181 # 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
|
182 # 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
|
183 # constrain to this range. |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
184 #self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
185 # config._get_option('TIMEZONE').set, "25") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
186 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
187 try: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
188 import pytz |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
189 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
190 config._get_option('TIMEZONE').set("UTC")) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
191 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
192 config._get_option('TIMEZONE').set("America/New_York")) |
|
6296
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
193 self.assertEqual(None, |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
194 config._get_option('TIMEZONE').set("EST")) |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
195 self.assertRaises(configuration.OptionValueError, |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
196 config._get_option('TIMEZONE').set, "Zool/Zot") |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
197 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
198 except ImportError: |
|
6296
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
199 # UTC is a known offset of 0 coded into roundup.date |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
200 # so it works even without pytz. |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
201 self.assertEqual(None, |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
202 config._get_option('TIMEZONE').set("UTC")) |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
203 # same with EST known timeone offset of 5 |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
204 self.assertEqual(None, |
|
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
205 config._get_option('TIMEZONE').set("EST")) |
|
5774
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('TIMEZONE').set, "America/New_York") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
208 |
|
6296
6cf9f2f49b89
Fix UTC timezone test case if pytz not available; add tests
John Rouillard <rouilj@ieee.org>
parents:
5794
diff
changeset
|
209 |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
210 def testWebSecretKey(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
211 config = configuration.CoreConfig() |
|
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 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
214 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
|
215 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
216 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
217 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
|
218 |
|
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 def testStaticFiles(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
221 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
222 |
|
7913
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
223 |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
224 if ("/tmp/bar" == normpath("/tmp/bar/")): |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
225 result_list = ["./foo", "/tmp/bar"] |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
226 else: |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
227 result_list = [".\\foo", "\\tmp\\bar"] |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
228 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
229 config._get_option('STATIC_FILES').set("foo /tmp/bar")) |
|
7913
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
230 print(config.STATIC_FILES) |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
231 self.assertEqual(config.STATIC_FILES, result_list) |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
232 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
233 def testIsolationLevel(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
234 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
235 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
236 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
237 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
|
238 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
239 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
|
240 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
241 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
|
242 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
243 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
244 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
245 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
|
246 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
247 def testConfigSave(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
248 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
249 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
250 # 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
|
251 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
252 self.startdir = os.getcwd() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
253 |
|
7584
a5629f6e7ec2
test: fix mising / in directory spec.
John Rouillard <rouilj@ieee.org>
parents:
7556
diff
changeset
|
254 self.dirname = os.getcwd() + '/_test_config' |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
255 os.mkdir(self.dirname) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
256 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
257 try: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
258 os.chdir(self.dirname) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
259 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
|
260 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
|
261 config.save() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
262 config.save() # creates .bak file |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
263 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
|
264 self.assertTrue(os.access("config.bak", os.F_OK)) |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
265 config.save() # trigger delete of old .bak file |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
266 # FIXME: this should test to see if a new .bak |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
267 # was created. For now verify .bak still exists |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
268 self.assertTrue(os.access("config.bak", os.F_OK)) |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
269 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
270 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
|
271 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
|
272 config.save("foo.bar") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
273 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
|
274 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
|
275 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
|
276 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
277 finally: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
278 # cleanup scratch directory and files |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
279 try: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
280 os.chdir(self.startdir) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
281 shutil.rmtree(self.dirname) |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
282 except OSError as error: |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
283 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
|
284 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
285 def testFloatAndInt_with_update_option(self): |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
286 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
287 config = configuration.CoreConfig() |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
288 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
289 # Update existing IntegerNumberGeqZeroOption to IntegerNumberOption |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
290 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
|
291 configuration.IntegerNumberOption, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
292 "0", description="new desc") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
293 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
294 # -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
|
295 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
296 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
|
297 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
298 # but can't float this |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
299 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
300 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
|
301 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
302 # but fred is still an issue |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
303 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
304 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
|
305 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
306 # Update existing IntegerNumberOption to FloatNumberOption |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
307 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
|
308 configuration.FloatNumberOption, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
309 "0.0") |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
310 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
311 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
|
312 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
313 # can float this |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
314 self.assertEqual(None, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
315 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
|
316 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
317 # but fred is still an issue |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
318 self.assertRaises(configuration.OptionValueError, |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
319 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
|
320 |
|
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
321 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
|
322 places=6) |
|
6331
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
323 |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
324 # test removal of .0 on floats that are integers |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
325 self.assertEqual(None, |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
326 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("3.0")) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
327 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
328 self.assertEqual("3", |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
329 config._get_option('WEB_LOGIN_ATTEMPTS_MIN')._value2str(3.00)) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
330 |
|
7556
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
331 def testIntegerNumberGtZeroOption(self): |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
332 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
333 config = configuration.CoreConfig() |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
334 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
335 # Update existing IntegerNumberGeqZeroOption to IntegerNumberOption |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
336 config.update_option('WEB_LOGIN_ATTEMPTS_MIN', |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
337 configuration.IntegerNumberGtZeroOption, |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
338 "1", description="new desc") |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
339 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
340 self.assertEqual(None, |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
341 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("1")) |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
342 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
343 # -1 is not allowed |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
344 self.assertRaises(configuration.OptionValueError, |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
345 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "-1") |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
346 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
347 # but can't float this |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
348 self.assertRaises(configuration.OptionValueError, |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
349 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "2.4") |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
350 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
351 # but can't float this |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
352 self.assertRaises(configuration.OptionValueError, |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
353 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set, "0.5") |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
354 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
355 |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
356 def testOriginHeader(self): |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
357 config = configuration.CoreConfig() |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
358 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
359 with self.assertRaises(configuration.OptionValueError) as cm: |
|
7155
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
6821
diff
changeset
|
360 config._get_option('WEB_ALLOWED_API_ORIGINS').set("https://foo.edu *") |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
6821
diff
changeset
|
361 |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
6821
diff
changeset
|
362 config._get_option('WEB_ALLOWED_API_ORIGINS').set("* https://foo.edu HTTP://baR.edu") |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
363 |
|
7155
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
6821
diff
changeset
|
364 self.assertEqual(config['WEB_ALLOWED_API_ORIGINS'][0], '*') |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
6821
diff
changeset
|
365 self.assertEqual(config['WEB_ALLOWED_API_ORIGINS'][1], 'https://foo.edu') |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
6821
diff
changeset
|
366 self.assertEqual(config['WEB_ALLOWED_API_ORIGINS'][2], 'HTTP://baR.edu') |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
367 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6604
diff
changeset
|
368 |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
369 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
370 def testOptionAsString(self): |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
371 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
372 config = configuration.CoreConfig() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
373 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
374 config._get_option('WEB_LOGIN_ATTEMPTS_MIN').set("2552") |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
375 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
376 v = config._get_option('WEB_LOGIN_ATTEMPTS_MIN').__str__() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
377 print(v) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
378 self.assertIn("55", v) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
379 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
380 v = config._get_option('WEB_LOGIN_ATTEMPTS_MIN').__repr__() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
381 print(v) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
382 self.assertIn("55", v) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
383 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
384 def testBooleanOption(self): |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
385 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
386 config = configuration.CoreConfig() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
387 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
388 with self.assertRaises(configuration.OptionValueError) as cm: |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
389 config._get_option('INSTANT_REGISTRATION').set("3") |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
390 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
391 # test multiple boolean representations |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
392 for b in [ "yes", "1", "true", "TRUE", "tRue", "on", |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
393 "oN", 1, True ]: |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
394 self.assertEqual(None, |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
395 config._get_option('INSTANT_REGISTRATION').set(b)) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
396 self.assertEqual(1, |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
397 config._get_option('INSTANT_REGISTRATION').get()) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
398 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
399 for b in ["no", "0", "false", "FALSE", "fAlse", "off", |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
400 "oFf", 0, False]: |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
401 self.assertEqual(None, |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
402 config._get_option('INSTANT_REGISTRATION').set(b)) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
403 self.assertEqual(0, |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
404 config._get_option('INSTANT_REGISTRATION').get()) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
405 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
406 def testOctalNumberOption(self): |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
407 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
408 config = configuration.CoreConfig() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
409 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
410 with self.assertRaises(configuration.OptionValueError) as cm: |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
411 config._get_option('UMASK').set("xyzzy") |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
412 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
413 print(type(config._get_option('UMASK'))) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
414 |
|
6331
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
415 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
416 class TrackerConfig(unittest.TestCase): |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
417 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
418 backend = 'anydbm' |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
419 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
420 def setUp(self): |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
421 self.dirname = '_test_instance' |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
422 # set up and open a tracker |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
423 self.instance = db_test_base.setupTracker(self.dirname, self.backend) |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
424 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
425 # open the database |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
426 self.db = self.instance.open('admin') |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
427 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
428 self.db.commit() |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
429 self.db.close() |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
430 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
431 def tearDown(self): |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
432 if self.db: |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
433 self.db.close() |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
434 try: |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
435 shutil.rmtree(self.dirname) |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
436 except OSError as error: |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
437 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
438 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
439 def munge_configini(self, mods = None, section=None): |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
440 """ modify config.ini to meet testing requirements |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
441 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
442 mods is a list of tuples: |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
443 [ ( "a = ", "b" ), ("c = ", None), ("d = ", "b", "z = ") ] |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
444 Match line with first tuple element e.g. "a = ". Note specify |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
445 trailing "=" and space to delimit keyword and properly format |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
446 replacement line. If there are two elements in the tuple, |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
447 and the first element matches, the line is |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
448 replaced with the concatenation of the first and second elements. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
449 If second element is None ("" doesn't work), the line will be |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
450 deleted. If there are three elements in the tuple, the line |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
451 is replaced with the contcatentation of the third and second |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
452 elements (used to replace commented out parameters). |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
453 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
454 Note if the key/first element of tuple is not unique in |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
455 config.ini, you must set the section to match the bracketed |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
456 section name. |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
457 """ |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
458 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
459 if mods is None: |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
460 return |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
461 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
462 # if section is defined, the tests in the loop will turn |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
463 # it off on [main] if section != '[main]'. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
464 in_section = True |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
465 |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
466 for line in fileinput.input(os.path.join(self.dirname, "config.ini"), |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
467 inplace=True): |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
468 if section: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
469 if line.startswith('['): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
470 in_section = False |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
471 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
472 if line.startswith(section): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
473 in_section = True |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
474 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
475 if in_section: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
476 for rule in mods: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
477 if len(rule) == 3: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
478 match, value, repl = rule |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
479 else: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
480 match, value = rule |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
481 repl = None |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
482 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
483 if line.startswith(match): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
484 if value is not None: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
485 if repl: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
486 print(repl + value) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
487 else: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
488 print(match + value) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
489 break |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
490 else: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
491 print(line[:-1]) # remove trailing \n |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
492 else: |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
493 print(line[:-1]) # remove trailing \n |
|
6331
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
494 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
495 def testNoDBInConfig(self): |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
496 """Arguably this should be tested in test_instance since it is |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
497 triggered by instance.open. But it raises an error in the |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
498 configuration module with a missing required param in |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
499 config.ini. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
500 """ |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
501 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
502 # remove the backend key in config.ini |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
503 self.munge_configini(mods=[ ("backend = ", None) ]) |
|
6331
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
504 |
|
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
505 # this should fail as backend isn't defined. |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
506 with self.assertRaises(configuration.OptionUnsetError) as cm: |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
507 instance.open(self.dirname) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
508 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
509 self.assertEqual("RDBMS_BACKEND is not set" |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
510 " and has no default", cm.exception.__str__()) |
|
6331
c547e05d7a54
Test case where backend is missing from config.ini.
John Rouillard <rouilj@ieee.org>
parents:
6296
diff
changeset
|
511 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
512 def testUnsetMailPassword_with_set_username(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
513 """ Set [mail] username but don't set the |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
514 [mail] password. Should get an OptionValueError. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
515 """ |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
516 # SETUP: set mail username |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
517 self.munge_configini(mods=[ ("username = ", "foo"), ], |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
518 section="[mail]") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
519 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
520 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
521 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
522 with self.assertRaises(configuration.OptionValueError) as cm: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
523 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
524 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
525 print(cm.exception) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
526 # test repr. The type is right since it passed assertRaises. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
527 self.assertIn("OptionValueError", repr(cm.exception)) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
528 # look for 'not defined' |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
529 self.assertEqual("not defined", cm.exception.args[1]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
530 |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
531 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
532 def testUnsetMailPassword_with_unset_username(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
533 """ Set [mail] username but don't set the |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
534 [mail] password. Should get an OptionValueError. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
535 """ |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
536 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
537 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
538 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
539 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
540 self.assertEqual(config['MAIL_USERNAME'], '') |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
541 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
542 with self.assertRaises(configuration.OptionUnsetError) as cm: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
543 self.assertEqual(config['MAIL_PASSWORD'], 'NO DEFAULT') |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
544 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
545 def testSecretMandatory_missing_file(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
546 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
547 # SETUP: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
548 self.munge_configini(mods=[ ("secret_key = ", "file://secret_key"), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
549 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
550 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
551 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
552 with self.assertRaises(configuration.OptionValueError) as cm: |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
553 config.load(self.dirname) |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
554 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
555 print(cm.exception) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
556 self.assertEqual(cm.exception.args[0].setting, "secret_key") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
557 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
558 def testSecretMandatory_load_from_file(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
559 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
560 # SETUP: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
561 self.munge_configini(mods=[ ("secret_key = ", "file://secret_key"), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
562 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
563 secret = "ASDQWEZXCRFVBGTYHNMJU" |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
564 with open(self.dirname + "/secret_key", "w") as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
565 f.write(secret + "\n") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
566 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
567 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
568 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
569 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
570 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
571 self.assertEqual(config['WEB_SECRET_KEY'], secret) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
572 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
573 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
574 def testSecretMandatory_load_from_abs_file(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
575 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
576 abs_file = "/tmp/secret_key.%s"%os.getpid() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
577 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
578 # SETUP: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
579 self.munge_configini(mods=[ ("secret_key = ", "file://%s"%abs_file), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
580 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
581 secret = "ASDQWEZXCRFVBGTYHNMJU" |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
582 with open(abs_file, "w") as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
583 f.write(secret + "\n") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
584 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
585 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
586 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
587 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
588 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
589 self.assertEqual(config['WEB_SECRET_KEY'], secret) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
590 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
591 os.remove(abs_file) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
592 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
593 def testSecretMandatory_empty_file(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
594 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
595 self.munge_configini(mods=[ ("secret_key = ", "file:// secret_key"), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
596 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
597 # file with no value just newline. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
598 with open(self.dirname + "/secret_key", "w") as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
599 f.write("\n") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
600 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
601 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
602 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
603 with self.assertRaises(configuration.OptionValueError) as cm: |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
604 config.load(self.dirname) |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
605 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
606 print(cm.exception.args) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
607 self.assertEqual(cm.exception.args[2],"Value must not be empty.") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
608 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
609 def testNullableSecret_empty_file(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
610 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
611 self.munge_configini(mods=[ ("password = ", "file://db_password"), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
612 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
613 # file with no value just newline. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
614 with open(self.dirname + "/db_password", "w") as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
615 f.write("\n") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
616 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
617 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
618 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
619 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
620 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
621 v = config['RDBMS_PASSWORD'] |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
622 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
623 self.assertEqual(v, None) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
624 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
625 def testNullableSecret_with_file_value(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
626 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
627 self.munge_configini(mods=[ ("password = ", "file://db_password"), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
628 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
629 # file with no value just newline. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
630 with open(self.dirname + "/db_password", "w") as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
631 f.write("test\n") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
632 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
633 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
634 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
635 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
636 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
637 v = config['RDBMS_PASSWORD'] |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
638 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
639 self.assertEqual(v, "test") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
640 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
641 def testNullableSecret_with_value(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
642 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
643 self.munge_configini(mods=[ ("password = ", "test"), ]) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
644 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
645 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
646 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
647 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
648 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
649 v = config['RDBMS_PASSWORD'] |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
650 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
651 self.assertEqual(v, "test") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
652 |
|
7809
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
653 def testListSecret_for_jwt_invalid_secret(self): |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
654 """A jwt_secret is made of ',' separated strings. |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
655 If the first string is < 32 characters (like the default |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
656 value of disabled) then jwt is disabled and no harm done. |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
657 If any other secrets are <32 characters we raise a red flag |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
658 on startup to prevent them from being used. |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
659 """ |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
660 self.munge_configini(mods=[ ("jwt_secret = ", "disable, test"), ]) |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
661 |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
662 config = configuration.CoreConfig() |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
663 |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
664 with self.assertRaises(configuration.OptionValueError) as cm: |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
665 config.load(self.dirname) |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
666 |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
667 print(cm.exception.args) |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
668 self.assertEqual( |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
669 cm.exception.args[2], |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
670 "One or more secrets less then 32 characters in length\nfound: test") |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7584
diff
changeset
|
671 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
672 def testSetMailPassword_with_set_username(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
673 """ Set [mail] username and set the password. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
674 Should have both values set. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
675 """ |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
676 # SETUP: set mail username |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
677 self.munge_configini(mods=[ ("username = ", "foo"), |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
678 ("#password = ", "passwordfoo", |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
679 "password = ") ], |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
680 section="[mail]") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
681 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
682 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
683 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
684 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
685 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
686 self.assertEqual(config['MAIL_USERNAME'], 'foo') |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
687 self.assertEqual(config['MAIL_PASSWORD'], 'passwordfoo') |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
688 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
689 def testSetMailPassword_from_file(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
690 """ Set [mail] username and set the password. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
691 Should have both values set. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
692 """ |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
693 # SETUP: set mail username |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
694 self.munge_configini(mods=[ ("username = ", "foo"), |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
695 ("#password = ", "file://password", |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
696 "password = ") ], |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
697 section="[mail]") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
698 with open(self.dirname + "/password", "w") as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
699 f.write("passwordfoo\n") |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
700 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
701 config = configuration.CoreConfig() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
702 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
703 config.load(self.dirname) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
704 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
705 self.assertEqual(config['MAIL_USERNAME'], 'foo') |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
706 self.assertEqual(config['MAIL_PASSWORD'], 'passwordfoo') |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6560
diff
changeset
|
707 |
|
6367
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
708 @skip_xapian |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
709 def testInvalidIndexerLanguage_w_empty(self): |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
710 """ make sure we have a reasonable error message if |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
711 invalid indexer language is specified. This uses |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
712 default search path for indexers. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
713 """ |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
714 |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
715 # SETUP: set indexer_language value to an invalid value. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
716 self.munge_configini(mods=[ ("indexer = ", ""), |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
717 ("indexer_language = ", "NO_LANG") ]) |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
718 |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
719 config = configuration.CoreConfig() |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
720 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
721 with self.assertRaises(configuration.OptionValueError) as cm: |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
722 config.load(self.dirname) |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
723 |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
724 print(cm.exception) |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
725 # test repr. The type is right since it passed assertRaises. |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
726 self.assertIn("OptionValueError", repr(cm.exception)) |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
727 # look for failing language |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
728 self.assertIn("NO_LANG", cm.exception.args[1]) |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
729 # look for supported language |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
730 self.assertIn("english", cm.exception.args[2]) |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
731 |
|
6368
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
732 @include_no_xapian |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
733 def testInvalidIndexerLanguage_w_empty_no_xapian(self): |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
734 """ Test case for empty indexer if xapian really isn't installed |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
735 |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
736 This should behave like testInvalidIndexerLanguage_xapian_missing |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
737 but without all the sys.modules mangling. |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
738 """ |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
739 print("Testing when xapian is not installed") |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
740 |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
741 # SETUP: set indexer_language value to an invalid value. |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
742 self.munge_configini(mods=[ ("indexer = ", ""), |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
743 ("indexer_language = ", "NO_LANG") ]) |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
744 |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
745 config = configuration.CoreConfig() |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
746 |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
747 config.load(self.dirname) |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
748 |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
749 self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG') |
|
e3ed3ad9e795
issue2551125 Add indexer_lang test that runs if xapian not installed
John Rouillard <rouilj@ieee.org>
parents:
6367
diff
changeset
|
750 |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
751 def testInvalidIndexerLanguage_xapian_missing(self): |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
752 """Using default path for indexers, make import of xapian |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
753 fail and prevent exception from happening even though |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
754 the indexer_language would be invalid for xapian. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
755 """ |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
756 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
757 print("Testing xapian not loadable") |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
758 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
759 # SETUP: same as testInvalidIndexerLanguage_w_empty |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
760 self.munge_configini(mods=[ ("indexer = ", ""), |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
761 ("indexer_language = ", "NO_LANG") ]) |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
762 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
763 import sys |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
764 # Set module to Non to prevent xapian from loading |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
765 sys.modules['xapian'] = None |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
766 config.load(self.dirname) |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
767 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
768 # need to delete both to make python2 not error finding _xapian |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
769 del(sys.modules['xapian']) |
|
6371
5c1db5d4baed
Fix failing xapian test
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6368
diff
changeset
|
770 if 'xapian._xapian' in sys.modules: |
|
6367
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
771 del(sys.modules['xapian._xapian']) |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
772 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
773 self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG') |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
774 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
775 # do a reset here to test reset rather than wasting cycles |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
776 # to do setup in a different test |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
777 config.reset() |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
778 self.assertEqual(config['INDEXER_LANGUAGE'], 'english') |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
779 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
780 def testInvalidIndexerLanguage_w_native(self): |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
781 """indexer_language is invalid but indexer is not "" or xapian |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
782 Config load should succeed without exception. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
783 """ |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
784 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
785 print("Testing indexer = native") |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
786 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
787 self.munge_configini(mods = [ ("indexer = ", "native"), |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
788 ("indexer_language = ", "NO_LANG") ]) |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
789 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
790 config.load(self.dirname) |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
791 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
792 self.assertEqual(config['HTML_VERSION'], 'html4') |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
793 self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG') |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
794 |
|
6367
8a7de159d1a6
issue2551125 Make indexer_lang test work if xapian not installed.
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
795 @skip_xapian |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
796 def testInvalidIndexerLanguage_w_xapian(self): |
| 6358 | 797 """ Use explicit xapian indexer. Verify exception is |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
798 generated. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
799 """ |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
800 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
801 print("Testing explicit xapian") |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
802 |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
803 self.munge_configini(mods=[ ("indexer = ", "xapian"), |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
804 ("indexer_language = ", "NO_LANG") ]) |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
805 |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
806 with self.assertRaises(configuration.OptionValueError) as cm: |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
807 config.load(self.dirname) |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
808 # don't test exception content. Done in |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
809 # testInvalidIndexerLanguage_w_empty |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
810 # if exception not generated assertRaises |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
811 # will generate failure. |
|
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
812 |
|
6604
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
813 def testInvalidIndexerLanguage_w_native_fts(self): |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
814 """ Use explicit native-fts indexer. Verify exception is |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
815 generated. |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
816 """ |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
817 |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
818 self.munge_configini(mods=[ ("indexer = ", "native-fts"), |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
819 ("indexer_language = ", "NO_LANG") ]) |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
820 |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
821 with self.assertRaises(configuration.OptionValueError) as cm: |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
822 config.load(self.dirname) |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
823 |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
824 # test repr. The type is right since it passed assertRaises. |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
825 self.assertIn("OptionValueError", repr(cm.exception)) |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
826 # look for failing language |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
827 self.assertIn("NO_LANG", cm.exception.args[1]) |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
828 # look for supported language |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
829 self.assertIn("basque", cm.exception.args[2]) |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
830 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
831 @skip_redis |
|
7900
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
832 def testLoadSessionDbRedisCompatible(self): |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
833 """ run load to validate config """ |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
834 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
835 config = configuration.CoreConfig() |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
836 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
837 # compatible pair |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
838 config.RDBMS_BACKEND = "sqlite" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
839 config.SESSIONDB_BACKEND = "redis" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
840 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
841 config.validator(config.options) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
842 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
843 # compatible pair |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
844 config.RDBMS_BACKEND = "anydbm" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
845 config.SESSIONDB_BACKEND = "redis" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
846 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
847 config.validator(config.options) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
848 |
|
7900
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
849 @skip_redis |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
850 @skip_postgresql |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
851 def testLoadSessionDbRedisIncompatible(self): |
|
011941fcb598
test: skip test requiring postgresql backend if not present
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
852 """ run load to validate config """ |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
853 # incompatible pair |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
854 config.RDBMS_BACKEND = "postgresql" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
855 config.SESSIONDB_BACKEND = "redis" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
856 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
857 with self.assertRaises(configuration.OptionValueError) as cm: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
858 config.validator(config.options) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
859 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
860 self.assertIn(" db type: redis with postgresql", |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
861 cm.exception.__str__()) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
862 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
863 def testLoadSessionDb(self): |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
864 """ run load to validate config """ |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
865 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
866 config = configuration.CoreConfig() |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
867 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
868 # incompatible pair |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
869 config.RDBMS_BACKEND = "sqlite" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
870 config.SESSIONDB_BACKEND = "foo" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
871 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
872 with self.assertRaises(configuration.OptionValueError) as cm: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
873 config.validator(config.options) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
874 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
875 self.assertIn(" db type: foo with sqlite", |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
876 cm.exception.__str__()) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
877 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
878 # compatible pair |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
879 config.RDBMS_BACKEND = "sqlite" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
880 config.SESSIONDB_BACKEND = "" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
881 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
882 config.validator(config.options) # any exception will fail test |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
883 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
884 config.RDBMS_BACKEND = "sqlite" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
885 config.SESSIONDB_BACKEND = "anydbm" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
886 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
887 config.validator(config.options) # any exception will fail test |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
888 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
889 config.RDBMS_BACKEND = "anydbm" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
890 config.SESSIONDB_BACKEND = "redis" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
891 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
892 # make it looks like redis is not available |
|
6821
e0f0aed72097
Fix test if redis is not loaded
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
893 try: |
|
e0f0aed72097
Fix test if redis is not loaded
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
894 del(sys.modules['redis']) |
|
e0f0aed72097
Fix test if redis is not loaded
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
895 except KeyError: |
|
e0f0aed72097
Fix test if redis is not loaded
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
896 # redis is not available anyway. |
|
e0f0aed72097
Fix test if redis is not loaded
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
897 pass |
|
e0f0aed72097
Fix test if redis is not loaded
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
898 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
899 sys.modules['redis'] = None |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
900 with self.assertRaises(configuration.OptionValueError) as cm: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
901 config.validator(config.options) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
902 del(sys.modules['redis']) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
903 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
904 self.assertIn("Unable to load redis module", |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
905 cm.exception.__str__()) |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
906 |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
907 def testLoadConfig(self): |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
908 """ run load to validate config """ |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
909 |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
910 config = configuration.CoreConfig() |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
911 |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
912 config.load(self.dirname) |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
913 |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
914 # test various ways of accessing config data |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
915 with self.assertRaises(configuration.InvalidOptionError) as cm: |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
916 # using lower case name fails |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
917 c = config['indexer_language'] |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
918 print(cm.exception) |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
919 self.assertIn("indexer_language", repr(cm.exception)) |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
920 |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
921 # uppercase name passes as does tuple index for setting in main |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
922 self.assertEqual(config['HTML_VERSION'], 'html4') |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
923 self.assertEqual(config[('main', 'html_version')], 'html4') |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
924 |
|
6357
c985ed52ca2d
Add testcases for invalid indexer_language
John Rouillard <rouilj@ieee.org>
parents:
6356
diff
changeset
|
925 # uppercase name passes as does tuple index for setting in web |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
926 self.assertEqual(config['WEB_COOKIE_TAKES_PRECEDENCE'], 0) |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6331
diff
changeset
|
927 self.assertEqual(config[('web','cookie_takes_precedence')], 0) |
| 6358 | 928 |
| 929 | |
|
6359
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
930 def testLoadConfigNoConfig(self): |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
931 """ run load on a directory missing config.ini """ |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
932 |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
933 c = os.path.join(self.dirname, configuration.Config.INI_FILE) |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
934 if os.path.exists(c): |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
935 os.remove(c) |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
936 else: |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
937 self.assertFalse("setup failed missing config.ini") |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
938 |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
939 config = configuration.CoreConfig() |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
940 |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
941 with self.assertRaises(configuration.NoConfigError) as cm: |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
942 config.load(self.dirname) |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
943 |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
944 print(cm.exception) |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
945 self.assertEqual(cm.exception.args[0], self.dirname) |
|
2d42a308927b
Test trying to load missing config.ini file.
John Rouillard <rouilj@ieee.org>
parents:
6358
diff
changeset
|
946 |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
947 |
|
7966
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
948 def testXhtmlRaisesOptionError(self): |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
949 self.munge_configini(mods=[ ("html_version = ", "xhtml") ]) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
950 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
951 config = configuration.CoreConfig() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
952 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
953 # verify config is initalized to defaults |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
954 self.assertEqual(config['HTML_VERSION'], 'html4') |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
955 |
|
7966
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
956 |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
957 with self.assertRaises(configuration.OptionValueError) as cm: |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
958 # load config |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
959 config.load(self.dirname) |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
960 |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
961 print(cm.exception) |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
962 self.assertEqual(str(cm.exception), |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
963 "Invalid value for HTML_VERSION: 'xhtml'\n" |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
964 "Allowed values: html4") |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
965 |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
966 def testCopyConfig(self): |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
967 |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
968 self.munge_configini(mods=[ ("static_files = ", "html2") ]) |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
969 |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
970 config = configuration.CoreConfig() |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
971 |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
972 # verify config is initalized to defaults |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
973 self.assertEqual(config['STATIC_FILES'], None) |
|
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
974 |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
975 # load config |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
976 config.load(self.dirname) |
|
7966
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
977 self.assertEqual(config['STATIC_FILES'], ['_test_instance/html2']) |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
978 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
979 # copy config |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
980 config_copy = config.copy() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
981 |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
982 # this should work |
|
7966
1e38ca6fb16e
test: clean up test for deprecation of xhtml.
John Rouillard <rouilj@ieee.org>
parents:
7913
diff
changeset
|
983 self.assertEqual(config_copy['STATIC_FILES'], ['_test_instance/html2']) |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
984 |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
985 @skip_py2 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
986 def testConfigValueInterpolateError(self): |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
987 ''' error is not raised using ConfigParser under Python 2. |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
988 Unknown cause, so skip it if running python 2. |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
989 ''' |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
990 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
991 self.munge_configini(mods=[ ("admin_email = ", "a bare % is invalid") ]) |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
992 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
993 config = configuration.CoreConfig() |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
994 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
995 # load config generates: |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
996 ''' |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
997 E roundup.configuration.ParsingOptionError: Error in _test_instance/config.ini with section [main] at option admin_email: '%' must be followed by '%' or '(', found: '% is invalid' |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
998 ''' |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
999 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1000 with self.assertRaises(configuration.ParsingOptionError) as cm: |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1001 config.load(self.dirname) |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1002 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1003 print(cm.exception) |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1004 self.assertIn("'%' must be followed by '%' or '(', found: '% is invalid'", cm.exception.args[0]) |
|
7913
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
1005 self.assertIn(normpath("_test_instance/config.ini") + " with section [main] at option admin_email", cm.exception.args[0]) |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1006 |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6371
diff
changeset
|
1007 |
|
6560
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1008 from roundup.admin import AdminTool |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1009 from .test_admin import captured_output |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1010 |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1011 admin=AdminTool() |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1012 with captured_output() as (out, err): |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1013 sys.argv=['main', '-i', self.dirname, 'get', 'tile', 'issue1'] |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1014 ret = admin.main() |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1015 |
|
7913
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
1016 expected_err = ("Error in " + |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
1017 normpath("_test_instance/config.ini") + |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
1018 " with section [main] at option admin_email: '%' " |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
1019 "must be followed by '%' or '(', found: " |
|
6102ae426390
issue2551334 - get test suite running under windows
John Rouillard <rouilj@ieee.org>
parents:
7900
diff
changeset
|
1020 "'% is invalid'") |
|
6560
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1021 |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1022 self.assertEqual(ret, 1) |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1023 out = out.getvalue().strip() |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1024 self.assertEqual(out, expected_err) |
|
fdfe3b7387ea
Add test for config parse error by running AdminTool.
John Rouillard <rouilj@ieee.org>
parents:
6557
diff
changeset
|
1025 |
| 6358 | 1026 def testInvalidIndexerValue(self): |
| 1027 """ Mistype native indexer. Verify exception is | |
| 1028 generated. | |
| 1029 """ | |
| 1030 | |
| 1031 print("Testing indexer nati") | |
| 1032 | |
| 1033 self.munge_configini(mods=[ ("indexer = ", "nati") ]) | |
| 1034 | |
| 1035 with self.assertRaises(configuration.OptionValueError) as cm: | |
| 1036 config.load(self.dirname) | |
| 1037 | |
| 1038 self.assertIn("OptionValueError", repr(cm.exception)) | |
| 1039 # look for failing value | |
| 1040 self.assertEqual("nati", cm.exception.args[1]) | |
| 1041 # look for supported values | |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
1042 self.assertIn("'whoosh'", cm.exception.args[2]) |
| 6358 | 1043 |
|
6363
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
1044 # verify that args show up in string representaton |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
1045 string_rep = cm.exception.__str__() |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
1046 print(string_rep) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
1047 self.assertIn("nati", string_rep) |
|
08e209a7f22b
Use OptionValueError for indexer_language error, add configuration tests
John Rouillard <rouilj@ieee.org>
parents:
6359
diff
changeset
|
1048 self.assertIn("'whoosh'", string_rep) |
