[fix] for test
This commit is contained in:
parent
73b66137af
commit
79f51648a1
3 changed files with 15 additions and 7 deletions
|
|
@ -8,9 +8,8 @@ import requests
|
|||
from frappe.model.delete_doc import delete_doc
|
||||
from frappe.utils.data import today, add_to_date
|
||||
from frappe import _dict
|
||||
from frappe.limits import SiteExpiredError, update_limits, clear_limit
|
||||
from frappe.limits import update_limits, clear_limit
|
||||
from frappe.utils import get_url
|
||||
from frappe.installer import update_site_config
|
||||
from frappe.core.doctype.user.user import MaxUsersReachedError
|
||||
|
||||
test_records = frappe.get_test_records('User')
|
||||
|
|
@ -145,6 +144,7 @@ class TestUser(unittest.TestCase):
|
|||
clear_limit('users')
|
||||
|
||||
# def test_deny_multiple_sessions(self):
|
||||
# from frappe.installer import update_site_config
|
||||
# clear_limit('users')
|
||||
#
|
||||
# # allow one session
|
||||
|
|
@ -179,13 +179,18 @@ class TestUser(unittest.TestCase):
|
|||
# test_request(conn1)
|
||||
|
||||
def test_site_expiry(self):
|
||||
user = frappe.get_doc('User', 'test@example.com')
|
||||
user.enabled = 1
|
||||
user.new_password = 'testpassword'
|
||||
user.save()
|
||||
|
||||
update_limits({'expiry': add_to_date(today(), days=-1)})
|
||||
frappe.local.conf = _dict(frappe.get_site_config())
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
res = requests.post(get_url(), params={'cmd': 'login', 'usr': 'test@example.com', 'pwd': 'testpassword',
|
||||
'device': 'desktop'})
|
||||
res = requests.post(get_url(), params={'cmd': 'login', 'usr':
|
||||
'test@example.com', 'pwd': 'testpassword', 'device': 'desktop'})
|
||||
|
||||
# While site is expired status code returned is 417 Failed Expectation
|
||||
self.assertEqual(res.status_code, 417)
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ def reset_enabled_scheduler_events(login_manager):
|
|||
frappe.db.set_global('enabled_scheduler_events', None)
|
||||
except MySQLdb.OperationalError, e:
|
||||
if e.args[0]==1205:
|
||||
frappe.get_logger().error("Error in reset_enabled_scheduler_events")
|
||||
frappe.log_error(frappe.get_traceback(), "Error in reset_enabled_scheduler_events")
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -244,5 +244,8 @@ def get_doctype_from_path(path):
|
|||
return None, None
|
||||
|
||||
def add_csrf_token(data):
|
||||
return data.replace("<!-- csrf_token -->", '<script>frappe.csrf_token = "{0}";</script>'.format(
|
||||
frappe.local.session.data.csrf_token))
|
||||
if frappe.local.session:
|
||||
return data.replace("<!-- csrf_token -->", '<script>frappe.csrf_token = "{0}";</script>'.format(
|
||||
frappe.local.session.data.csrf_token))
|
||||
else:
|
||||
return data
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue