test: Fix test dependencies
This commit is contained in:
parent
e33a09f4e6
commit
57166b9964
9 changed files with 16 additions and 40 deletions
|
|
@ -5,7 +5,8 @@ from __future__ import unicode_literals
|
|||
|
||||
import frappe
|
||||
import unittest
|
||||
from frappe.exceptions import ValidationError
|
||||
|
||||
test_dependencies = ['Contact', 'Salutation']
|
||||
|
||||
class TestContact(unittest.TestCase):
|
||||
|
||||
|
|
@ -52,4 +53,4 @@ def create_contact(name, salutation, emails=None, phones=None, save=True):
|
|||
if save:
|
||||
doc.insert()
|
||||
|
||||
return doc
|
||||
return doc
|
||||
|
|
|
|||
|
|
@ -90,4 +90,5 @@ class TestActivityLog(unittest.TestCase):
|
|||
def update_system_settings(args):
|
||||
doc = frappe.get_doc('System Settings')
|
||||
doc.update(args)
|
||||
doc.flags.ignore_mandatory = 1
|
||||
doc.save()
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ class TestSameContent(unittest.TestCase):
|
|||
|
||||
class TestFile(unittest.TestCase):
|
||||
def setUp(self):
|
||||
frappe.set_user('Administrator')
|
||||
self.delete_test_data()
|
||||
self.upload_file()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ from __future__ import unicode_literals
|
|||
import frappe
|
||||
import unittest
|
||||
|
||||
test_dependencies = ['Role']
|
||||
|
||||
class TestRoleProfile(unittest.TestCase):
|
||||
def test_make_new_role_profile(self):
|
||||
new_role_profile = frappe.get_doc(dict(doctype='Role Profile', role_profile='Test 1')).insert()
|
||||
|
|
@ -21,4 +23,4 @@ class TestRoleProfile(unittest.TestCase):
|
|||
# clear roles
|
||||
new_role_profile.roles = []
|
||||
new_role_profile.save()
|
||||
self.assertEqual(new_role_profile.roles, [])
|
||||
self.assertEqual(new_role_profile.roles, [])
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import frappe
|
|||
def update_system_settings(args):
|
||||
doc = frappe.get_doc('System Settings')
|
||||
doc.update(args)
|
||||
doc.flags.ignore_mandatory = 1
|
||||
doc.save()
|
||||
|
||||
def get_system_setting(key):
|
||||
return frappe.db.get_single_value("System Settings", key)
|
||||
|
||||
global_test_dependencies = ['User']
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ from __future__ import unicode_literals
|
|||
import unittest, frappe, re, email
|
||||
from six import PY3
|
||||
|
||||
from frappe.test_runner import make_test_records
|
||||
|
||||
make_test_records("User")
|
||||
make_test_records("Email Account")
|
||||
|
||||
test_dependencies = ['Email Account']
|
||||
|
||||
class TestEmail(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ class TestFmtDatetime(unittest.TestCase):
|
|||
frappe.db.set_default("time_format", self.pre_test_time_format)
|
||||
frappe.local.user_date_format = None
|
||||
frappe.local.user_time_format = None
|
||||
frappe.db.rollback()
|
||||
|
||||
# Test utility functions
|
||||
|
||||
|
|
@ -97,28 +98,12 @@ class TestFmtDatetime(unittest.TestCase):
|
|||
self.assertEqual(formatdate(test_date), valid_fmt)
|
||||
|
||||
# Test time formatters
|
||||
|
||||
def test_format_time_forced(self):
|
||||
# Test with forced time formats
|
||||
self.assertEqual(
|
||||
format_time(test_time, 'ss:mm:HH'),
|
||||
test_date_obj.strftime('%S:%M:%H'))
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_format_time_forced_broken_locale(self):
|
||||
# Test with forced time formats
|
||||
# Currently format_time defaults to HH:mm:ss if the locale is
|
||||
# broken, so this is an expected failure.
|
||||
lang = frappe.local.lang
|
||||
try:
|
||||
# Force fallback from Babel
|
||||
frappe.local.lang = 'FAKE'
|
||||
self.assertEqual(
|
||||
format_time(test_time, 'ss:mm:HH'),
|
||||
test_date_obj.strftime('%S:%M:%H'))
|
||||
finally:
|
||||
frappe.local.lang = lang
|
||||
|
||||
def test_format_time(self):
|
||||
# Test format_time with various default time formats set
|
||||
for fmt, valid_fmt in test_time_formats.items():
|
||||
|
|
@ -135,21 +120,6 @@ class TestFmtDatetime(unittest.TestCase):
|
|||
format_datetime(test_datetime, 'dd-yyyy-MM ss:mm:HH'),
|
||||
test_date_obj.strftime('%d-%Y-%m %S:%M:%H'))
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_format_datetime_forced_broken_locale(self):
|
||||
# Test with forced datetime formats
|
||||
# Currently format_datetime defaults to yyyy-MM-dd HH:mm:ss
|
||||
# if the locale is broken, so this is an expected failure.
|
||||
lang = frappe.local.lang
|
||||
# Force fallback from Babel
|
||||
try:
|
||||
frappe.local.lang = 'FAKE'
|
||||
self.assertEqual(
|
||||
format_datetime(test_datetime, 'dd-yyyy-MM ss:mm:HH'),
|
||||
test_date_obj.strftime('%d-%Y-%m %S:%M:%H'))
|
||||
finally:
|
||||
frappe.local.lang = lang
|
||||
|
||||
def test_format_datetime(self):
|
||||
# Test formatdate with various default date formats set
|
||||
for date_fmt, valid_date in test_date_formats.items():
|
||||
|
|
|
|||
|
|
@ -208,12 +208,14 @@ def enable_2fa(bypass_two_factor_auth=0, bypass_restrict_ip_check=0):
|
|||
system_settings.bypass_2fa_for_retricted_ip_users = cint(bypass_two_factor_auth)
|
||||
system_settings.bypass_restrict_ip_check_if_2fa_enabled = cint(bypass_restrict_ip_check)
|
||||
system_settings.two_factor_method = 'OTP App'
|
||||
system_settings.flags.ignore_mandatory = True
|
||||
system_settings.save(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
|
||||
def disable_2fa():
|
||||
system_settings = frappe.get_doc('System Settings')
|
||||
system_settings.enable_two_factor_auth = 0
|
||||
system_settings.flags.ignore_mandatory = True
|
||||
system_settings.save(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import unittest, json
|
|||
from frappe.website.render import build_page
|
||||
from frappe.website.doctype.web_form.web_form import accept
|
||||
|
||||
test_records = frappe.get_test_records('Web Form')
|
||||
test_dependencies = ['Web Form']
|
||||
|
||||
class TestWebForm(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue