refactor: unit vs integration treewide (#27992)

* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
This commit is contained in:
David Arnold 2024-10-06 11:43:36 +02:00 committed by GitHub
parent cfb04b93e1
commit c114e5fae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
261 changed files with 2586 additions and 960 deletions

View file

@ -2,13 +2,22 @@
# License: MIT. See LICENSE
import frappe
from frappe.test_runner import make_test_records
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import make_test_records
TEST_DOCTYPE = "Assignment Test"
class TestAutoAssign(FrappeTestCase):
class UnitTestAssignmentRule(UnitTestCase):
"""
Unit tests for AssignmentRule.
Use this class for testing individual functions and methods.
"""
pass
class TestAutoAssign(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

View file

@ -9,7 +9,7 @@ from frappe.automation.doctype.auto_repeat.auto_repeat import (
week_map,
)
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import add_days, add_months, getdate, today
if TYPE_CHECKING:
@ -32,7 +32,16 @@ def add_custom_fields() -> "CustomField":
)
class TestAutoRepeat(FrappeTestCase):
class UnitTestAutoRepeat(UnitTestCase):
"""
Unit tests for AutoRepeat.
Use this class for testing individual functions and methods.
"""
pass
class TestAutoRepeat(IntegrationTestCase):
@classmethod
def setUpClass(cls):
cls.custom_field = add_custom_fields()

View file

@ -1,8 +1,17 @@
# Copyright (c) 2019, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestMilestone(FrappeTestCase):
class UnitTestMilestone(UnitTestCase):
"""
Unit tests for Milestone.
Use this class for testing individual functions and methods.
"""
pass
class TestMilestone(IntegrationTestCase):
pass

View file

@ -2,10 +2,19 @@
# License: MIT. See LICENSE
import frappe
import frappe.cache_manager
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestMilestoneTracker(FrappeTestCase):
class UnitTestMilestoneTracker(UnitTestCase):
"""
Unit tests for MilestoneTracker.
Use this class for testing individual functions and methods.
"""
pass
class TestMilestoneTracker(IntegrationTestCase):
def test_milestone(self):
frappe.db.delete("Milestone Tracker")

View file

@ -4,11 +4,20 @@
import frappe
from frappe.automation.doctype.reminder.reminder import create_new_reminder, send_reminders
from frappe.desk.doctype.notification_log.notification_log import get_notification_logs
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import add_to_date, now_datetime
class TestReminder(FrappeTestCase):
class UnitTestReminder(UnitTestCase):
"""
Unit tests for Reminder.
Use this class for testing individual functions and methods.
"""
pass
class TestReminder(IntegrationTestCase):
def test_reminder(self):
description = "TEST_REMINDER"

View file

@ -4,10 +4,19 @@ from functools import partial
import frappe
from frappe.contacts.doctype.address.address import address_query, get_address_display
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestAddress(FrappeTestCase):
class UnitTestAddress(UnitTestCase):
"""
Unit tests for Address.
Use this class for testing individual functions and methods.
"""
pass
class TestAddress(IntegrationTestCase):
def test_template_works(self):
if not frappe.db.exists("Address Template", "India"):
frappe.get_doc({"doctype": "Address Template", "country": "India", "is_default": 1}).insert()

View file

@ -2,11 +2,20 @@
# License: MIT. See LICENSE
import frappe
from frappe.contacts.doctype.address_template.address_template import get_default_address_template
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils.jinja import validate_template
class TestAddressTemplate(FrappeTestCase):
class UnitTestAddressTemplate(UnitTestCase):
"""
Unit tests for AddressTemplate.
Use this class for testing individual functions and methods.
"""
pass
class TestAddressTemplate(IntegrationTestCase):
def setUp(self) -> None:
frappe.db.delete("Address Template", {"country": "India"})
frappe.db.delete("Address Template", {"country": "Brazil"})

View file

@ -3,12 +3,21 @@
import frappe
from frappe.contacts.doctype.contact.contact import get_full_name
from frappe.email import get_contact_list
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_dependencies = ["Contact", "Salutation"]
class TestContact(FrappeTestCase):
class UnitTestContact(UnitTestCase):
"""
Unit tests for Contact.
Use this class for testing individual functions and methods.
"""
pass
class TestContact(IntegrationTestCase):
def test_check_default_email(self):
emails = [
{"email": "test1@example.com", "is_primary": 0},

View file

@ -1,7 +1,16 @@
# Copyright (c) 2017, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestGender(FrappeTestCase):
class UnitTestGender(UnitTestCase):
"""
Unit tests for Gender.
Use this class for testing individual functions and methods.
"""
pass
class TestGender(IntegrationTestCase):
pass

View file

@ -1,7 +1,16 @@
# Copyright (c) 2017, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestSalutation(FrappeTestCase):
class UnitTestSalutation(UnitTestCase):
"""
Unit tests for Salutation.
Use this class for testing individual functions and methods.
"""
pass
class TestSalutation(IntegrationTestCase):
pass

View file

@ -1,7 +1,7 @@
import frappe
import frappe.defaults
from frappe.contacts.report.addresses_and_contacts.addresses_and_contacts import get_data
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
def get_custom_linked_doctype():
@ -85,7 +85,7 @@ def create_linked_contact(link_list, address):
frappe.flags.test_contact_created = True
class TestAddressesAndContacts(FrappeTestCase):
class TestAddressesAndContacts(IntegrationTestCase):
def test_get_data(self):
linked_docs = [get_custom_doc_for_address_and_contacts()]
links_list = [item.name for item in linked_docs]

View file

@ -14,11 +14,20 @@ from frappe.core.doctype.data_import.data_import import export_csv
from frappe.core.doctype.user.user import generate_keys
# imports - standard imports
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import cstr, get_site_url
class TestAccessLog(FrappeTestCase):
class UnitTestAccessLog(UnitTestCase):
"""
Unit tests for AccessLog.
Use this class for testing individual functions and methods.
"""
pass
class TestAccessLog(IntegrationTestCase):
def setUp(self):
# generate keys for current user to send requests for the following tests
generate_keys(frappe.session.user)

View file

@ -4,10 +4,19 @@ import time
import frappe
from frappe.auth import CookieManager, LoginManager
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestActivityLog(FrappeTestCase):
class UnitTestActivityLog(UnitTestCase):
"""
Unit tests for ActivityLog.
Use this class for testing individual functions and methods.
"""
pass
class TestActivityLog(IntegrationTestCase):
def setUp(self) -> None:
frappe.set_user("Administrator")

View file

@ -2,11 +2,20 @@
# See license.txt
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import today
class TestAuditTrail(FrappeTestCase):
class UnitTestAuditTrail(UnitTestCase):
"""
Unit tests for AuditTrail.
Use this class for testing individual functions and methods.
"""
pass
class TestAuditTrail(IntegrationTestCase):
def setUp(self):
self.child_doctype = create_custom_child_doctype()
self.custom_doctype = create_custom_doctype()

View file

@ -4,12 +4,21 @@ import json
import frappe
from frappe.templates.includes.comments.comments import add_comment
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.test_model_utils import set_user
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.website.doctype.blog_post.test_blog_post import make_test_blog
class TestComment(FrappeTestCase):
class UnitTestComment(UnitTestCase):
"""
Unit tests for Comment.
Use this class for testing individual functions and methods.
"""
pass
class TestComment(IntegrationTestCase):
def test_comment_creation(self):
test_doc = frappe.get_doc(doctype="ToDo", description="test")
test_doc.insert()
@ -87,7 +96,7 @@ class TestComment(FrappeTestCase):
test_blog.delete()
@change_settings("Blog Settings", {"allow_guest_to_comment": 0})
@IntegrationTestCase.change_settings("Blog Settings", {"allow_guest_to_comment": 0})
def test_guest_cannot_comment(self):
test_blog = make_test_blog()
with set_user("Guest"):

View file

@ -6,7 +6,7 @@ import frappe
from frappe.core.doctype.communication.communication import Communication, get_emails, parse_email
from frappe.core.doctype.communication.email import add_attachments, make
from frappe.email.doctype.email_queue.email_queue import EmailQueue
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
if TYPE_CHECKING:
from frappe.contacts.doctype.contact.contact import Contact
@ -15,7 +15,16 @@ if TYPE_CHECKING:
test_records = frappe.get_test_records("Communication")
class TestCommunication(FrappeTestCase):
class UnitTestCommunication(UnitTestCase):
"""
Unit tests for Communication.
Use this class for testing individual functions and methods.
"""
pass
class TestCommunication(IntegrationTestCase):
def test_email(self):
valid_email_list = [
"Full Name <full@example.com>",
@ -325,7 +334,7 @@ class TestCommunication(FrappeTestCase):
self.assertNotEqual(normal_comm.email_status, "Spam")
class TestCommunicationEmailMixin(FrappeTestCase):
class TestCommunicationEmailMixin(IntegrationTestCase):
def new_communication(self, recipients=None, cc=None, bcc=None) -> Communication:
recipients = ", ".join(recipients or [])
cc = ", ".join(cc or [])

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Custom DocPerm')
class TestCustomDocPerm(FrappeTestCase):
class UnitTestCustomDocperm(UnitTestCase):
"""
Unit tests for CustomDocperm.
Use this class for testing individual functions and methods.
"""
pass
class TestCustomDocPerm(IntegrationTestCase):
pass

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Custom Role')
class TestCustomRole(FrappeTestCase):
class UnitTestCustomRole(UnitTestCase):
"""
Unit tests for CustomRole.
Use this class for testing individual functions and methods.
"""
pass
class TestCustomRole(IntegrationTestCase):
pass

View file

@ -2,10 +2,19 @@
# License: MIT. See LICENSE
import frappe
from frappe.core.doctype.data_export.exporter import DataExporter
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDataExporter(FrappeTestCase):
class UnitTestDataExport(UnitTestCase):
"""
Unit tests for DataExport.
Use this class for testing individual functions and methods.
"""
pass
class TestDataExporter(IntegrationTestCase):
def setUp(self):
self.doctype_name = "Test DocType for Export Tool"
self.doc_name = "Test Data for Export Tool"

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDataImport(FrappeTestCase):
class UnitTestDataImport(UnitTestCase):
"""
Unit tests for DataImport.
Use this class for testing individual functions and methods.
"""
pass
class TestDataImport(IntegrationTestCase):
pass

View file

@ -3,12 +3,21 @@
import frappe
from frappe.core.doctype.data_import.exporter import Exporter
from frappe.core.doctype.data_import.test_importer import create_doctype_if_not_exists
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
doctype_name = "DocType for Export"
class TestExporter(FrappeTestCase):
class UnitTestDataImport(UnitTestCase):
"""
Unit tests for DataImport.
Use this class for testing individual functions and methods.
"""
pass
class TestExporter(IntegrationTestCase):
def setUp(self):
create_doctype_if_not_exists(doctype_name)

View file

@ -2,14 +2,23 @@
# License: MIT. See LICENSE
import frappe
from frappe.core.doctype.data_import.importer import Importer
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.test_query_builder import db_type_is, run_only_if
from frappe.tests.utils import FrappeTestCase
from frappe.utils import format_duration, getdate
doctype_name = "DocType for Import"
class TestImporter(FrappeTestCase):
class UnitTestDataImport(UnitTestCase):
"""
Unit tests for DataImport.
Use this class for testing individual functions and methods.
"""
pass
class TestImporter(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDataImportLog(FrappeTestCase):
class UnitTestDataImportLog(UnitTestCase):
"""
Unit tests for DataImportLog.
Use this class for testing individual functions and methods.
"""
pass
class TestDataImportLog(IntegrationTestCase):
pass

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Deleted Document')
class TestDeletedDocument(FrappeTestCase):
class UnitTestDeletedDocument(UnitTestCase):
"""
Unit tests for DeletedDocument.
Use this class for testing individual functions and methods.
"""
pass
class TestDeletedDocument(IntegrationTestCase):
pass

View file

@ -4,12 +4,21 @@
import frappe
import frappe.share
from frappe.automation.doctype.auto_repeat.test_auto_repeat import create_submittable_doctype
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, UnitTestCase
test_dependencies = ["User"]
class TestDocShare(FrappeTestCase):
class UnitTestDocshare(UnitTestCase):
"""
Unit tests for Docshare.
Use this class for testing individual functions and methods.
"""
pass
class TestDocShare(IntegrationTestCase):
def setUp(self):
self.user = "test@example.com"
self.event = frappe.get_doc(
@ -167,7 +176,7 @@ class TestDocShare(FrappeTestCase):
test_doc.reload()
self.assertTrue(test_doc.has_permission("read"))
@change_settings("System Settings", {"disable_document_sharing": 1})
@IntegrationTestCase.change_settings("System Settings", {"disable_document_sharing": 1})
def test_share_disabled_add(self):
"Test if user loses share access on disabling share globally."
frappe.share.add("Event", self.event.name, self.user, share=1) # Share as admin
@ -179,7 +188,7 @@ class TestDocShare(FrappeTestCase):
frappe.PermissionError, frappe.share.add, "Event", self.event.name, "test1@example.com"
)
@change_settings("System Settings", {"disable_document_sharing": 1})
@IntegrationTestCase.change_settings("System Settings", {"disable_document_sharing": 1})
def test_share_disabled_add_with_ignore_permissions(self):
frappe.share.add("Event", self.event.name, self.user, share=1)
frappe.set_user(self.user)
@ -192,7 +201,7 @@ class TestDocShare(FrappeTestCase):
"Event", self.event.name, "test1@example.com", flags={"ignore_share_permission": True}
)
@change_settings("System Settings", {"disable_document_sharing": 1})
@IntegrationTestCase.change_settings("System Settings", {"disable_document_sharing": 1})
def test_share_disabled_set_permission(self):
frappe.share.add("Event", self.event.name, self.user, share=1)
frappe.set_user(self.user)
@ -208,7 +217,7 @@ class TestDocShare(FrappeTestCase):
"read",
)
@change_settings("System Settings", {"disable_document_sharing": 1})
@IntegrationTestCase.change_settings("System Settings", {"disable_document_sharing": 1})
def test_share_disabled_assign_to(self):
"""
Assigning a document to a user without access must not share the document,

View file

@ -2,8 +2,22 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class Test{classname}(FrappeTestCase):
class Test{classname}(UnitTestCase):
"""
Unit tests for {classname}.
Use this class for testing individual functions and methods.
"""
pass
class Test{classname}(IntegrationTestCase):
"""
Integration tests for {classname}.
Use this class for testing interactions between multiple components.
"""
pass

View file

@ -24,10 +24,19 @@ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from frappe.desk.form.load import getdoc
from frappe.model.delete_doc import delete_controllers
from frappe.model.sync import remove_orphan_doctypes
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDocType(FrappeTestCase):
class UnitTestDoctype(UnitTestCase):
"""
Unit tests for Doctype.
Use this class for testing individual functions and methods.
"""
pass
class TestDocType(IntegrationTestCase):
def tearDown(self):
frappe.db.rollback()

View file

@ -1,10 +1,19 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDocumentNamingRule(FrappeTestCase):
class UnitTestDocumentNamingRule(UnitTestCase):
"""
Unit tests for DocumentNamingRule.
Use this class for testing individual functions and methods.
"""
pass
class TestDocumentNamingRule(IntegrationTestCase):
def test_naming_rule_by_series(self):
naming_rule = frappe.get_doc(
doctype="Document Naming Rule", document_type="ToDo", prefix="test-todo-", prefix_digits=5

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDocumentNamingRuleCondition(FrappeTestCase):
class UnitTestDocumentNamingRuleCondition(UnitTestCase):
"""
Unit tests for DocumentNamingRuleCondition.
Use this class for testing individual functions and methods.
"""
pass
class TestDocumentNamingRuleCondition(IntegrationTestCase):
pass

View file

@ -7,11 +7,20 @@ from frappe.core.doctype.document_naming_settings.document_naming_settings impor
DocumentNamingSettings,
)
from frappe.model.naming import NamingSeries, get_default_naming_series
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import cint
class TestNamingSeries(FrappeTestCase):
class UnitTestDocumentNamingSettings(UnitTestCase):
"""
Unit tests for DocumentNamingSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestNamingSeries(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDocumentShareKey(FrappeTestCase):
class UnitTestDocumentShareKey(UnitTestCase):
"""
Unit tests for DocumentShareKey.
Use this class for testing individual functions and methods.
"""
pass
class TestDocumentShareKey(IntegrationTestCase):
pass

View file

@ -1,7 +1,16 @@
# Copyright (c) 2017, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDomain(FrappeTestCase):
class UnitTestDomain(UnitTestCase):
"""
Unit tests for Domain.
Use this class for testing individual functions and methods.
"""
pass
class TestDomain(IntegrationTestCase):
pass

View file

@ -5,13 +5,22 @@ from unittest.mock import patch
from ldap3.core.exceptions import LDAPException, LDAPInappropriateAuthenticationResult
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils.error import _is_ldap_exception, guess_exception_source
# test_records = frappe.get_test_records('Error Log')
class TestErrorLog(FrappeTestCase):
class UnitTestErrorLog(UnitTestCase):
"""
Unit tests for ErrorLog.
Use this class for testing individual functions and methods.
"""
pass
class TestErrorLog(IntegrationTestCase):
def test_error_log(self):
"""let's do an error log on error log?"""
doc = frappe.new_doc("Error Log")
@ -64,7 +73,7 @@ TEST_EXCEPTIONS = (
)
class TestExceptionSourceGuessing(FrappeTestCase):
class TestExceptionSourceGuessing(IntegrationTestCase):
@patch.object(frappe, "get_installed_apps", return_value=["frappe", "erpnext", "3pa"])
def test_exc_source_guessing(self, _installed_apps):
for source, exc in TEST_EXCEPTIONS:

View file

@ -20,7 +20,7 @@ from frappe.core.doctype.file.exceptions import FileTypeNotAllowed
from frappe.core.doctype.file.utils import get_corrupted_image_msg, get_extension
from frappe.desk.form.utils import add_comment
from frappe.exceptions import ValidationError
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import get_files_path, set_request
if TYPE_CHECKING:
@ -61,7 +61,16 @@ def make_test_image_file(private=False):
_test_file.delete()
class TestSimpleFile(FrappeTestCase):
class UnitTestFile(UnitTestCase):
"""
Unit tests for File.
Use this class for testing individual functions and methods.
"""
pass
class TestSimpleFile(IntegrationTestCase):
def setUp(self):
self.attached_to_doctype, self.attached_to_docname = make_test_doc()
self.test_content = test_content1
@ -83,7 +92,7 @@ class TestSimpleFile(FrappeTestCase):
self.assertEqual(content, self.test_content)
class TestFSRollbacks(FrappeTestCase):
class TestFSRollbacks(IntegrationTestCase):
def test_rollback_from_file_system(self):
file_name = content = frappe.generate_hash()
file = frappe.new_doc("File", file_name=file_name, content=content).insert()
@ -93,8 +102,8 @@ class TestFSRollbacks(FrappeTestCase):
self.assertFalse(file.exists_on_disk())
class TestExtensionValidations(FrappeTestCase):
@change_settings("System Settings", {"allowed_file_extensions": "JPG\nCSV"})
class TestExtensionValidations(IntegrationTestCase):
@IntegrationTestCase.change_settings("System Settings", {"allowed_file_extensions": "JPG\nCSV"})
def test_allowed_extension(self):
set_request(method="POST", path="/")
file_name = content = frappe.generate_hash()
@ -106,7 +115,7 @@ class TestExtensionValidations(FrappeTestCase):
self.assertFalse(bad_file.exists_on_disk())
class TestBase64File(FrappeTestCase):
class TestBase64File(IntegrationTestCase):
def setUp(self):
self.attached_to_doctype, self.attached_to_docname = make_test_doc()
self.test_content = base64.b64encode(test_content1.encode("utf-8"))
@ -129,7 +138,7 @@ class TestBase64File(FrappeTestCase):
self.assertEqual(content, test_content1)
class TestSameFileName(FrappeTestCase):
class TestSameFileName(IntegrationTestCase):
def test_saved_content(self):
self.attached_to_doctype, self.attached_to_docname = make_test_doc()
self.test_content1 = test_content1
@ -189,7 +198,7 @@ class TestSameFileName(FrappeTestCase):
self.assertEqual(_file.get_content(), test_content2)
class TestSameContent(FrappeTestCase):
class TestSameContent(IntegrationTestCase):
def setUp(self):
self.attached_to_doctype1, self.attached_to_docname1 = make_test_doc()
self.attached_to_doctype2, self.attached_to_docname2 = make_test_doc()
@ -274,7 +283,7 @@ class TestSameContent(FrappeTestCase):
self.assertEqual(file_content_properly_decoded, test_content1)
class TestFile(FrappeTestCase):
class TestFile(IntegrationTestCase):
def setUp(self):
frappe.set_user("Administrator")
self.delete_test_data()
@ -595,7 +604,7 @@ def convert_to_symlink(directory):
shutil.move(new_directory, directory)
class TestAttachment(FrappeTestCase):
class TestAttachment(IntegrationTestCase):
test_doctype = "Test For Attachment"
@classmethod
@ -641,7 +650,7 @@ class TestAttachment(FrappeTestCase):
self.assertTrue(exists)
class TestAttachmentsAccess(FrappeTestCase):
class TestAttachmentsAccess(IntegrationTestCase):
def setUp(self) -> None:
frappe.db.delete("File", {"is_folder": 0})
@ -707,7 +716,7 @@ class TestAttachmentsAccess(FrappeTestCase):
frappe.db.rollback()
class TestFileUtils(FrappeTestCase):
class TestFileUtils(IntegrationTestCase):
def test_extract_images_from_doc(self):
is_private = not frappe.get_meta("ToDo").make_attachments_public
@ -792,7 +801,7 @@ class TestFileUtils(FrappeTestCase):
self.assertTrue(folder.is_folder)
class TestFileOptimization(FrappeTestCase):
class TestFileOptimization(IntegrationTestCase):
def test_optimize_file(self):
with make_test_image_file() as test_file:
original_size = test_file.file_size
@ -844,7 +853,7 @@ class TestFileOptimization(FrappeTestCase):
self.assertEqual(get_extension("", None, file_content), "jpg")
class TestGuestFileAndAttachments(FrappeTestCase):
class TestGuestFileAndAttachments(IntegrationTestCase):
def setUp(self) -> None:
frappe.db.delete("File", {"is_folder": 0})
frappe.get_doc(

View file

@ -6,10 +6,19 @@ from frappe.core.doctype.installed_applications.installed_applications import (
InvalidAppOrder,
update_installed_apps_order,
)
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestInstalledApplications(FrappeTestCase):
class UnitTestInstalledApplications(UnitTestCase):
"""
Unit tests for InstalledApplications.
Use this class for testing individual functions and methods.
"""
pass
class TestInstalledApplications(IntegrationTestCase):
def test_order_change(self):
update_installed_apps_order(["frappe"])
self.assertRaises(InvalidAppOrder, update_installed_apps_order, [])

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Language')
class TestLanguage(FrappeTestCase):
class UnitTestLanguage(UnitTestCase):
"""
Unit tests for Language.
Use this class for testing individual functions and methods.
"""
pass
class TestLanguage(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestLogSettingUser(FrappeTestCase):
class UnitTestLogSettingUser(UnitTestCase):
"""
Unit tests for LogSettingUser.
Use this class for testing individual functions and methods.
"""
pass
class TestLogSettingUser(IntegrationTestCase):
pass

View file

@ -5,11 +5,20 @@ from datetime import datetime
import frappe
from frappe.core.doctype.log_settings.log_settings import _supports_log_clearing, run_log_clean_up
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import add_to_date, now_datetime
class TestLogSettings(FrappeTestCase):
class UnitTestLogSettings(UnitTestCase):
"""
Unit tests for LogSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestLogSettings(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Module Def')
class TestModuleDef(FrappeTestCase):
class UnitTestModuleDef(UnitTestCase):
"""
Unit tests for ModuleDef.
Use this class for testing individual functions and methods.
"""
pass
class TestModuleDef(IntegrationTestCase):
pass

View file

@ -1,10 +1,19 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestModuleProfile(FrappeTestCase):
class UnitTestModuleProfile(UnitTestCase):
"""
Unit tests for ModuleProfile.
Use this class for testing individual functions and methods.
"""
pass
class TestModuleProfile(IntegrationTestCase):
def test_make_new_module_profile(self):
if not frappe.db.get_value("Module Profile", "_Test Module Profile"):
frappe.get_doc(

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestNavbarItem(FrappeTestCase):
class UnitTestNavbarItem(UnitTestCase):
"""
Unit tests for NavbarItem.
Use this class for testing individual functions and methods.
"""
pass
class TestNavbarItem(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestNavbarSettings(FrappeTestCase):
class UnitTestNavbarSettings(UnitTestCase):
"""
Unit tests for NavbarSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestNavbarSettings(IntegrationTestCase):
pass

View file

@ -5,10 +5,19 @@ import json
import os
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestPackage(FrappeTestCase):
class UnitTestPackage(UnitTestCase):
"""
Unit tests for Package.
Use this class for testing individual functions and methods.
"""
pass
class TestPackage(IntegrationTestCase):
def test_package_release(self):
make_test_package()
make_test_module()

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestPackageImport(FrappeTestCase):
class UnitTestPackageImport(UnitTestCase):
"""
Unit tests for PackageImport.
Use this class for testing individual functions and methods.
"""
pass
class TestPackageImport(IntegrationTestCase):
pass

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestPackageRelease(FrappeTestCase):
class UnitTestPackageRelease(UnitTestCase):
"""
Unit tests for PackageRelease.
Use this class for testing individual functions and methods.
"""
pass
class TestPackageRelease(IntegrationTestCase):
pass

View file

@ -5,12 +5,21 @@ import unittest
from unittest.mock import patch
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_records = frappe.get_test_records("Page")
class TestPage(FrappeTestCase):
class UnitTestPage(UnitTestCase):
"""
Unit tests for Page.
Use this class for testing individual functions and methods.
"""
pass
class TestPage(IntegrationTestCase):
def test_naming(self):
self.assertRaises(
frappe.NameError,

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Patch Log')
class TestPatchLog(FrappeTestCase):
class UnitTestPatchLog(UnitTestCase):
"""
Unit tests for PatchLog.
Use this class for testing individual functions and methods.
"""
pass
class TestPatchLog(IntegrationTestCase):
pass

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestPermissionInspector(FrappeTestCase):
class UnitTestPermissionInspector(UnitTestCase):
"""
Unit tests for PermissionInspector.
Use this class for testing individual functions and methods.
"""
pass
class TestPermissionInspector(IntegrationTestCase):
pass

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestPermissionLog(FrappeTestCase):
class UnitTestPermissionLog(UnitTestCase):
"""
Unit tests for PermissionLog.
Use this class for testing individual functions and methods.
"""
pass
class TestPermissionLog(IntegrationTestCase):
pass

View file

@ -7,11 +7,21 @@ from contextlib import contextmanager
import frappe
from frappe.desk.query_report import generate_report_result, get_report_doc
from frappe.query_builder.utils import db_type_is
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.test_query_builder import run_only_if
from frappe.tests.utils import FrappeTestCase, timeout
from frappe.tests.utils import timeout
class TestPreparedReport(FrappeTestCase):
class UnitTestPreparedReport(UnitTestCase):
"""
Unit tests for PreparedReport.
Use this class for testing individual functions and methods.
"""
pass
class TestPreparedReport(IntegrationTestCase):
@classmethod
def tearDownClass(cls):
for r in frappe.get_all("Prepared Report", pluck="name"):

View file

@ -8,12 +8,21 @@ import frappe.recorder
from frappe.core.doctype.recorder.recorder import _optimize_query, serialize_request
from frappe.query_builder.utils import db_type_is
from frappe.recorder import get as get_recorder_data
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.test_query_builder import run_only_if
from frappe.tests.utils import FrappeTestCase
from frappe.utils import set_request
class TestRecorder(FrappeTestCase):
class UnitTestRecorder(UnitTestCase):
"""
Unit tests for Recorder.
Use this class for testing individual functions and methods.
"""
pass
class TestRecorder(IntegrationTestCase):
def setUp(self):
self.start_recoder()
@ -79,7 +88,7 @@ class TestRecorder(FrappeTestCase):
self.assertIsInstance(serialize_request(request_doc), dict)
class TestQueryOptimization(FrappeTestCase):
class TestQueryOptimization(IntegrationTestCase):
@run_only_if(db_type_is.MARIADB)
def test_query_optimizer(self):
suggested_index = _optimize_query(

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestRecorderQuery(FrappeTestCase):
class UnitTestRecorderQuery(UnitTestCase):
"""
Unit tests for RecorderQuery.
Use this class for testing individual functions and methods.
"""
pass
class TestRecorderQuery(IntegrationTestCase):
pass

View file

@ -11,13 +11,22 @@ from frappe.custom.doctype.customize_form.customize_form import reset_customizat
from frappe.desk.query_report import add_total_row, run, save_report
from frappe.desk.reportview import delete_report
from frappe.desk.reportview import save_report as _save_report
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_records = frappe.get_test_records("Report")
test_dependencies = ["User"]
class TestReport(FrappeTestCase):
class UnitTestReport(UnitTestCase):
"""
Unit tests for Report.
Use this class for testing individual functions and methods.
"""
pass
class TestReport(IntegrationTestCase):
@classmethod
def setUpClass(cls) -> None:
cls.enable_safe_exec()

View file

@ -3,12 +3,21 @@
import frappe
from frappe.core.doctype.role.role import get_info_based_on_role
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_records = frappe.get_test_records("Role")
class TestUser(FrappeTestCase):
class UnitTestRole(UnitTestCase):
"""
Unit tests for Role.
Use this class for testing individual functions and methods.
"""
pass
class TestUser(IntegrationTestCase):
def test_disable_role(self):
frappe.get_doc("User", "test@example.com").add_roles("_Test Role 3")

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestRolePermissionforPageandReport(FrappeTestCase):
class UnitTestRolePermissionForPageAndReport(UnitTestCase):
"""
Unit tests for RolePermissionForPageAndReport.
Use this class for testing individual functions and methods.
"""
pass
class TestRolePermissionforPageandReport(IntegrationTestCase):
pass

View file

@ -1,12 +1,21 @@
# Copyright (c) 2017, Frappe Technologies and Contributors
# License: MIT. See LICENSE
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_dependencies = ["Role"]
class TestRoleProfile(FrappeTestCase):
class UnitTestRoleProfile(UnitTestCase):
"""
Unit tests for RoleProfile.
Use this class for testing individual functions and methods.
"""
pass
class TestRoleProfile(IntegrationTestCase):
def test_make_new_role_profiles(self):
frappe.delete_doc_if_exists("Role Profile", "Test 1", force=1)
new_role_profile = frappe.get_doc(doctype="Role Profile", role_profile="Test 1").insert()

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestRoleReplication(FrappeTestCase):
class UnitTestRoleReplication(UnitTestCase):
"""
Unit tests for RoleReplication.
Use this class for testing individual functions and methods.
"""
pass
class TestRoleReplication(IntegrationTestCase):
pass

View file

@ -10,7 +10,8 @@ from rq.job import Job
import frappe
from frappe.core.doctype.rq_job.rq_job import RQJob, remove_failed_jobs, stop_job
from frappe.installer import update_site_config
from frappe.tests.utils import FrappeTestCase, timeout
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import timeout
from frappe.utils import cstr, execute_in_shell
from frappe.utils.background_jobs import get_job_status, is_job_enqueued
@ -23,7 +24,16 @@ def wait_for_completion(job: Job):
time.sleep(0.2)
class TestRQJob(FrappeTestCase):
class UnitTestRqJob(UnitTestCase):
"""
Unit tests for RqJob.
Use this class for testing individual functions and methods.
"""
pass
class TestRQJob(IntegrationTestCase):
BG_JOB = "frappe.core.doctype.rq_job.test_rq_job.test_func"
def check_status(self, job: Job, status, wait=True):

View file

@ -3,10 +3,19 @@
import frappe
from frappe.core.doctype.rq_worker.rq_worker import RQWorker
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestRQWorker(FrappeTestCase):
class UnitTestRqWorker(UnitTestCase):
"""
Unit tests for RqWorker.
Use this class for testing individual functions and methods.
"""
pass
class TestRQWorker(IntegrationTestCase):
def test_get_worker_list(self):
workers = RQWorker.get_list()
self.assertGreaterEqual(len(workers), 1)

View file

@ -1,8 +1,17 @@
# Copyright (c) 2019, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestScheduledJobLog(FrappeTestCase):
class UnitTestScheduledJobLog(UnitTestCase):
"""
Unit tests for ScheduledJobLog.
Use this class for testing individual functions and methods.
"""
pass
class TestScheduledJobLog(IntegrationTestCase):
pass

View file

@ -4,12 +4,21 @@ from datetime import timedelta
import frappe
from frappe.core.doctype.scheduled_job_type.scheduled_job_type import sync_jobs
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import get_datetime
from frappe.utils.data import now_datetime
class TestScheduledJobType(FrappeTestCase):
class UnitTestScheduledJobType(UnitTestCase):
"""
Unit tests for ScheduledJobType.
Use this class for testing individual functions and methods.
"""
pass
class TestScheduledJobType(IntegrationTestCase):
def setUp(self):
frappe.db.rollback()
frappe.db.truncate("Scheduled Job Type")

View file

@ -6,7 +6,7 @@ import frappe
from frappe.core.doctype.scheduled_job_type.scheduled_job_type import ScheduledJobType, sync_jobs
from frappe.core.doctype.server_script.server_script import ServerScript
from frappe.frappeclient import FrappeClient, FrappeException
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import get_site_url
scripts = [
@ -108,7 +108,16 @@ doc.save()
]
class TestServerScript(FrappeTestCase):
class UnitTestServerScript(UnitTestCase):
"""
Unit tests for ServerScript.
Use this class for testing individual functions and methods.
"""
pass
class TestServerScript(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

View file

@ -5,10 +5,19 @@ from frappe.core.doctype.session_default_settings.session_default_settings impor
clear_session_defaults,
set_session_default_values,
)
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestSessionDefaultSettings(FrappeTestCase):
class UnitTestSessionDefaultSettings(UnitTestCase):
"""
Unit tests for SessionDefaultSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestSessionDefaultSettings(IntegrationTestCase):
def test_set_session_default_settings(self):
frappe.set_user("Administrator")
settings = frappe.get_single("Session Default Settings")

View file

@ -1,7 +1,16 @@
# Copyright (c) 2017, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestSMSSettings(FrappeTestCase):
class UnitTestSmsSettings(UnitTestCase):
"""
Unit tests for SmsSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestSMSSettings(IntegrationTestCase):
pass

View file

@ -5,14 +5,24 @@ import time
import typing
import frappe
from frappe.tests.utils import FrappeTestCase, timeout
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import timeout
from frappe.utils.background_jobs import get_queue
if typing.TYPE_CHECKING:
from rq.job import Job
class TestSubmissionQueue(FrappeTestCase):
class UnitTestSubmissionQueue(UnitTestCase):
"""
Unit tests for SubmissionQueue.
Use this class for testing individual functions and methods.
"""
pass
class TestSubmissionQueue(IntegrationTestCase):
queue = get_queue(qtype="default")
@timeout(seconds=20)

View file

@ -1,7 +1,16 @@
# Copyright (c) 2017, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestSystemSettings(FrappeTestCase):
class UnitTestSystemSettings(UnitTestCase):
"""
Unit tests for SystemSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestSystemSettings(IntegrationTestCase):
pass

View file

@ -3,12 +3,21 @@
import hashlib
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_records = []
class TestTransactionLog(FrappeTestCase):
class UnitTestTransactionLog(UnitTestCase):
"""
Unit tests for TransactionLog.
Use this class for testing individual functions and methods.
"""
pass
class TestTransactionLog(IntegrationTestCase):
def test_validate_chaining(self):
frappe.get_doc(
{

View file

@ -2,10 +2,19 @@
# License: MIT. See LICENSE
import frappe
from frappe import _
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestTranslation(FrappeTestCase):
class UnitTestTranslation(UnitTestCase):
"""
Unit tests for Translation.
Use this class for testing individual functions and methods.
"""
pass
class TestTranslation(IntegrationTestCase):
def setUp(self):
frappe.db.delete("Translation")

View file

@ -22,15 +22,24 @@ from frappe.core.doctype.user.user import (
from frappe.desk.notifications import extract_mentions
from frappe.frappeclient import FrappeClient
from frappe.model.delete_doc import delete_doc
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.test_api import FrappeAPITestCase
from frappe.tests.utils import FrappeTestCase, change_settings
from frappe.utils import get_url
user_module = frappe.core.doctype.user.user
test_records = frappe.get_test_records("User")
class TestUser(FrappeTestCase):
class UnitTestUser(UnitTestCase):
"""
Unit tests for User.
Use this class for testing individual functions and methods.
"""
pass
class TestUser(IntegrationTestCase):
def tearDown(self):
# disable password strength test
frappe.db.set_single_value("System Settings", "enable_password_policy", 0)
@ -279,7 +288,7 @@ class TestUser(FrappeTestCase):
"""
self.assertListEqual(extract_mentions(comment), ["test@example.com", "test1@example.com"])
@change_settings("System Settings", commit=True, password_reset_limit=1)
@IntegrationTestCase.change_settings("System Settings", commit=True, password_reset_limit=1)
def test_rate_limiting_for_reset_password(self):
url = get_url()
data = {"cmd": "frappe.core.doctype.user.user.reset_password", "user": "test@test.com"}
@ -358,7 +367,7 @@ class TestUser(FrappeTestCase):
"/signup",
)
@change_settings("System Settings", password_reset_limit=6)
@IntegrationTestCase.change_settings("System Settings", password_reset_limit=6)
def test_reset_password(self):
from frappe.auth import CookieManager, LoginManager
from frappe.utils import set_request
@ -444,7 +453,7 @@ class TestUser(FrappeTestCase):
sorted(m.get("module_name") for m in get_modules_from_all_apps()),
)
@change_settings("System Settings", reset_password_link_expiry_duration=1)
@IntegrationTestCase.change_settings("System Settings", reset_password_link_expiry_duration=1)
def test_reset_password_link_expiry(self):
new_password = "new_password"
frappe.set_user("testpassword@example.com")

View file

@ -1,8 +1,17 @@
# Copyright (c) 2021, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestUserGroup(FrappeTestCase):
class UnitTestUserGroup(UnitTestCase):
"""
Unit tests for UserGroup.
Use this class for testing individual functions and methods.
"""
pass
class TestUserGroup(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2021, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestUserGroupMember(FrappeTestCase):
class UnitTestUserGroupMember(UnitTestCase):
"""
Unit tests for UserGroupMember.
Use this class for testing individual functions and methods.
"""
pass
class TestUserGroupMember(IntegrationTestCase):
pass

View file

@ -7,11 +7,20 @@ from frappe.core.doctype.user_permission.user_permission import (
remove_applicable,
)
from frappe.permissions import add_permission, has_user_permission
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.website.doctype.blog_post.test_blog_post import make_test_blog
class TestUserPermission(FrappeTestCase):
class UnitTestUserPermission(UnitTestCase):
"""
Unit tests for UserPermission.
Use this class for testing individual functions and methods.
"""
pass
class TestUserPermission(IntegrationTestCase):
def setUp(self):
test_users = (
"test_bulk_creation_update@example.com",

View file

@ -2,10 +2,19 @@
# License: MIT. See LICENSE
import frappe
from frappe.installer import update_site_config
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestUserType(FrappeTestCase):
class UnitTestUserType(UnitTestCase):
"""
Unit tests for UserType.
Use this class for testing individual functions and methods.
"""
pass
class TestUserType(IntegrationTestCase):
def setUp(self):
create_role()

View file

@ -4,11 +4,20 @@ import copy
import frappe
from frappe.core.doctype.version.version import get_diff
from frappe.test_runner import make_test_objects
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import make_test_objects
class TestVersion(FrappeTestCase):
class UnitTestVersion(UnitTestCase):
"""
Unit tests for Version.
Use this class for testing individual functions and methods.
"""
pass
class TestVersion(IntegrationTestCase):
def test_get_diff(self):
frappe.set_user("Administrator")
test_records = make_test_objects("Event", reset=True)

View file

@ -1,10 +1,19 @@
# Copyright (c) 2018, Frappe Technologies and Contributors
# License: MIT. See LICENSE
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestViewLog(FrappeTestCase):
class UnitTestViewLog(UnitTestCase):
"""
Unit tests for ViewLog.
Use this class for testing individual functions and methods.
"""
pass
class TestViewLog(IntegrationTestCase):
def tearDown(self):
frappe.set_user("Administrator")

View file

@ -5,10 +5,10 @@
from frappe.core.report.database_storage_usage_by_tables.database_storage_usage_by_tables import (
execute,
)
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
class TestDBUsageReport(FrappeTestCase):
class TestDBUsageReport(IntegrationTestCase):
def test_basic_query(self):
_, data = execute()
tables = [d.table for d in data]

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Client Script')
class TestClientScript(FrappeTestCase):
class UnitTestClientScript(UnitTestCase):
"""
Unit tests for ClientScript.
Use this class for testing individual functions and methods.
"""
pass
class TestClientScript(IntegrationTestCase):
pass

View file

@ -7,12 +7,21 @@ from frappe.custom.doctype.custom_field.custom_field import (
create_custom_fields,
rename_fieldname,
)
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_records = frappe.get_test_records("Custom Field")
class TestCustomField(FrappeTestCase):
class UnitTestCustomField(UnitTestCase):
"""
Unit tests for CustomField.
Use this class for testing individual functions and methods.
"""
pass
class TestCustomField(IntegrationTestCase):
def test_create_custom_fields(self):
create_custom_fields(
{

View file

@ -6,13 +6,22 @@ import json
import frappe
from frappe.core.doctype.doctype.doctype import InvalidFieldNameError
from frappe.core.doctype.doctype.test_doctype import new_doctype
from frappe.test_runner import make_test_records_for_doctype
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import make_test_records_for_doctype
test_dependencies = ["Custom Field", "Property Setter"]
class TestCustomizeForm(FrappeTestCase):
class UnitTestCustomizeForm(UnitTestCase):
"""
Unit tests for CustomizeForm.
Use this class for testing individual functions and methods.
"""
pass
class TestCustomizeForm(IntegrationTestCase):
def insert_custom_field(self):
frappe.delete_doc_if_exists("Custom Field", "Event-custom_test_field")
self.field = frappe.get_doc(

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDocTypeLayout(FrappeTestCase):
class UnitTestDoctypeLayout(UnitTestCase):
"""
Unit tests for DoctypeLayout.
Use this class for testing individual functions and methods.
"""
pass
class TestDocTypeLayout(IntegrationTestCase):
pass

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Property Setter')
class TestPropertySetter(FrappeTestCase):
class UnitTestPropertySetter(UnitTestCase):
"""
Unit tests for PropertySetter.
Use this class for testing individual functions and methods.
"""
pass
class TestPropertySetter(IntegrationTestCase):
pass

View file

@ -3,10 +3,10 @@
from frappe.custom.report.audit_system_hooks.audit_system_hooks import execute
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
class TestAuditSystemHooksReport(FrappeTestCase):
class TestAuditSystemHooksReport(IntegrationTestCase):
def test_basic_query(self):
_, data = execute()
for row in data:

View file

@ -6,10 +6,20 @@ import time
import frappe
from frappe.core.doctype.doctype.test_doctype import new_doctype
from frappe.desk.doctype.bulk_update.bulk_update import submit_cancel_or_update_docs
from frappe.tests.utils import FrappeTestCase, timeout
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import timeout
class TestBulkUpdate(FrappeTestCase):
class UnitTestBulkUpdate(UnitTestCase):
"""
Unit tests for BulkUpdate.
Use this class for testing individual functions and methods.
"""
pass
class TestBulkUpdate(IntegrationTestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestChangelogFeed(FrappeTestCase):
class UnitTestChangelogFeed(UnitTestCase):
"""
Unit tests for ChangelogFeed.
Use this class for testing individual functions and methods.
"""
pass
class TestChangelogFeed(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestConsoleLog(FrappeTestCase):
class UnitTestConsoleLog(UnitTestCase):
"""
Unit tests for ConsoleLog.
Use this class for testing individual functions and methods.
"""
pass
class TestConsoleLog(IntegrationTestCase):
pass

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestCustomHTMLBlock(FrappeTestCase):
class UnitTestCustomHtmlBlock(UnitTestCase):
"""
Unit tests for CustomHtmlBlock.
Use this class for testing individual functions and methods.
"""
pass
class TestCustomHTMLBlock(IntegrationTestCase):
pass

View file

@ -2,11 +2,20 @@
# License: MIT. See LICENSE
import frappe
from frappe.core.doctype.user.test_user import test_user
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils.modules import get_modules_from_all_apps_for_user
class TestDashboard(FrappeTestCase):
class UnitTestDashboard(UnitTestCase):
"""
Unit tests for Dashboard.
Use this class for testing individual functions and methods.
"""
pass
class TestDashboard(IntegrationTestCase):
def test_permission_query(self):
for user in ["Administrator", "test@example.com"]:
with self.set_user(user):

View file

@ -8,12 +8,21 @@ from dateutil.relativedelta import relativedelta
import frappe
from frappe.desk.doctype.dashboard_chart.dashboard_chart import get
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.utils import formatdate, get_last_day, getdate
from frappe.utils.dateutils import get_period, get_period_ending
class TestDashboardChart(FrappeTestCase):
class UnitTestDashboardChart(UnitTestCase):
"""
Unit tests for DashboardChart.
Use this class for testing individual functions and methods.
"""
pass
class TestDashboardChart(IntegrationTestCase):
def test_period_ending(self):
self.assertEqual(get_period_ending("2019-04-10", "Daily"), getdate("2019-04-10"))

View file

@ -1,7 +1,16 @@
# Copyright (c) 2019, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestDashboardChartSource(FrappeTestCase):
class UnitTestDashboardChartSource(UnitTestCase):
"""
Unit tests for DashboardChartSource.
Use this class for testing individual functions and methods.
"""
pass
class TestDashboardChartSource(IntegrationTestCase):
pass

View file

@ -7,13 +7,22 @@ import json
import frappe
import frappe.defaults
from frappe.desk.doctype.event.event import get_events
from frappe.test_runner import make_test_objects
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
from frappe.tests.utils import make_test_objects
test_records = frappe.get_test_records("Event")
class TestEvent(FrappeTestCase):
class UnitTestEvent(UnitTestCase):
"""
Unit tests for Event.
Use this class for testing individual functions and methods.
"""
pass
class TestEvent(IntegrationTestCase):
def setUp(self):
frappe.db.delete("Event")
make_test_objects("Event", reset=True)

View file

@ -2,8 +2,17 @@
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestFormTour(FrappeTestCase):
class UnitTestFormTour(UnitTestCase):
"""
Unit tests for FormTour.
Use this class for testing individual functions and methods.
"""
pass
class TestFormTour(IntegrationTestCase):
pass

View file

@ -1,9 +1,18 @@
# Copyright (c) 2015, Frappe Technologies and Contributors
# License: MIT. See LICENSE
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
# test_records = frappe.get_test_records('Kanban Board')
class TestKanbanBoard(FrappeTestCase):
class UnitTestKanbanBoard(UnitTestCase):
"""
Unit tests for KanbanBoard.
Use this class for testing individual functions and methods.
"""
pass
class TestKanbanBoard(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2019, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestListViewSettings(FrappeTestCase):
class UnitTestListViewSettings(UnitTestCase):
"""
Unit tests for ListViewSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestListViewSettings(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestModuleOnboarding(FrappeTestCase):
class UnitTestModuleOnboarding(UnitTestCase):
"""
Unit tests for ModuleOnboarding.
Use this class for testing individual functions and methods.
"""
pass
class TestModuleOnboarding(IntegrationTestCase):
pass

View file

@ -2,12 +2,21 @@
# License: MIT. See LICENSE
import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
test_records = frappe.get_test_records("Note")
class TestNote(FrappeTestCase):
class UnitTestNote(UnitTestCase):
"""
Unit tests for Note.
Use this class for testing individual functions and methods.
"""
pass
class TestNote(IntegrationTestCase):
def insert_note(self):
frappe.db.delete("Version")
frappe.db.delete("Note")

View file

@ -3,10 +3,19 @@
import frappe
from frappe.core.doctype.user.user import get_system_users
from frappe.desk.form.assign_to import add as assign_task
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestNotificationLog(FrappeTestCase):
class UnitTestNotificationLog(UnitTestCase):
"""
Unit tests for NotificationLog.
Use this class for testing individual functions and methods.
"""
pass
class TestNotificationLog(IntegrationTestCase):
def test_assignment(self):
todo = get_todo()
user = get_user()

View file

@ -2,8 +2,17 @@
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestNotificationSettings(FrappeTestCase):
class UnitTestNotificationSettings(UnitTestCase):
"""
Unit tests for NotificationSettings.
Use this class for testing individual functions and methods.
"""
pass
class TestNotificationSettings(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestNumberCard(FrappeTestCase):
class UnitTestNumberCard(UnitTestCase):
"""
Unit tests for NumberCard.
Use this class for testing individual functions and methods.
"""
pass
class TestNumberCard(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestOnboardingPermission(FrappeTestCase):
class UnitTestOnboardingPermission(UnitTestCase):
"""
Unit tests for OnboardingPermission.
Use this class for testing individual functions and methods.
"""
pass
class TestOnboardingPermission(IntegrationTestCase):
pass

View file

@ -1,8 +1,17 @@
# Copyright (c) 2020, Frappe Technologies and Contributors
# License: MIT. See LICENSE
# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase, UnitTestCase
class TestOnboardingStep(FrappeTestCase):
class UnitTestOnboardingStep(UnitTestCase):
"""
Unit tests for OnboardingStep.
Use this class for testing individual functions and methods.
"""
pass
class TestOnboardingStep(IntegrationTestCase):
pass

Some files were not shown because too many files have changed in this diff Show more