Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to simulate some GAE server error?

Are there ways to test my error_handlers setup in the app.yaml file, especially the error code over_quota?

like image 753
Falcon Avatar asked Feb 01 '12 02:02

Falcon


1 Answers

Testing error_handlers

dev_appserver.py is the application that is parsing your app.yaml and serving these error files. This means that you're best bet is probably a straight up acceptance test where you bring up dev_appserver.py and try hitting it localhost:8080 with GETs and PUTs that would trigger the various errors you're expecting.

So, if /foo returns a 404, you could do the following with Python requests:

>>> def test_foo():
>>>   response = requests.get('/foo')
>>>   assert response.status_code == 404

Testing Over Quota Error

In this specific case it sounds like you're trying to explicitly raise the over_quota error. This link mentions that the exception you're looking for is apiproxy_errors.OverQuotaError.

I'm not sure what your test code is, but have you tried explicitly raising this error, with straight up raise?

I was able to run the following code after bootstrapping my apiproxy_stub_map, setting up my path, etc.:

from google.appengine.runtime import apiproxy_errors

def test_foo():
  raise apiproxy_errors.OverQuotaError
like image 62
mvanveen Avatar answered Nov 19 '22 14:11

mvanveen