I have a unit test that tests if an api point is unaccessible if not authenticated like this:
def test_endpoint_get_unauth(self):
r = self.get('/api/endpoint/1')
self.assertStatusCode(r, 401)
The test passes, but nosetests/unittest still shows me an error that an exception was raised saying "not authorized." Is there anyway to stop this?
Full log:
ERROR in views [/myenv/lib/python2.7/site-packages/flask_restless/views.py:115]:
Not Authorized
--------------------------------------------------------------------------------
Traceback (most recent call last):
File "/myapp/myenv/lib/python2.7/site-packages/flask_restless/views.py", line 113, in decorator
return func(*args, **kw)
File "/myapp/myenv/lib/python2.7/site-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/myapp/myenv/lib/python2.7/site-packages/flask/views.py", line 149, in dispatch_request
return meth(*args, **kwargs)
File "/myapp/myenv/lib/python2.7/site-packages/flask_restless/views.py", line 989, in get
preprocessor(instance_id=instid)
File "/myapp/app/api/api.py", line 16, in check_auth
raise ProcessingException(message='Not Authorized', status_code=401)
ProcessingException
................
----------------------------------------------------------------------
Ran 16 tests in 15.788s
OK