'Ensure otp is confirmed'

def test_confirm_otp_token(self):

    authenticate_for_2factor(self.user)
    tmp_id = frappe.local.response[u'tmp_id']
    otp = u'wrongotp'
    with self.assertRaises(frappe.AuthenticationError):
        confirm_otp_token(self.login_manager, otp=otp, tmp_id=tmp_id)
    otp = get_otp(self.user)
    self.assertTrue(confirm_otp_token(self.login_manager, otp=otp, tmp_id=tmp_id))
    if frappe.flags.tests_verbose:
        print u'Sleeping    for    30secs    to    confirm    token    expires..'
    time.sleep(30)
    with self.assertRaises(frappe.AuthenticationError):
        confirm_otp_token(self.login_manager, otp=otp, tmp_id=tmp_id)
