def setUp(self): self.testbed = testbed.Testbed() self.testbed.activate() set_current_session(Session()) self.testbed.init_mail_stub() self.testbed.init_datastore_v3_stub() self.testbed.init_memcache_stub() self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME) app = webapp2.WSGIApplication([ Route('/<api:api>/v1/Lists/', handler=ListHandler), Route('/<api:api>/v1/lists/', handler=ListHandler), Route('/<api:api>/v1/Lists', handler=ListHandler), Route('/<api:api>/v1/lists', handler=ListHandler), Route('/<api:api>/v1/Lists/<list_id>', handler=ListHandler), Route('/<api:api>/v1/Lists/<list_id>', handler=ListHandler), Route('/<api:api>/v1/Lists/<list_id>/<item_id>', handler=ListHandler, methods='DELETE'), Route('/<api:api>/v1/lists/<list_id>/<item_id>', handler=ListHandler, methods='DELETE'), Route('/Lists/', handler=ListHandler), Route('/lists/', handler=ListHandler), Route('/Lists', handler=ListHandler), Route('/lists', handler=ListHandler), Route('/Lists/<list_id>', handler=ListHandler), Route('/lists/<list_id>', handler=ListHandler) ], debug=True) UserUtil.decorate_app(app) self.testapp = webtest.TestApp(app)
def __login__(self): email = '*****@*****.**' password = '******' # 1. Register client response = UserUtil.register_user(self.testapp, email, password) self.assertEqual(response.status_int, constants.STATUS_OK, 'Register failed with correct credentials: ' + str(response.status_int)) # 2. Verify response = UserUtil.verify_user(self.testapp, self.mail_stub, email) self.assertEqual(response.status_int, constants.STATUS_OK, 'Verification failed: ' + str(response.status_int))
def __logout__(self): response = UserUtil.logout(self.testapp) self.assertEqual(response.status_int, constants.STATUS_OK, 'Logout failed: ' + str(response.status_int))