内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
在编写的Django测试中,如何获得当前登录用户?
例如,这就是我想要写的测试:
def test_author_set_once(self): self.client.login(username='Adam', password='password') #create an object and test the author is adam self.client.login(username='Barry', password='password') #modify the first object and test that the author has not changed
所以我能这样
self.assertEqual(object.author, self.client.user)
(但我不能)
我现在的编码方式是这样的:
self.client.login(username='Adam', password='password') self.user = User.objects.get(username='Adam') #create an object self.assertEqual(object.author, self.user)
测试客户端与请求无关。它本身并不包含用户登录的信息。
可以然后通过以下方式获取用户:
response.request.user
Django的最新版本可以使用:
response.context["user"]
目前呼叫中心只有API文档,需要用户自己开发。如果用户需要saas系统的呼叫中心可以使用智能外呼机器人:https://cloud.tencent.com/product/ccsr
你有没有调整观众端表现,即通过对 LivePushConfig 中的homeOrientation设置项进行配置,它控制的是观众端看到的视频宽高比是16:9还是6:19,调整后的结果可以用播放器查看以确认是否符合预期。
控制台使用的是新的接口,批量创建子网,https://cloud.tencent.com/document/product/215/31960,可以指定路由表。terraform开发的时候是基于api2.0开发的,还没有这个接口,因此暂时无法使用