def test_success(self, LoginClassMock):
        external_user, main_user, pending_key = self.setup_call_stat(LoginClassMock)

        cmd = facade.login_checking_email(str(pending_key.id()), 'ticket', 'response').execute()

        self.assertTrue(cmd.checked)
        self.assertEqual(main_user, MainUserSearch(external_user).execute().result)
    def test_not_creating_link_if_there_is_one_already(self, LoginClassMock):
        external_user, main_user, pending_key = self.setup_call_stat(LoginClassMock)
        linked_main_user = mommy.save_one(MainUser)
        ExternalToMainUser(origin=external_user.key, destination=linked_main_user).put()
        cmd = facade.login_checking_email(str(pending_key.id()), 'ticket', 'response').execute()

        self.assertFalse(cmd.checked)
        self.assertEqual(1, len(ExternalToMainUser.query().fetch()))
def index(_handler, _resp, pending_id, ticket):
    facade.login_checking_email(pending_id, ticket, _resp).execute()
    _handler.redirect('/')