add support for testing paths are not redirected
Add support for tests that ensure no existing rule redirects by having the test assume a response code of 200. Change-Id: I2aa1ada7e85c5e8066fdae634a4cf38b64ec821b Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
7200a0657f
commit
7e37a20c79
@ -37,6 +37,9 @@ parts: the input path, the expected HTTP response code, and the
|
||||
/no/rule 301 /should/fail
|
||||
/nova/latest/man/nova-cert.html 410
|
||||
|
||||
# verify that this path is not redirected
|
||||
/pike/index.html 200
|
||||
|
||||
The output from ``whereto`` includes a report of any tests that do not
|
||||
match, including if no rules match and if multiple rules match. For
|
||||
example:
|
||||
|
@ -78,7 +78,11 @@ def process_tests(ruleset, tests, max_hops):
|
||||
for test in tests:
|
||||
matches = _find_matches(ruleset, test)
|
||||
if not matches:
|
||||
# No rules matched at all.
|
||||
# No rules matched at all. If the test was expecting
|
||||
# that don't record it as a failure.
|
||||
if test[2] == '200':
|
||||
used.add(test[0])
|
||||
else:
|
||||
mismatches.append((test, []))
|
||||
else:
|
||||
code, expected = test[-2:]
|
||||
|
@ -173,3 +173,34 @@ class TestProcessTests(base.TestCase):
|
||||
{1, 2, 3},
|
||||
)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_200_test(self):
|
||||
self.ruleset.add(
|
||||
1,
|
||||
'redirect', '301', '/path', '/new/path',
|
||||
)
|
||||
actual = app.process_tests(
|
||||
self.ruleset,
|
||||
[(1, '/another/path', '200', None)],
|
||||
0,
|
||||
)
|
||||
expected = ([], [], [], set())
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_200_test_rule_mismatch(self):
|
||||
self.ruleset.add(
|
||||
1,
|
||||
'redirect', '301', '/path', '/new/path',
|
||||
)
|
||||
actual = app.process_tests(
|
||||
self.ruleset,
|
||||
[(1, '/path', '200', None)],
|
||||
0,
|
||||
)
|
||||
expected = (
|
||||
[((1, '/path', '200', None), [(1, '301', '/new/path')])],
|
||||
[],
|
||||
[],
|
||||
{1},
|
||||
)
|
||||
self.assertEqual(expected, actual)
|
||||
|
@ -114,3 +114,12 @@ class TestParseTests(base.TestCase):
|
||||
[(2, ['/releases', '410', None])],
|
||||
self.parse(input),
|
||||
)
|
||||
|
||||
def test_200_rule(self):
|
||||
input = u"""
|
||||
/releases 200
|
||||
"""
|
||||
self.assertEqual(
|
||||
[(2, ['/releases', '200', None])],
|
||||
self.parse(input),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user