在Google App Engine和webtest中测试注销方案

时间:2013-10-14 17:07:56

标签: python google-app-engine testing webtest

我很难做出这个简单的测试工作:

class TestNotlogedUser(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.testapp = webtest.TestApp(application)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_user_stub()

    def tearDown(self):
        self.testbed.deactivate()

    def test_user_profile_301(self):
        resp = self.testapp.get('/profile/logout/')
        resp.click(linkid='logout') # user logs out
        resp = self.testapp.get('/profile/')
        self.assertEquals(resp.status_int, 301, resp) # user is redirected to a login page

但它引发了这个错误:

AppError: Bad response: 404 NOT FOUND (not 200 OK or 3xx redirect for http://localhost/accounts/Logout?continue=http%3A//testbed.example.com/)

此部分导致问题continue=http%3A//testbed.example.com,我想将主机更改为localhost:8080

根据github源代码,您将extra_environ传递给构造函数:

:param extra_environ:
        A dictionary of values that should go
        into the environment for each request. These can provide a
        communication channel with the application.

我的问题是有可能将testbed.example.com更改为此参数的值,我仍然在源代码,但似乎没有关于此extra_environ的键名称的文档字典。

0 个答案:

没有答案