annotate test/test_config.py @ 5548:fea11d05110e

Avoid errors from selecting "no selection" on multilink (issue2550722). As discussed in issue 2550722 there are various cases where selecting "no selection" on a multilink can result in inappropriate errors from Roundup: * If selecting "no selection" produces a null edit (a value was set in the multilink in an edit with an error, then removed again, along with all other changes, in the next form submission), so the page is rendered from the form contents including the "-<id>" value for "no selection" for the multilink. * If creating an item with a nonempty value for a multilink has an error, and the resubmission changes that multilink to "no selection" (and this in turn has subcases, according to whether the creation then succeeds or fails on the resubmission, which need fixes in different places in the Roundup code). All of these cases have in common that it is expected and OK to have a "-<id>" value for a submission for a multilink when <id> is not set in that multilink in the database (because the original attempt to set <id> in that multilink had an error), so the hyperdb.py logic to give an error in that case is thus removed. In the subcase of the second case where the resubmission with "no selection" has an error, the templating code tries to produce a menu entry for the "-<id>" multilink value, which also results in an error, hence the templating.py change to ignore such values in the list for a multilink.
author Joseph Myers <jsm@polyomino.org.uk>
date Thu, 27 Sep 2018 11:33:01 +0000
parents dd642afb4440
children f91da208f26b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5126
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1 #
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
4 # under the same terms as Python, so long as this copyright message and
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
5 # disclaimer are retained in their original form.
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
6 #
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
10 # POSSIBILITY OF SUCH DAMAGE.
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
11 #
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
17
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
18 import unittest
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
19 import logging
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
20
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
21 import pytest
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
22 from roundup import configuration
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
23
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
24 config = configuration.CoreConfig()
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
25 config.DATABASE = "db"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
26 config.RDBMS_NAME = "rounduptest"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
27 config.RDBMS_HOST = "localhost"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
28 config.RDBMS_USER = "rounduptest"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
29 config.RDBMS_PASSWORD = "rounduptest"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
30 config.RDBMS_TEMPLATE = "template0"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
31 # these TRACKER_WEB and MAIL_DOMAIN values are used in mailgw tests
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
32 config.MAIL_DOMAIN = "your.tracker.email.domain.example"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
33 config.TRACKER_WEB = "http://tracker.example/cgi-bin/roundup.cgi/bugs/"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
34 # uncomment the following to have excessive debug output from test cases
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
35 # FIXME: tracker logging level should be increased by -v arguments
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
36 # to 'run_tests.py' script
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
37 #config.LOGGING_FILENAME = "/tmp/logfile"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
38 #config.LOGGING_LEVEL = "DEBUG"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
39 config.init_logging()
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
40 config.options['FOO'] = "value"
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
41
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
42 class ConfigTest(unittest.TestCase):
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
43
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
44 def test_badConfigKeyword(self):
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
45 """Run configure tests looking for invalid option name
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
46 """
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
47 self.assertRaises(configuration.InvalidOptionError, config._get_option, "BadOptionName")
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
48
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
49 def test_validConfigKeyword(self):
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
50 """Run configure tests looking for invalid option name
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
51 """
dd642afb4440 starter tests for roundup/configuration.py
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
52 self.assertEquals(config._get_option("FOO"), "value")

Roundup Issue Tracker: http://roundup-tracker.org/