On 6/6/18 5:37 AM, Deshani Geethika wrote:
> Hi Dave,
>
> I need some help in understanding an error related to test cases.
>
> I was trying to write a test case to check the '/neighborhood' route in
> Allura/allura/tests/functional/test_root.py as below.
>
> def test_neighborhood(self):
>> response = self.app.get('/neighborhood/')
>
>
> But I get the following error, when I run the above test case.
>
> Traceback (most recent call last):
>> File
>> "/home/deshani/env-allura/local/lib/python2.7/site-packages/nose/case.py",
>> line 197, in runTest
>> self.test(*self.arg)
>> File
>> "/home/deshani/src/allura/Allura/allura/tests/functional/test_root.py",
>> line 58, in test_neighborhood
>> response = self.app.get('/neighborhood/')
>> File "/home/deshani/src/allura/AlluraTest/alluratest/validation.py",
>> line 322, in get
>> resp = super(ValidatingTestApp, self).get(*args, **kw)
>> File "/home/deshani/src/allura/AlluraTest/alluratest/validation.py",
>> line 269, in get
>> return super(PostParamCheckingTestApp, self).get(*args, **kwargs)
>> File
>> "/home/deshani/env-allura/local/lib/python2.7/site-packages/webtest/app.py",
>> line 756, in get
>> expect_errors=expect_errors)
>> File
>> "/home/deshani/env-allura/local/lib/python2.7/site-packages/webtest/app.py",
>> line 1118, in do_request
>> self._check_status(status, res)
>> File
>> "/home/deshani/env-allura/local/lib/python2.7/site-packages/webtest/app.py",
>> line 1154, in _check_status
>> res)
>> AppError: Bad response: 404 Not Found (not 200 OK or 3xx redirect for
>> http://localhost/neighborhood/)
>
>
> Can you help me to understand why this error comes up?
>
> Regards!
Wow, this was a tricky one! I was stumped about this for a while too. Its
happening because of some helper code for tests, that is not very obvious. In
Allura/allura/controllers/basetest_project_root.py a modified root controller is
used for tests, which makes some project & tool testing easier. This controller
is used because test.ini specifies "override_root=basetest_project_root"
And then in this controller on line 71 there is a list of root controller
attributes that is hardcoded. So you will have to add 'neighborhood' and
'dashboard' to that list.
I would also recommend adding a comment on the real RootController mentioning
the BasetestProjectRootController so that anyone else in the future who adds a
root url knows that they have to update the other place too.
--
Dave Brondsema : [email protected]
http://www.brondsema.net : personal
http://www.splike.com : programming
<><