Google App Engine set up a user when using testbed

后端 未结 2 1259
既然无缘
既然无缘 2020-12-17 16:20

I\'m using the GAE testbed service and when I run users.get_current_user() I get None i.e.

>>> import sys
>>> sys         


        
2条回答
  •  生来不讨喜
    2020-12-17 17:06

    To simulate a sign in of an admin user, you can call anywhere in your test function:

    self.testbed.setup_env(
        USER_EMAIL = 'test@example.com',
        USER_ID = '123',
        USER_IS_ADMIN = '1',
        overwrite = True)
    

    Note that you need to use the overwrite=True parameter!

提交回复
热议问题