【python – Google App Engine:Webtest模拟登录用户和管理员】教程文章相关的互联网学习教程文章

python – 如何使用django_webtest的基本身份验证来访问Django REST框架?【代码】

我在将数据发布到我的测试中使用Django REST框架的一些视图时遇到了麻烦.我正在使用django_webtest来测试我的用户API.我遇到了以下代码的问题:class UserApiTest(WebTest):def setUp(self):AdminFactory()def test_accessing_user_list_shows_one_user(self):user_list = self.app.get('/quickstart/users/', user='admin')assert_that(user_list.json, has_entry('count', 1))def test_posting_new_user_returns_url_for_user_de...

python webtest端口配置?【代码】

我试图用webtest编写一些测试来测试我的python GAE应用程序.我遇到的问题是应用程序正在侦听端口8080但我无法配置webtest来命中该端口. 例如,我想使用app.get(‘/ getreport’)来达到http://localhost:8080/getreport.显然,它只会遇到http:// localhost / getreport. 有没有办法设置webtest来击中特定端口?解决方法:在config,我引用,portRequired? No, defaults is “80” Defines the port number to use forexecuting requests...

python – Google App Engine:Webtest模拟登录用户和管理员【代码】

从webtest文档中我了解到:The best way to simulateauthentication is if your applicationlooks in environ[‘REMOTE_USER’] to seeif someone is authenticated. Then youcan simply set that value, like:app.get('/secret', extra_environ=dict(REMOTE_USER='bob'))我试图在Google App引擎环境中做同样的事情.我想模拟登录用户和管理员用户. 如果可能,我必须在extra_environ中设置哪些字典值来完成此操作?解决方法:设置用户...