From c114e5fae8247d285d25eb2f19577f5713540e3d Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sun, 6 Oct 2024 11:43:36 +0200 Subject: [PATCH] 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 --- .../assignment_rule/test_assignment_rule.py | 15 +- .../doctype/auto_repeat/test_auto_repeat.py | 13 +- .../doctype/milestone/test_milestone.py | 13 +- .../test_milestone_tracker.py | 13 +- .../doctype/reminder/test_reminder.py | 13 +- .../contacts/doctype/address/test_address.py | 13 +- .../address_template/test_address_template.py | 13 +- .../contacts/doctype/contact/test_contact.py | 13 +- frappe/contacts/doctype/gender/test_gender.py | 13 +- .../doctype/salutation/test_salutation.py | 13 +- .../test_addresses_and_contacts.py | 4 +- .../doctype/access_log/test_access_log.py | 13 +- .../doctype/activity_log/test_activity_log.py | 13 +- .../doctype/audit_trail/test_audit_trail.py | 13 +- frappe/core/doctype/comment/test_comment.py | 15 +- .../communication/test_communication.py | 15 +- .../custom_docperm/test_custom_docperm.py | 13 +- .../doctype/custom_role/test_custom_role.py | 13 +- .../doctype/data_export/test_data_exporter.py | 13 +- .../doctype/data_import/test_data_import.py | 13 +- .../core/doctype/data_import/test_exporter.py | 13 +- .../core/doctype/data_import/test_importer.py | 13 +- .../data_import_log/test_data_import_log.py | 13 +- .../deleted_document/test_deleted_document.py | 13 +- frappe/core/doctype/docshare/test_docshare.py | 21 +- .../doctype/boilerplate/test_controller._py | 18 +- frappe/core/doctype/doctype/test_doctype.py | 13 +- .../test_document_naming_rule.py | 13 +- .../test_document_naming_rule_condition.py | 13 +- .../test_document_naming_settings.py | 13 +- .../test_document_share_key.py | 13 +- frappe/core/doctype/domain/test_domain.py | 13 +- .../core/doctype/error_log/test_error_log.py | 15 +- frappe/core/doctype/file/test_file.py | 37 +- .../test_installed_applications.py | 13 +- frappe/core/doctype/language/test_language.py | 13 +- .../log_setting_user/test_log_setting_user.py | 13 +- .../doctype/log_settings/test_log_settings.py | 13 +- .../doctype/module_def/test_module_def.py | 13 +- .../module_profile/test_module_profile.py | 13 +- .../doctype/navbar_item/test_navbar_item.py | 13 +- .../navbar_settings/test_navbar_settings.py | 13 +- frappe/core/doctype/package/test_package.py | 13 +- .../package_import/test_package_import.py | 13 +- .../package_release/test_package_release.py | 13 +- frappe/core/doctype/page/test_page.py | 13 +- .../core/doctype/patch_log/test_patch_log.py | 13 +- .../test_permission_inspector.py | 13 +- .../permission_log/test_permission_log.py | 13 +- .../prepared_report/test_prepared_report.py | 14 +- frappe/core/doctype/recorder/test_recorder.py | 15 +- .../recorder_query/test_recorder_query.py | 13 +- frappe/core/doctype/report/test_report.py | 13 +- frappe/core/doctype/role/test_role.py | 13 +- ...est_role_permission_for_page_and_report.py | 13 +- .../doctype/role_profile/test_role_profile.py | 13 +- .../role_replication/test_role_replication.py | 13 +- frappe/core/doctype/rq_job/test_rq_job.py | 14 +- .../core/doctype/rq_worker/test_rq_worker.py | 13 +- .../test_scheduled_job_log.py | 13 +- .../test_scheduled_job_type.py | 13 +- .../server_script/test_server_script.py | 13 +- .../test_session_default_settings.py | 13 +- .../doctype/sms_settings/test_sms_settings.py | 13 +- .../submission_queue/test_submission_queue.py | 14 +- .../system_settings/test_system_settings.py | 13 +- .../transaction_log/test_transaction_log.py | 13 +- .../doctype/translation/test_translation.py | 13 +- frappe/core/doctype/user/test_user.py | 19 +- .../doctype/user_group/test_user_group.py | 13 +- .../test_user_group_member.py | 13 +- .../user_permission/test_user_permission.py | 13 +- .../core/doctype/user_type/test_user_type.py | 13 +- frappe/core/doctype/version/test_version.py | 15 +- frappe/core/doctype/view_log/test_view_log.py | 13 +- .../test_database_storage_usage_by_tables.py | 4 +- .../client_script/test_client_script.py | 13 +- .../doctype/custom_field/test_custom_field.py | 13 +- .../customize_form/test_customize_form.py | 15 +- .../doctype_layout/test_doctype_layout.py | 13 +- .../property_setter/test_property_setter.py | 13 +- .../test_audit_system_hooks.py | 4 +- .../doctype/bulk_update/test_bulk_update.py | 14 +- .../changelog_feed/test_changelog_feed.py | 13 +- .../doctype/console_log/test_console_log.py | 13 +- .../test_custom_html_block.py | 13 +- .../desk/doctype/dashboard/test_dashboard.py | 13 +- .../dashboard_chart/test_dashboard_chart.py | 13 +- .../test_dashboard_chart_source.py | 13 +- frappe/desk/doctype/event/test_event.py | 15 +- .../desk/doctype/form_tour/test_form_tour.py | 13 +- .../doctype/kanban_board/test_kanban_board.py | 13 +- .../test_list_view_settings.py | 13 +- .../test_module_onboarding.py | 13 +- frappe/desk/doctype/note/test_note.py | 13 +- .../notification_log/test_notification_log.py | 13 +- .../test_notification_settings.py | 13 +- .../doctype/number_card/test_number_card.py | 13 +- .../test_onboarding_permission.py | 13 +- .../onboarding_step/test_onboarding_step.py | 13 +- .../system_console/test_system_console.py | 13 +- .../test_system_health_report.py | 13 +- frappe/desk/doctype/tag/test_tag.py | 13 +- frappe/desk/doctype/tag_link/test_tag_link.py | 13 +- frappe/desk/doctype/todo/test_todo.py | 13 +- .../desk/doctype/workspace/test_workspace.py | 13 +- .../test_workspace_settings.py | 13 +- frappe/desk/form/test_form.py | 4 +- .../test_auto_email_report.py | 13 +- .../document_follow/test_document_follow.py | 13 +- .../email_account/test_email_account.py | 15 +- .../doctype/email_domain/test_email_domain.py | 15 +- .../email_flag_queue/test_email_flag_queue.py | 13 +- .../doctype/email_group/test_email_group.py | 13 +- .../test_email_group_member.py | 13 +- .../doctype/email_queue/test_email_queue.py | 13 +- .../doctype/email_rule/test_email_rule.py | 13 +- .../email_template/test_email_template.py | 13 +- .../test_email_unsubscribe.py | 13 +- .../doctype/newsletter/test_newsletter.py | 4 +- .../doctype/notification/test_notification.py | 15 +- .../unhandled_email/test_unhandled_email.py | 13 +- frappe/email/test_email_attachments.py | 4 +- frappe/email/test_email_body.py | 4 +- frappe/email/test_smtp.py | 4 +- frappe/geo/doctype/country/test_country.py | 13 +- frappe/geo/doctype/currency/test_currency.py | 13 +- .../extractors/tests/test_javascript.py | 4 +- frappe/gettext/test_translate.py | 4 +- .../connected_app/test_connected_app.py | 13 +- .../dropbox_settings/test_dropbox_settings.py | 13 +- .../test_geolocation_settings.py | 13 +- .../google_contacts/test_google_contacts.py | 13 +- .../doctype/google_drive/test_google_drive.py | 13 +- .../google_settings/test_google_settings.py | 13 +- .../test_integration_request.py | 13 +- .../test_oauth_authorization_code.py | 13 +- .../test_oauth_bearer_token.py | 13 +- .../doctype/oauth_client/test_oauth_client.py | 13 +- .../test_push_notification_settings.py | 13 +- .../test_s3_backup_settings.py | 13 +- .../test_slack_webhook_url.py | 13 +- .../social_login_key/test_social_login_key.py | 15 +- .../doctype/token_cache/test_token_cache.py | 13 +- .../doctype/webhook/test_webhook.py | 13 +- .../test_webhook_request_log.py | 13 +- frappe/parallel_test_runner.py | 3 +- .../doctype/letter_head/test_letter_head.py | 13 +- .../test_network_printer_settings.py | 13 +- .../doctype/print_format/test_print_format.py | 13 +- .../test_print_format_field_template.py | 13 +- .../print_heading/test_print_heading.py | 13 +- .../print_settings/test_print_settings.py | 13 +- .../doctype/print_style/test_print_style.py | 13 +- frappe/search/test_full_text_search.py | 4 +- .../energy_point_log/test_energy_point_log.py | 13 +- .../test_energy_point_settings.py | 13 +- frappe/test_runner.py | 230 +------- frappe/tests/__init__.py | 5 + frappe/tests/test_api.py | 6 +- frappe/tests/test_assign.py | 4 +- frappe/tests/test_auth.py | 6 +- frappe/tests/test_background_jobs.py | 4 +- frappe/tests/test_base_document.py | 4 +- frappe/tests/test_boot.py | 6 +- frappe/tests/test_caching.py | 4 +- frappe/tests/test_child_table.py | 4 +- frappe/tests/test_client.py | 4 +- frappe/tests/test_commands.py | 9 +- frappe/tests/test_config.py | 4 +- frappe/tests/test_cors.py | 4 +- frappe/tests/test_dashboard_connections.py | 6 +- frappe/tests/test_db.py | 27 +- frappe/tests/test_db_query.py | 6 +- frappe/tests/test_db_update.py | 4 +- frappe/tests/test_defaults.py | 4 +- frappe/tests/test_deferred_insert.py | 4 +- frappe/tests/test_docstatus.py | 4 +- frappe/tests/test_document.py | 6 +- frappe/tests/test_document_locks.py | 4 +- frappe/tests/test_document_ro_mode.py | 4 +- frappe/tests/test_domainification.py | 4 +- frappe/tests/test_dynamic_links.py | 4 +- frappe/tests/test_email.py | 10 +- frappe/tests/test_exporter_fixtures.py | 4 +- frappe/tests/test_fixture_import.py | 4 +- frappe/tests/test_fmt_datetime.py | 4 +- frappe/tests/test_fmt_money.py | 4 +- frappe/tests/test_form_load.py | 4 +- frappe/tests/test_formatter.py | 4 +- frappe/tests/test_frappe_client.py | 4 +- frappe/tests/test_geo_ip.py | 4 +- frappe/tests/test_global_search.py | 6 +- frappe/tests/test_goal.py | 6 +- frappe/tests/test_hooks.py | 6 +- frappe/tests/test_linked_with.py | 4 +- frappe/tests/test_listview.py | 4 +- frappe/tests/test_model_utils.py | 4 +- frappe/tests/test_modules.py | 4 +- frappe/tests/test_monitor.py | 4 +- frappe/tests/test_naming.py | 6 +- frappe/tests/test_nestedset.py | 4 +- frappe/tests/test_non_nullable_docfield.py | 4 +- frappe/tests/test_oauth20.py | 6 +- frappe/tests/test_password.py | 4 +- frappe/tests/test_patches.py | 6 +- frappe/tests/test_pdf.py | 4 +- frappe/tests/test_perf.py | 4 +- frappe/tests/test_permissions.py | 6 +- frappe/tests/test_printview.py | 4 +- frappe/tests/test_query.py | 4 +- frappe/tests/test_query_builder.py | 14 +- frappe/tests/test_query_report.py | 4 +- frappe/tests/test_rate_limiter.py | 4 +- frappe/tests/test_rating.py | 4 +- frappe/tests/test_recorder.py | 9 +- frappe/tests/test_redis.py | 4 +- frappe/tests/test_rename_doc.py | 4 +- frappe/tests/test_reportview.py | 4 +- frappe/tests/test_safe_exec.py | 6 +- frappe/tests/test_scheduler.py | 4 +- frappe/tests/test_search.py | 4 +- frappe/tests/test_seen.py | 4 +- frappe/tests/test_sequence.py | 4 +- frappe/tests/test_sitemap.py | 6 +- frappe/tests/test_test_utils.py | 8 +- frappe/tests/test_translate.py | 4 +- frappe/tests/test_twofactor.py | 4 +- frappe/tests/test_utils.py | 66 +-- frappe/tests/test_virtual_doctype.py | 4 +- frappe/tests/test_webform.py | 4 +- frappe/tests/test_website.py | 4 +- frappe/tests/tests_geo_utils.py | 4 +- frappe/tests/utils.py | 514 +++++++++++++----- .../test_about_us_settings.py | 13 +- .../blog_category/test_blog_category.py | 13 +- .../doctype/blog_post/test_blog_post.py | 13 +- .../blog_settings/test_blog_settings.py | 13 +- frappe/website/doctype/color/test_color.py | 13 +- .../discussion_reply/test_discussion_reply.py | 13 +- .../discussion_topic/test_discussion_topic.py | 13 +- .../doctype/help_article/test_help_article.py | 13 +- .../help_category/test_help_category.py | 13 +- .../test_personal_data_deletion_request.py | 13 +- .../test_personal_data_download_request.py | 13 +- .../portal_settings/test_portal_settings.py | 13 +- .../doctype/utm_campaign/test_utm_campaign.py | 13 +- .../doctype/utm_medium/test_utm_medium.py | 13 +- .../doctype/utm_source/test_utm_source.py | 13 +- .../website/doctype/web_form/test_web_form.py | 13 +- .../website/doctype/web_page/test_web_page.py | 13 +- .../web_page_view/test_web_page_view.py | 13 +- .../doctype/web_template/test_web_template.py | 13 +- .../test_web_template_field.py | 13 +- .../test_website_route_meta.py | 13 +- .../website_settings/test_website_settings.py | 13 +- .../website_sidebar/test_website_sidebar.py | 13 +- .../test_website_slideshow.py | 13 +- .../website_theme/test_website_theme.py | 13 +- .../doctype/workflow/test_workflow.py | 15 +- .../workflow_action/test_workflow_action.py | 13 +- 261 files changed, 2586 insertions(+), 960 deletions(-) diff --git a/frappe/automation/doctype/assignment_rule/test_assignment_rule.py b/frappe/automation/doctype/assignment_rule/test_assignment_rule.py index 530d45163d..08a9cdc62b 100644 --- a/frappe/automation/doctype/assignment_rule/test_assignment_rule.py +++ b/frappe/automation/doctype/assignment_rule/test_assignment_rule.py @@ -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() diff --git a/frappe/automation/doctype/auto_repeat/test_auto_repeat.py b/frappe/automation/doctype/auto_repeat/test_auto_repeat.py index b6ef8301fb..f5b93a8cc7 100644 --- a/frappe/automation/doctype/auto_repeat/test_auto_repeat.py +++ b/frappe/automation/doctype/auto_repeat/test_auto_repeat.py @@ -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() diff --git a/frappe/automation/doctype/milestone/test_milestone.py b/frappe/automation/doctype/milestone/test_milestone.py index 5348479809..6249d9082a 100644 --- a/frappe/automation/doctype/milestone/test_milestone.py +++ b/frappe/automation/doctype/milestone/test_milestone.py @@ -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 diff --git a/frappe/automation/doctype/milestone_tracker/test_milestone_tracker.py b/frappe/automation/doctype/milestone_tracker/test_milestone_tracker.py index aff6a4863a..a7a9cbaacf 100644 --- a/frappe/automation/doctype/milestone_tracker/test_milestone_tracker.py +++ b/frappe/automation/doctype/milestone_tracker/test_milestone_tracker.py @@ -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") diff --git a/frappe/automation/doctype/reminder/test_reminder.py b/frappe/automation/doctype/reminder/test_reminder.py index 8085cf876c..11211a13df 100644 --- a/frappe/automation/doctype/reminder/test_reminder.py +++ b/frappe/automation/doctype/reminder/test_reminder.py @@ -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" diff --git a/frappe/contacts/doctype/address/test_address.py b/frappe/contacts/doctype/address/test_address.py index ecb95f9e0c..001dd7221f 100644 --- a/frappe/contacts/doctype/address/test_address.py +++ b/frappe/contacts/doctype/address/test_address.py @@ -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() diff --git a/frappe/contacts/doctype/address_template/test_address_template.py b/frappe/contacts/doctype/address_template/test_address_template.py index 80c4ee73ac..8aa97b3490 100644 --- a/frappe/contacts/doctype/address_template/test_address_template.py +++ b/frappe/contacts/doctype/address_template/test_address_template.py @@ -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"}) diff --git a/frappe/contacts/doctype/contact/test_contact.py b/frappe/contacts/doctype/contact/test_contact.py index f203983309..bcb9cf7a03 100644 --- a/frappe/contacts/doctype/contact/test_contact.py +++ b/frappe/contacts/doctype/contact/test_contact.py @@ -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}, diff --git a/frappe/contacts/doctype/gender/test_gender.py b/frappe/contacts/doctype/gender/test_gender.py index 1b428521b7..6ed4074186 100644 --- a/frappe/contacts/doctype/gender/test_gender.py +++ b/frappe/contacts/doctype/gender/test_gender.py @@ -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 diff --git a/frappe/contacts/doctype/salutation/test_salutation.py b/frappe/contacts/doctype/salutation/test_salutation.py index a1d9e044a0..ffc2cb1d62 100644 --- a/frappe/contacts/doctype/salutation/test_salutation.py +++ b/frappe/contacts/doctype/salutation/test_salutation.py @@ -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 diff --git a/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py b/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py index fe76d28c06..800722ffc3 100644 --- a/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py +++ b/frappe/contacts/report/addresses_and_contacts/test_addresses_and_contacts.py @@ -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] diff --git a/frappe/core/doctype/access_log/test_access_log.py b/frappe/core/doctype/access_log/test_access_log.py index b3432d60bf..118c3d5eca 100644 --- a/frappe/core/doctype/access_log/test_access_log.py +++ b/frappe/core/doctype/access_log/test_access_log.py @@ -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) diff --git a/frappe/core/doctype/activity_log/test_activity_log.py b/frappe/core/doctype/activity_log/test_activity_log.py index d20ca7301d..357cb2ebf1 100644 --- a/frappe/core/doctype/activity_log/test_activity_log.py +++ b/frappe/core/doctype/activity_log/test_activity_log.py @@ -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") diff --git a/frappe/core/doctype/audit_trail/test_audit_trail.py b/frappe/core/doctype/audit_trail/test_audit_trail.py index c5f195a9f6..dcdce5a93a 100644 --- a/frappe/core/doctype/audit_trail/test_audit_trail.py +++ b/frappe/core/doctype/audit_trail/test_audit_trail.py @@ -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() diff --git a/frappe/core/doctype/comment/test_comment.py b/frappe/core/doctype/comment/test_comment.py index 12251718e8..96f18f6c74 100644 --- a/frappe/core/doctype/comment/test_comment.py +++ b/frappe/core/doctype/comment/test_comment.py @@ -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"): diff --git a/frappe/core/doctype/communication/test_communication.py b/frappe/core/doctype/communication/test_communication.py index 4474168c14..6fbd0347c6 100644 --- a/frappe/core/doctype/communication/test_communication.py +++ b/frappe/core/doctype/communication/test_communication.py @@ -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 ", @@ -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 []) diff --git a/frappe/core/doctype/custom_docperm/test_custom_docperm.py b/frappe/core/doctype/custom_docperm/test_custom_docperm.py index bc113f1f8f..b4b6bd1eb2 100644 --- a/frappe/core/doctype/custom_docperm/test_custom_docperm.py +++ b/frappe/core/doctype/custom_docperm/test_custom_docperm.py @@ -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 diff --git a/frappe/core/doctype/custom_role/test_custom_role.py b/frappe/core/doctype/custom_role/test_custom_role.py index c81d70d3b5..2f6677fa30 100644 --- a/frappe/core/doctype/custom_role/test_custom_role.py +++ b/frappe/core/doctype/custom_role/test_custom_role.py @@ -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 diff --git a/frappe/core/doctype/data_export/test_data_exporter.py b/frappe/core/doctype/data_export/test_data_exporter.py index 2f580e4a63..90379cfb2f 100644 --- a/frappe/core/doctype/data_export/test_data_exporter.py +++ b/frappe/core/doctype/data_export/test_data_exporter.py @@ -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" diff --git a/frappe/core/doctype/data_import/test_data_import.py b/frappe/core/doctype/data_import/test_data_import.py index 10f8098b2b..9dade7f4ab 100644 --- a/frappe/core/doctype/data_import/test_data_import.py +++ b/frappe/core/doctype/data_import/test_data_import.py @@ -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 diff --git a/frappe/core/doctype/data_import/test_exporter.py b/frappe/core/doctype/data_import/test_exporter.py index cd7f91d079..ac782d95df 100644 --- a/frappe/core/doctype/data_import/test_exporter.py +++ b/frappe/core/doctype/data_import/test_exporter.py @@ -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) diff --git a/frappe/core/doctype/data_import/test_importer.py b/frappe/core/doctype/data_import/test_importer.py index 8e7ae548ab..74aab68867 100644 --- a/frappe/core/doctype/data_import/test_importer.py +++ b/frappe/core/doctype/data_import/test_importer.py @@ -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() diff --git a/frappe/core/doctype/data_import_log/test_data_import_log.py b/frappe/core/doctype/data_import_log/test_data_import_log.py index 6db1b87b9b..0a75c3eb05 100644 --- a/frappe/core/doctype/data_import_log/test_data_import_log.py +++ b/frappe/core/doctype/data_import_log/test_data_import_log.py @@ -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 diff --git a/frappe/core/doctype/deleted_document/test_deleted_document.py b/frappe/core/doctype/deleted_document/test_deleted_document.py index 28d494556f..ac7ed7ab47 100644 --- a/frappe/core/doctype/deleted_document/test_deleted_document.py +++ b/frappe/core/doctype/deleted_document/test_deleted_document.py @@ -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 diff --git a/frappe/core/doctype/docshare/test_docshare.py b/frappe/core/doctype/docshare/test_docshare.py index 9edf78405f..48dcf87e54 100644 --- a/frappe/core/doctype/docshare/test_docshare.py +++ b/frappe/core/doctype/docshare/test_docshare.py @@ -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, diff --git a/frappe/core/doctype/doctype/boilerplate/test_controller._py b/frappe/core/doctype/doctype/boilerplate/test_controller._py index 83a38c493d..550d26ad38 100644 --- a/frappe/core/doctype/doctype/boilerplate/test_controller._py +++ b/frappe/core/doctype/doctype/boilerplate/test_controller._py @@ -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 diff --git a/frappe/core/doctype/doctype/test_doctype.py b/frappe/core/doctype/doctype/test_doctype.py index dc07f274ce..93505b393a 100644 --- a/frappe/core/doctype/doctype/test_doctype.py +++ b/frappe/core/doctype/doctype/test_doctype.py @@ -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() diff --git a/frappe/core/doctype/document_naming_rule/test_document_naming_rule.py b/frappe/core/doctype/document_naming_rule/test_document_naming_rule.py index 0747b97025..69717a4eab 100644 --- a/frappe/core/doctype/document_naming_rule/test_document_naming_rule.py +++ b/frappe/core/doctype/document_naming_rule/test_document_naming_rule.py @@ -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 diff --git a/frappe/core/doctype/document_naming_rule_condition/test_document_naming_rule_condition.py b/frappe/core/doctype/document_naming_rule_condition/test_document_naming_rule_condition.py index edf52fc0c4..2588217cec 100644 --- a/frappe/core/doctype/document_naming_rule_condition/test_document_naming_rule_condition.py +++ b/frappe/core/doctype/document_naming_rule_condition/test_document_naming_rule_condition.py @@ -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 diff --git a/frappe/core/doctype/document_naming_settings/test_document_naming_settings.py b/frappe/core/doctype/document_naming_settings/test_document_naming_settings.py index 237d8108c9..3192e8f487 100644 --- a/frappe/core/doctype/document_naming_settings/test_document_naming_settings.py +++ b/frappe/core/doctype/document_naming_settings/test_document_naming_settings.py @@ -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() diff --git a/frappe/core/doctype/document_share_key/test_document_share_key.py b/frappe/core/doctype/document_share_key/test_document_share_key.py index 23f91157e6..0b00b79146 100644 --- a/frappe/core/doctype/document_share_key/test_document_share_key.py +++ b/frappe/core/doctype/document_share_key/test_document_share_key.py @@ -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 diff --git a/frappe/core/doctype/domain/test_domain.py b/frappe/core/doctype/domain/test_domain.py index 92540cda6b..99b7c0e320 100644 --- a/frappe/core/doctype/domain/test_domain.py +++ b/frappe/core/doctype/domain/test_domain.py @@ -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 diff --git a/frappe/core/doctype/error_log/test_error_log.py b/frappe/core/doctype/error_log/test_error_log.py index 98c87dda52..d56a7ef761 100644 --- a/frappe/core/doctype/error_log/test_error_log.py +++ b/frappe/core/doctype/error_log/test_error_log.py @@ -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: diff --git a/frappe/core/doctype/file/test_file.py b/frappe/core/doctype/file/test_file.py index 57159fa48d..a9929a4719 100644 --- a/frappe/core/doctype/file/test_file.py +++ b/frappe/core/doctype/file/test_file.py @@ -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( diff --git a/frappe/core/doctype/installed_applications/test_installed_applications.py b/frappe/core/doctype/installed_applications/test_installed_applications.py index 1ee1c99b86..13315bc362 100644 --- a/frappe/core/doctype/installed_applications/test_installed_applications.py +++ b/frappe/core/doctype/installed_applications/test_installed_applications.py @@ -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, []) diff --git a/frappe/core/doctype/language/test_language.py b/frappe/core/doctype/language/test_language.py index 1f1e9cb913..bb65991191 100644 --- a/frappe/core/doctype/language/test_language.py +++ b/frappe/core/doctype/language/test_language.py @@ -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 diff --git a/frappe/core/doctype/log_setting_user/test_log_setting_user.py b/frappe/core/doctype/log_setting_user/test_log_setting_user.py index 556dc36dc9..0296baded9 100644 --- a/frappe/core/doctype/log_setting_user/test_log_setting_user.py +++ b/frappe/core/doctype/log_setting_user/test_log_setting_user.py @@ -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 diff --git a/frappe/core/doctype/log_settings/test_log_settings.py b/frappe/core/doctype/log_settings/test_log_settings.py index edee098553..ed3f9a2a97 100644 --- a/frappe/core/doctype/log_settings/test_log_settings.py +++ b/frappe/core/doctype/log_settings/test_log_settings.py @@ -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() diff --git a/frappe/core/doctype/module_def/test_module_def.py b/frappe/core/doctype/module_def/test_module_def.py index e44741c894..83c34ebc40 100644 --- a/frappe/core/doctype/module_def/test_module_def.py +++ b/frappe/core/doctype/module_def/test_module_def.py @@ -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 diff --git a/frappe/core/doctype/module_profile/test_module_profile.py b/frappe/core/doctype/module_profile/test_module_profile.py index a92adb0e74..8f7a42e200 100644 --- a/frappe/core/doctype/module_profile/test_module_profile.py +++ b/frappe/core/doctype/module_profile/test_module_profile.py @@ -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( diff --git a/frappe/core/doctype/navbar_item/test_navbar_item.py b/frappe/core/doctype/navbar_item/test_navbar_item.py index 7ad92a3ae8..162438e8c2 100644 --- a/frappe/core/doctype/navbar_item/test_navbar_item.py +++ b/frappe/core/doctype/navbar_item/test_navbar_item.py @@ -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 diff --git a/frappe/core/doctype/navbar_settings/test_navbar_settings.py b/frappe/core/doctype/navbar_settings/test_navbar_settings.py index f6c2cf69cd..15bbba386e 100644 --- a/frappe/core/doctype/navbar_settings/test_navbar_settings.py +++ b/frappe/core/doctype/navbar_settings/test_navbar_settings.py @@ -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 diff --git a/frappe/core/doctype/package/test_package.py b/frappe/core/doctype/package/test_package.py index 25c5187701..5915fdc6d0 100644 --- a/frappe/core/doctype/package/test_package.py +++ b/frappe/core/doctype/package/test_package.py @@ -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() diff --git a/frappe/core/doctype/package_import/test_package_import.py b/frappe/core/doctype/package_import/test_package_import.py index e4bb3d6715..260116cfcc 100644 --- a/frappe/core/doctype/package_import/test_package_import.py +++ b/frappe/core/doctype/package_import/test_package_import.py @@ -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 diff --git a/frappe/core/doctype/package_release/test_package_release.py b/frappe/core/doctype/package_release/test_package_release.py index 8cea4d0aff..f40e0c2277 100644 --- a/frappe/core/doctype/package_release/test_package_release.py +++ b/frappe/core/doctype/package_release/test_package_release.py @@ -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 diff --git a/frappe/core/doctype/page/test_page.py b/frappe/core/doctype/page/test_page.py index 82208be1c1..f9a63e867c 100644 --- a/frappe/core/doctype/page/test_page.py +++ b/frappe/core/doctype/page/test_page.py @@ -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, diff --git a/frappe/core/doctype/patch_log/test_patch_log.py b/frappe/core/doctype/patch_log/test_patch_log.py index 849c3b30a2..d51de16316 100644 --- a/frappe/core/doctype/patch_log/test_patch_log.py +++ b/frappe/core/doctype/patch_log/test_patch_log.py @@ -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 diff --git a/frappe/core/doctype/permission_inspector/test_permission_inspector.py b/frappe/core/doctype/permission_inspector/test_permission_inspector.py index cc726fb4f6..68a7107cd3 100644 --- a/frappe/core/doctype/permission_inspector/test_permission_inspector.py +++ b/frappe/core/doctype/permission_inspector/test_permission_inspector.py @@ -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 diff --git a/frappe/core/doctype/permission_log/test_permission_log.py b/frappe/core/doctype/permission_log/test_permission_log.py index 46d1ad71a5..282c0d99df 100644 --- a/frappe/core/doctype/permission_log/test_permission_log.py +++ b/frappe/core/doctype/permission_log/test_permission_log.py @@ -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 diff --git a/frappe/core/doctype/prepared_report/test_prepared_report.py b/frappe/core/doctype/prepared_report/test_prepared_report.py index dbd1294cbb..0307eb5ebf 100644 --- a/frappe/core/doctype/prepared_report/test_prepared_report.py +++ b/frappe/core/doctype/prepared_report/test_prepared_report.py @@ -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"): diff --git a/frappe/core/doctype/recorder/test_recorder.py b/frappe/core/doctype/recorder/test_recorder.py index 3a35925c75..3118014d72 100644 --- a/frappe/core/doctype/recorder/test_recorder.py +++ b/frappe/core/doctype/recorder/test_recorder.py @@ -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( diff --git a/frappe/core/doctype/recorder_query/test_recorder_query.py b/frappe/core/doctype/recorder_query/test_recorder_query.py index a21fdcef08..223fb2d8cb 100644 --- a/frappe/core/doctype/recorder_query/test_recorder_query.py +++ b/frappe/core/doctype/recorder_query/test_recorder_query.py @@ -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 diff --git a/frappe/core/doctype/report/test_report.py b/frappe/core/doctype/report/test_report.py index b22f4b491c..d9166e0d6e 100644 --- a/frappe/core/doctype/report/test_report.py +++ b/frappe/core/doctype/report/test_report.py @@ -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() diff --git a/frappe/core/doctype/role/test_role.py b/frappe/core/doctype/role/test_role.py index 1ab5a29f39..5a0bfb351a 100644 --- a/frappe/core/doctype/role/test_role.py +++ b/frappe/core/doctype/role/test_role.py @@ -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") diff --git a/frappe/core/doctype/role_permission_for_page_and_report/test_role_permission_for_page_and_report.py b/frappe/core/doctype/role_permission_for_page_and_report/test_role_permission_for_page_and_report.py index b05da325e6..3d0f57a355 100644 --- a/frappe/core/doctype/role_permission_for_page_and_report/test_role_permission_for_page_and_report.py +++ b/frappe/core/doctype/role_permission_for_page_and_report/test_role_permission_for_page_and_report.py @@ -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 diff --git a/frappe/core/doctype/role_profile/test_role_profile.py b/frappe/core/doctype/role_profile/test_role_profile.py index 4fe78f15e3..fe0575549f 100644 --- a/frappe/core/doctype/role_profile/test_role_profile.py +++ b/frappe/core/doctype/role_profile/test_role_profile.py @@ -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() diff --git a/frappe/core/doctype/role_replication/test_role_replication.py b/frappe/core/doctype/role_replication/test_role_replication.py index f315a06ff1..5f21597646 100644 --- a/frappe/core/doctype/role_replication/test_role_replication.py +++ b/frappe/core/doctype/role_replication/test_role_replication.py @@ -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 diff --git a/frappe/core/doctype/rq_job/test_rq_job.py b/frappe/core/doctype/rq_job/test_rq_job.py index b9a76ad505..d1250630fd 100644 --- a/frappe/core/doctype/rq_job/test_rq_job.py +++ b/frappe/core/doctype/rq_job/test_rq_job.py @@ -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): diff --git a/frappe/core/doctype/rq_worker/test_rq_worker.py b/frappe/core/doctype/rq_worker/test_rq_worker.py index 14c2b29de7..a4c8fdb4c9 100644 --- a/frappe/core/doctype/rq_worker/test_rq_worker.py +++ b/frappe/core/doctype/rq_worker/test_rq_worker.py @@ -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) diff --git a/frappe/core/doctype/scheduled_job_log/test_scheduled_job_log.py b/frappe/core/doctype/scheduled_job_log/test_scheduled_job_log.py index 6fd187b4e4..86df558726 100644 --- a/frappe/core/doctype/scheduled_job_log/test_scheduled_job_log.py +++ b/frappe/core/doctype/scheduled_job_log/test_scheduled_job_log.py @@ -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 diff --git a/frappe/core/doctype/scheduled_job_type/test_scheduled_job_type.py b/frappe/core/doctype/scheduled_job_type/test_scheduled_job_type.py index efa0be9cd2..e00f0173bb 100644 --- a/frappe/core/doctype/scheduled_job_type/test_scheduled_job_type.py +++ b/frappe/core/doctype/scheduled_job_type/test_scheduled_job_type.py @@ -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") diff --git a/frappe/core/doctype/server_script/test_server_script.py b/frappe/core/doctype/server_script/test_server_script.py index a1815a2daa..60310f4628 100644 --- a/frappe/core/doctype/server_script/test_server_script.py +++ b/frappe/core/doctype/server_script/test_server_script.py @@ -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() diff --git a/frappe/core/doctype/session_default_settings/test_session_default_settings.py b/frappe/core/doctype/session_default_settings/test_session_default_settings.py index 9d1800bc39..471584ab77 100644 --- a/frappe/core/doctype/session_default_settings/test_session_default_settings.py +++ b/frappe/core/doctype/session_default_settings/test_session_default_settings.py @@ -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") diff --git a/frappe/core/doctype/sms_settings/test_sms_settings.py b/frappe/core/doctype/sms_settings/test_sms_settings.py index 56cbe9b163..43d284acfc 100644 --- a/frappe/core/doctype/sms_settings/test_sms_settings.py +++ b/frappe/core/doctype/sms_settings/test_sms_settings.py @@ -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 diff --git a/frappe/core/doctype/submission_queue/test_submission_queue.py b/frappe/core/doctype/submission_queue/test_submission_queue.py index c057bd22e1..91ea2aa3c8 100644 --- a/frappe/core/doctype/submission_queue/test_submission_queue.py +++ b/frappe/core/doctype/submission_queue/test_submission_queue.py @@ -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) diff --git a/frappe/core/doctype/system_settings/test_system_settings.py b/frappe/core/doctype/system_settings/test_system_settings.py index a876e8301d..706191fd8a 100644 --- a/frappe/core/doctype/system_settings/test_system_settings.py +++ b/frappe/core/doctype/system_settings/test_system_settings.py @@ -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 diff --git a/frappe/core/doctype/transaction_log/test_transaction_log.py b/frappe/core/doctype/transaction_log/test_transaction_log.py index 0a76e5ac65..762b3fe280 100644 --- a/frappe/core/doctype/transaction_log/test_transaction_log.py +++ b/frappe/core/doctype/transaction_log/test_transaction_log.py @@ -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( { diff --git a/frappe/core/doctype/translation/test_translation.py b/frappe/core/doctype/translation/test_translation.py index 74862aa935..676fdbee37 100644 --- a/frappe/core/doctype/translation/test_translation.py +++ b/frappe/core/doctype/translation/test_translation.py @@ -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") diff --git a/frappe/core/doctype/user/test_user.py b/frappe/core/doctype/user/test_user.py index d9cc1d20c7..85cc085e58 100644 --- a/frappe/core/doctype/user/test_user.py +++ b/frappe/core/doctype/user/test_user.py @@ -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") diff --git a/frappe/core/doctype/user_group/test_user_group.py b/frappe/core/doctype/user_group/test_user_group.py index 79e013672d..e146320957 100644 --- a/frappe/core/doctype/user_group/test_user_group.py +++ b/frappe/core/doctype/user_group/test_user_group.py @@ -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 diff --git a/frappe/core/doctype/user_group_member/test_user_group_member.py b/frappe/core/doctype/user_group_member/test_user_group_member.py index a2eb5c7bfc..71bff265c5 100644 --- a/frappe/core/doctype/user_group_member/test_user_group_member.py +++ b/frappe/core/doctype/user_group_member/test_user_group_member.py @@ -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 diff --git a/frappe/core/doctype/user_permission/test_user_permission.py b/frappe/core/doctype/user_permission/test_user_permission.py index 3e8d677b04..1c5862dce5 100644 --- a/frappe/core/doctype/user_permission/test_user_permission.py +++ b/frappe/core/doctype/user_permission/test_user_permission.py @@ -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", diff --git a/frappe/core/doctype/user_type/test_user_type.py b/frappe/core/doctype/user_type/test_user_type.py index 08ba0ceaab..bba1c37f60 100644 --- a/frappe/core/doctype/user_type/test_user_type.py +++ b/frappe/core/doctype/user_type/test_user_type.py @@ -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() diff --git a/frappe/core/doctype/version/test_version.py b/frappe/core/doctype/version/test_version.py index ce8e0e8b89..f57210f46f 100644 --- a/frappe/core/doctype/version/test_version.py +++ b/frappe/core/doctype/version/test_version.py @@ -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) diff --git a/frappe/core/doctype/view_log/test_view_log.py b/frappe/core/doctype/view_log/test_view_log.py index d1596d84a4..ad64a1a655 100644 --- a/frappe/core/doctype/view_log/test_view_log.py +++ b/frappe/core/doctype/view_log/test_view_log.py @@ -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") diff --git a/frappe/core/report/database_storage_usage_by_tables/test_database_storage_usage_by_tables.py b/frappe/core/report/database_storage_usage_by_tables/test_database_storage_usage_by_tables.py index e82cbe9caf..c32c86bdd5 100644 --- a/frappe/core/report/database_storage_usage_by_tables/test_database_storage_usage_by_tables.py +++ b/frappe/core/report/database_storage_usage_by_tables/test_database_storage_usage_by_tables.py @@ -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] diff --git a/frappe/custom/doctype/client_script/test_client_script.py b/frappe/custom/doctype/client_script/test_client_script.py index 9b50a3d0b0..d3078f247a 100644 --- a/frappe/custom/doctype/client_script/test_client_script.py +++ b/frappe/custom/doctype/client_script/test_client_script.py @@ -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 diff --git a/frappe/custom/doctype/custom_field/test_custom_field.py b/frappe/custom/doctype/custom_field/test_custom_field.py index e83f413542..7d6f5b8b72 100644 --- a/frappe/custom/doctype/custom_field/test_custom_field.py +++ b/frappe/custom/doctype/custom_field/test_custom_field.py @@ -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( { diff --git a/frappe/custom/doctype/customize_form/test_customize_form.py b/frappe/custom/doctype/customize_form/test_customize_form.py index edf72eaf40..1aac048844 100644 --- a/frappe/custom/doctype/customize_form/test_customize_form.py +++ b/frappe/custom/doctype/customize_form/test_customize_form.py @@ -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( diff --git a/frappe/custom/doctype/doctype_layout/test_doctype_layout.py b/frappe/custom/doctype/doctype_layout/test_doctype_layout.py index c568cd4df7..97a97cd158 100644 --- a/frappe/custom/doctype/doctype_layout/test_doctype_layout.py +++ b/frappe/custom/doctype/doctype_layout/test_doctype_layout.py @@ -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 diff --git a/frappe/custom/doctype/property_setter/test_property_setter.py b/frappe/custom/doctype/property_setter/test_property_setter.py index dc74a69161..878a6ceb9d 100644 --- a/frappe/custom/doctype/property_setter/test_property_setter.py +++ b/frappe/custom/doctype/property_setter/test_property_setter.py @@ -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 diff --git a/frappe/custom/report/audit_system_hooks/test_audit_system_hooks.py b/frappe/custom/report/audit_system_hooks/test_audit_system_hooks.py index cd3edffc77..e943e79b08 100644 --- a/frappe/custom/report/audit_system_hooks/test_audit_system_hooks.py +++ b/frappe/custom/report/audit_system_hooks/test_audit_system_hooks.py @@ -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: diff --git a/frappe/desk/doctype/bulk_update/test_bulk_update.py b/frappe/desk/doctype/bulk_update/test_bulk_update.py index 7611141a0a..09a58d2be9 100644 --- a/frappe/desk/doctype/bulk_update/test_bulk_update.py +++ b/frappe/desk/doctype/bulk_update/test_bulk_update.py @@ -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() diff --git a/frappe/desk/doctype/changelog_feed/test_changelog_feed.py b/frappe/desk/doctype/changelog_feed/test_changelog_feed.py index 9427051f10..7fb856e1fb 100644 --- a/frappe/desk/doctype/changelog_feed/test_changelog_feed.py +++ b/frappe/desk/doctype/changelog_feed/test_changelog_feed.py @@ -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 diff --git a/frappe/desk/doctype/console_log/test_console_log.py b/frappe/desk/doctype/console_log/test_console_log.py index 9ae8d1f1e8..7370da48ac 100644 --- a/frappe/desk/doctype/console_log/test_console_log.py +++ b/frappe/desk/doctype/console_log/test_console_log.py @@ -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 diff --git a/frappe/desk/doctype/custom_html_block/test_custom_html_block.py b/frappe/desk/doctype/custom_html_block/test_custom_html_block.py index fbef9af45b..d6d8c0181d 100644 --- a/frappe/desk/doctype/custom_html_block/test_custom_html_block.py +++ b/frappe/desk/doctype/custom_html_block/test_custom_html_block.py @@ -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 diff --git a/frappe/desk/doctype/dashboard/test_dashboard.py b/frappe/desk/doctype/dashboard/test_dashboard.py index 26c93f2bf8..81d347730b 100644 --- a/frappe/desk/doctype/dashboard/test_dashboard.py +++ b/frappe/desk/doctype/dashboard/test_dashboard.py @@ -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): diff --git a/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py b/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py index 7afe2258d8..7d877a5280 100644 --- a/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py +++ b/frappe/desk/doctype/dashboard_chart/test_dashboard_chart.py @@ -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")) diff --git a/frappe/desk/doctype/dashboard_chart_source/test_dashboard_chart_source.py b/frappe/desk/doctype/dashboard_chart_source/test_dashboard_chart_source.py index 5b4c114287..3512b6ba74 100644 --- a/frappe/desk/doctype/dashboard_chart_source/test_dashboard_chart_source.py +++ b/frappe/desk/doctype/dashboard_chart_source/test_dashboard_chart_source.py @@ -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 diff --git a/frappe/desk/doctype/event/test_event.py b/frappe/desk/doctype/event/test_event.py index 0680167329..783646d303 100644 --- a/frappe/desk/doctype/event/test_event.py +++ b/frappe/desk/doctype/event/test_event.py @@ -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) diff --git a/frappe/desk/doctype/form_tour/test_form_tour.py b/frappe/desk/doctype/form_tour/test_form_tour.py index 3fdcdf95a6..65dfbe9187 100644 --- a/frappe/desk/doctype/form_tour/test_form_tour.py +++ b/frappe/desk/doctype/form_tour/test_form_tour.py @@ -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 diff --git a/frappe/desk/doctype/kanban_board/test_kanban_board.py b/frappe/desk/doctype/kanban_board/test_kanban_board.py index 05cd5723c4..a884606b78 100644 --- a/frappe/desk/doctype/kanban_board/test_kanban_board.py +++ b/frappe/desk/doctype/kanban_board/test_kanban_board.py @@ -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 diff --git a/frappe/desk/doctype/list_view_settings/test_list_view_settings.py b/frappe/desk/doctype/list_view_settings/test_list_view_settings.py index 8e27385230..bed90fb987 100644 --- a/frappe/desk/doctype/list_view_settings/test_list_view_settings.py +++ b/frappe/desk/doctype/list_view_settings/test_list_view_settings.py @@ -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 diff --git a/frappe/desk/doctype/module_onboarding/test_module_onboarding.py b/frappe/desk/doctype/module_onboarding/test_module_onboarding.py index e84a5c4d2b..cc27d870ed 100644 --- a/frappe/desk/doctype/module_onboarding/test_module_onboarding.py +++ b/frappe/desk/doctype/module_onboarding/test_module_onboarding.py @@ -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 diff --git a/frappe/desk/doctype/note/test_note.py b/frappe/desk/doctype/note/test_note.py index 94ab270e71..d588ee643d 100644 --- a/frappe/desk/doctype/note/test_note.py +++ b/frappe/desk/doctype/note/test_note.py @@ -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") diff --git a/frappe/desk/doctype/notification_log/test_notification_log.py b/frappe/desk/doctype/notification_log/test_notification_log.py index 4f42038bbf..d75bd59a69 100644 --- a/frappe/desk/doctype/notification_log/test_notification_log.py +++ b/frappe/desk/doctype/notification_log/test_notification_log.py @@ -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() diff --git a/frappe/desk/doctype/notification_settings/test_notification_settings.py b/frappe/desk/doctype/notification_settings/test_notification_settings.py index e88f98443b..acf2d93798 100644 --- a/frappe/desk/doctype/notification_settings/test_notification_settings.py +++ b/frappe/desk/doctype/notification_settings/test_notification_settings.py @@ -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 diff --git a/frappe/desk/doctype/number_card/test_number_card.py b/frappe/desk/doctype/number_card/test_number_card.py index a002b8aad3..dc1a16dc94 100644 --- a/frappe/desk/doctype/number_card/test_number_card.py +++ b/frappe/desk/doctype/number_card/test_number_card.py @@ -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 diff --git a/frappe/desk/doctype/onboarding_permission/test_onboarding_permission.py b/frappe/desk/doctype/onboarding_permission/test_onboarding_permission.py index d82cb3c346..2bac40f723 100644 --- a/frappe/desk/doctype/onboarding_permission/test_onboarding_permission.py +++ b/frappe/desk/doctype/onboarding_permission/test_onboarding_permission.py @@ -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 diff --git a/frappe/desk/doctype/onboarding_step/test_onboarding_step.py b/frappe/desk/doctype/onboarding_step/test_onboarding_step.py index 73b9ab4ac3..b6b78bf2ef 100644 --- a/frappe/desk/doctype/onboarding_step/test_onboarding_step.py +++ b/frappe/desk/doctype/onboarding_step/test_onboarding_step.py @@ -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 diff --git a/frappe/desk/doctype/system_console/test_system_console.py b/frappe/desk/doctype/system_console/test_system_console.py index 08a8b83708..209b84ca3d 100644 --- a/frappe/desk/doctype/system_console/test_system_console.py +++ b/frappe/desk/doctype/system_console/test_system_console.py @@ -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 TestSystemConsole(FrappeTestCase): +class UnitTestSystemConsole(UnitTestCase): + """ + Unit tests for SystemConsole. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSystemConsole(IntegrationTestCase): @classmethod def setUpClass(cls) -> None: cls.enable_safe_exec() diff --git a/frappe/desk/doctype/system_health_report/test_system_health_report.py b/frappe/desk/doctype/system_health_report/test_system_health_report.py index 34d930db31..b4f8ea018c 100644 --- a/frappe/desk/doctype/system_health_report/test_system_health_report.py +++ b/frappe/desk/doctype/system_health_report/test_system_health_report.py @@ -2,9 +2,18 @@ # See license.txt import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestSystemHealthReport(FrappeTestCase): +class UnitTestSystemHealthReport(UnitTestCase): + """ + Unit tests for SystemHealthReport. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSystemHealthReport(IntegrationTestCase): def test_it_works(self): frappe.get_doc("System Health Report") diff --git a/frappe/desk/doctype/tag/test_tag.py b/frappe/desk/doctype/tag/test_tag.py index 0c746e67ac..a009730b17 100644 --- a/frappe/desk/doctype/tag/test_tag.py +++ b/frappe/desk/doctype/tag/test_tag.py @@ -1,10 +1,19 @@ import frappe from frappe.desk.doctype.tag.tag import add_tag from frappe.desk.reportview import get_stats -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestTag(FrappeTestCase): +class UnitTestTag(UnitTestCase): + """ + Unit tests for Tag. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestTag(IntegrationTestCase): def setUp(self) -> None: frappe.db.delete("Tag") frappe.db.sql("UPDATE `tabDocType` set _user_tags=''") diff --git a/frappe/desk/doctype/tag_link/test_tag_link.py b/frappe/desk/doctype/tag_link/test_tag_link.py index 10edb2859e..0a71b780ad 100644 --- a/frappe/desk/doctype/tag_link/test_tag_link.py +++ b/frappe/desk/doctype/tag_link/test_tag_link.py @@ -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 TestTagLink(FrappeTestCase): +class UnitTestTagLink(UnitTestCase): + """ + Unit tests for TagLink. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestTagLink(IntegrationTestCase): pass diff --git a/frappe/desk/doctype/todo/test_todo.py b/frappe/desk/doctype/todo/test_todo.py index 231fc482f0..dab34c4c2b 100644 --- a/frappe/desk/doctype/todo/test_todo.py +++ b/frappe/desk/doctype/todo/test_todo.py @@ -4,12 +4,21 @@ import frappe from frappe.core.doctype.doctype.doctype import clear_permissions_cache from frappe.model.db_query import DatabaseQuery from frappe.permissions import add_permission, reset_perms -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase test_dependencies = ["User"] -class TestToDo(FrappeTestCase): +class UnitTestTodo(UnitTestCase): + """ + Unit tests for Todo. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestToDo(IntegrationTestCase): def test_delete(self): todo = frappe.get_doc(doctype="ToDo", description="test todo", assigned_by="Administrator").insert() diff --git a/frappe/desk/doctype/workspace/test_workspace.py b/frappe/desk/doctype/workspace/test_workspace.py index 4570ab576b..ff2bce69f4 100644 --- a/frappe/desk/doctype/workspace/test_workspace.py +++ b/frappe/desk/doctype/workspace/test_workspace.py @@ -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 TestWorkspace(FrappeTestCase): +class UnitTestWorkspace(UnitTestCase): + """ + Unit tests for Workspace. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWorkspace(IntegrationTestCase): def setUp(self): create_module("Test Module") diff --git a/frappe/desk/doctype/workspace_settings/test_workspace_settings.py b/frappe/desk/doctype/workspace_settings/test_workspace_settings.py index fe639c4d1c..a3c25696b4 100644 --- a/frappe/desk/doctype/workspace_settings/test_workspace_settings.py +++ b/frappe/desk/doctype/workspace_settings/test_workspace_settings.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestWorkspaceSettings(FrappeTestCase): +class UnitTestWorkspaceSettings(UnitTestCase): + """ + Unit tests for WorkspaceSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWorkspaceSettings(IntegrationTestCase): pass diff --git a/frappe/desk/form/test_form.py b/frappe/desk/form/test_form.py index 5028fedf96..1c7a8f0114 100644 --- a/frappe/desk/form/test_form.py +++ b/frappe/desk/form/test_form.py @@ -3,10 +3,10 @@ import frappe from frappe.desk.form.linked_with import get_linked_docs, get_linked_doctypes -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestForm(FrappeTestCase): +class TestForm(IntegrationTestCase): def test_linked_with(self): results = get_linked_docs("Role", "System Manager", linkinfo=get_linked_doctypes("Role")) self.assertTrue("User" in results) diff --git a/frappe/email/doctype/auto_email_report/test_auto_email_report.py b/frappe/email/doctype/auto_email_report/test_auto_email_report.py index 2fb37eafec..aa30c36349 100644 --- a/frappe/email/doctype/auto_email_report/test_auto_email_report.py +++ b/frappe/email/doctype/auto_email_report/test_auto_email_report.py @@ -3,14 +3,23 @@ import json import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import add_to_date, get_link_to_form, today from frappe.utils.data import is_html # test_records = frappe.get_test_records('Auto Email Report') -class TestAutoEmailReport(FrappeTestCase): +class UnitTestAutoEmailReport(UnitTestCase): + """ + Unit tests for AutoEmailReport. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestAutoEmailReport(IntegrationTestCase): def test_auto_email(self): frappe.delete_doc("Auto Email Report", "Permitted Documents For User") diff --git a/frappe/email/doctype/document_follow/test_document_follow.py b/frappe/email/doctype/document_follow/test_document_follow.py index 568879d415..a74b214715 100644 --- a/frappe/email/doctype/document_follow/test_document_follow.py +++ b/frappe/email/doctype/document_follow/test_document_follow.py @@ -11,10 +11,19 @@ from frappe.desk.like import toggle_like from frappe.query_builder import DocType from frappe.query_builder.functions import Cast_ from frappe.share import add as share -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestDocumentFollow(FrappeTestCase): +class UnitTestDocumentFollow(UnitTestCase): + """ + Unit tests for DocumentFollow. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDocumentFollow(IntegrationTestCase): def test_document_follow_version(self): user = get_user() event_doc = get_event() diff --git a/frappe/email/doctype/email_account/test_email_account.py b/frappe/email/doctype/email_account/test_email_account.py index 184fceea73..dbac77d408 100644 --- a/frappe/email/doctype/email_account/test_email_account.py +++ b/frappe/email/doctype/email_account/test_email_account.py @@ -13,10 +13,19 @@ from frappe.desk.form.load import get_attachments from frappe.email.doctype.email_account.email_account import notify_unreplied from frappe.email.email_body import get_message_id from frappe.email.receive import Email, InboundMail, SentEmailInInboxError -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestEmailAccount(FrappeTestCase): +class UnitTestEmailAccount(UnitTestCase): + """ + Unit tests for EmailAccount. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailAccount(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -454,7 +463,7 @@ class TestEmailAccount(FrappeTestCase): email_account.receive() -class TestInboundMail(FrappeTestCase): +class TestInboundMail(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/frappe/email/doctype/email_domain/test_email_domain.py b/frappe/email/doctype/email_domain/test_email_domain.py index 85ba6450b5..6a852d89b1 100644 --- a/frappe/email/doctype/email_domain/test_email_domain.py +++ b/frappe/email/doctype/email_domain/test_email_domain.py @@ -1,13 +1,22 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE import frappe -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("Email Domain") -class TestDomain(FrappeTestCase): +class UnitTestEmailDomain(UnitTestCase): + """ + Unit tests for EmailDomain. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDomain(IntegrationTestCase): def setUp(self): make_test_objects("Email Domain", reset=True) diff --git a/frappe/email/doctype/email_flag_queue/test_email_flag_queue.py b/frappe/email/doctype/email_flag_queue/test_email_flag_queue.py index 0d731c37da..6fdc0a3f0f 100644 --- a/frappe/email/doctype/email_flag_queue/test_email_flag_queue.py +++ b/frappe/email/doctype/email_flag_queue/test_email_flag_queue.py @@ -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('Email Flag Queue') -class TestEmailFlagQueue(FrappeTestCase): +class UnitTestEmailFlagQueue(UnitTestCase): + """ + Unit tests for EmailFlagQueue. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailFlagQueue(IntegrationTestCase): pass diff --git a/frappe/email/doctype/email_group/test_email_group.py b/frappe/email/doctype/email_group/test_email_group.py index fdb36825f5..03566bc881 100644 --- a/frappe/email/doctype/email_group/test_email_group.py +++ b/frappe/email/doctype/email_group/test_email_group.py @@ -1,13 +1,22 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import validate_url # test_records = frappe.get_test_records('Email Group') -class TestEmailGroup(FrappeTestCase): +class UnitTestEmailGroup(UnitTestCase): + """ + Unit tests for EmailGroup. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailGroup(IntegrationTestCase): def test_welcome_url(self): email_group = frappe.new_doc("Email Group") email_group.title = "Test" diff --git a/frappe/email/doctype/email_group_member/test_email_group_member.py b/frappe/email/doctype/email_group_member/test_email_group_member.py index 6432cadf54..cde4e74ae1 100644 --- a/frappe/email/doctype/email_group_member/test_email_group_member.py +++ b/frappe/email/doctype/email_group_member/test_email_group_member.py @@ -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('Email Group Member') -class TestEmailGroupMember(FrappeTestCase): +class UnitTestEmailGroupMember(UnitTestCase): + """ + Unit tests for EmailGroupMember. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailGroupMember(IntegrationTestCase): pass diff --git a/frappe/email/doctype/email_queue/test_email_queue.py b/frappe/email/doctype/email_queue/test_email_queue.py index 4165fa5edc..f2aec558e4 100644 --- a/frappe/email/doctype/email_queue/test_email_queue.py +++ b/frappe/email/doctype/email_queue/test_email_queue.py @@ -4,10 +4,19 @@ import textwrap import frappe from frappe.email.doctype.email_queue.email_queue import SendMailContext, get_email_retry_limit -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestEmailQueue(FrappeTestCase): +class UnitTestEmailQueue(UnitTestCase): + """ + Unit tests for EmailQueue. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailQueue(IntegrationTestCase): def test_email_queue_deletion_based_on_modified_date(self): from frappe.email.doctype.email_queue.email_queue import EmailQueue diff --git a/frappe/email/doctype/email_rule/test_email_rule.py b/frappe/email/doctype/email_rule/test_email_rule.py index 489379451d..cea1928ae7 100644 --- a/frappe/email/doctype/email_rule/test_email_rule.py +++ b/frappe/email/doctype/email_rule/test_email_rule.py @@ -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 TestEmailRule(FrappeTestCase): +class UnitTestEmailRule(UnitTestCase): + """ + Unit tests for EmailRule. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailRule(IntegrationTestCase): pass diff --git a/frappe/email/doctype/email_template/test_email_template.py b/frappe/email/doctype/email_template/test_email_template.py index f2c53647bc..5073e54359 100644 --- a/frappe/email/doctype/email_template/test_email_template.py +++ b/frappe/email/doctype/email_template/test_email_template.py @@ -1,7 +1,16 @@ # Copyright (c) 2018, Frappe Technologies and Contributors # License: MIT. See LICENSE -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestEmailTemplate(FrappeTestCase): +class UnitTestEmailTemplate(UnitTestCase): + """ + Unit tests for EmailTemplate. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailTemplate(IntegrationTestCase): pass diff --git a/frappe/email/doctype/email_unsubscribe/test_email_unsubscribe.py b/frappe/email/doctype/email_unsubscribe/test_email_unsubscribe.py index d0b1731ad9..4355c317a0 100644 --- a/frappe/email/doctype/email_unsubscribe/test_email_unsubscribe.py +++ b/frappe/email/doctype/email_unsubscribe/test_email_unsubscribe.py @@ -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('Email Unsubscribe') -class TestEmailUnsubscribe(FrappeTestCase): +class UnitTestEmailUnsubscribe(UnitTestCase): + """ + Unit tests for EmailUnsubscribe. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEmailUnsubscribe(IntegrationTestCase): pass diff --git a/frappe/email/doctype/newsletter/test_newsletter.py b/frappe/email/doctype/newsletter/test_newsletter.py index 7c355af0f0..c7ee147410 100644 --- a/frappe/email/doctype/newsletter/test_newsletter.py +++ b/frappe/email/doctype/newsletter/test_newsletter.py @@ -15,7 +15,7 @@ from frappe.email.doctype.newsletter.newsletter import ( send_scheduled_email, ) from frappe.email.queue import flush -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import add_days, getdate emails = [ @@ -134,7 +134,7 @@ class TestNewsletterMixin: return newsletter -class TestNewsletter(TestNewsletterMixin, FrappeTestCase): +class TestNewsletter(TestNewsletterMixin, IntegrationTestCase): def test_send(self): self.send_newsletter() diff --git a/frappe/email/doctype/notification/test_notification.py b/frappe/email/doctype/notification/test_notification.py index 304856ca50..986a3ae437 100644 --- a/frappe/email/doctype/notification/test_notification.py +++ b/frappe/email/doctype/notification/test_notification.py @@ -8,7 +8,7 @@ import frappe import frappe.utils import frappe.utils.scheduler from frappe.desk.form import assign_to -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from .notification import trigger_notifications @@ -25,7 +25,16 @@ def get_test_notification(config): frappe.db.commit() -class TestNotification(FrappeTestCase): +class UnitTestNotification(UnitTestCase): + """ + Unit tests for Notification. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestNotification(IntegrationTestCase): def setUp(self): frappe.db.delete("Email Queue") frappe.set_user("test@example.com") @@ -490,7 +499,7 @@ OK # from frappe.utils import add_to_date, now_datetime -# class TestNotificationOffsetRange(FrappeTestCase): +# class TestNotificationOffsetRange(IntegrationTestCase): # def setUp(self): # frappe.set_user("test@example.com") # # Create an event and notification before each test diff --git a/frappe/email/doctype/unhandled_email/test_unhandled_email.py b/frappe/email/doctype/unhandled_email/test_unhandled_email.py index 0d36b6b091..751e094d98 100644 --- a/frappe/email/doctype/unhandled_email/test_unhandled_email.py +++ b/frappe/email/doctype/unhandled_email/test_unhandled_email.py @@ -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('Unhandled Emails') -class TestUnhandledEmail(FrappeTestCase): +class UnitTestUnhandledEmail(UnitTestCase): + """ + Unit tests for UnhandledEmail. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestUnhandledEmail(IntegrationTestCase): pass diff --git a/frappe/email/test_email_attachments.py b/frappe/email/test_email_attachments.py index 9fe8ea6e9b..d298c4182a 100644 --- a/frappe/email/test_email_attachments.py +++ b/frappe/email/test_email_attachments.py @@ -5,7 +5,7 @@ import requests import frappe from frappe.email.receive import InboundMail -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import get_url if TYPE_CHECKING: @@ -32,7 +32,7 @@ YWJjZGVmZ2hpamtsbW5vcF9hdHRhY2htZW50 """.strip() -class TestEmailAttachments(FrappeTestCase): +class TestEmailAttachments(IntegrationTestCase): def test_email_attachment_percent_encoded(self): email_account = frappe._dict({"email_id": "receive@example.com"}) mail = InboundMail(EMAIL_CONTENT, email_account) diff --git a/frappe/email/test_email_body.py b/frappe/email/test_email_body.py index 3db7cd0175..60ff10b84c 100644 --- a/frappe/email/test_email_body.py +++ b/frappe/email/test_email_body.py @@ -14,10 +14,10 @@ from frappe.email.email_body import ( replace_filename_with_cid, ) from frappe.email.receive import Email -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestEmailBody(FrappeTestCase): +class TestEmailBody(IntegrationTestCase): def setUp(self): email_html = """
diff --git a/frappe/email/test_smtp.py b/frappe/email/test_smtp.py index 0495fd8596..8964c48965 100644 --- a/frappe/email/test_smtp.py +++ b/frappe/email/test_smtp.py @@ -4,10 +4,10 @@ import frappe from frappe.email.doctype.email_account.email_account import EmailAccount from frappe.email.smtp import SMTPServer -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestSMTP(FrappeTestCase): +class TestSMTP(IntegrationTestCase): def test_smtp_ssl_session(self): for port in [None, 0, 465, "465"]: make_server(port, 1, 0) diff --git a/frappe/geo/doctype/country/test_country.py b/frappe/geo/doctype/country/test_country.py index cf4590aabc..a58bc900b8 100644 --- a/frappe/geo/doctype/country/test_country.py +++ b/frappe/geo/doctype/country/test_country.py @@ -7,7 +7,7 @@ from frappe.geo.doctype.country.country import ( import_country_and_currency, ) from frappe.geo.doctype.currency.currency import enable_default_currencies -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase test_records = frappe.get_test_records("Country") @@ -22,7 +22,16 @@ def get_table_snapshot(doctype): return data -class TestCountry(FrappeTestCase): +class UnitTestCountry(UnitTestCase): + """ + Unit tests for Country. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestCountry(IntegrationTestCase): def test_bulk_insert_correctness(self): def clear_tables(): frappe.db.delete("Currency") diff --git a/frappe/geo/doctype/currency/test_currency.py b/frappe/geo/doctype/currency/test_currency.py index b02dd4258c..0b37b451f2 100644 --- a/frappe/geo/doctype/currency/test_currency.py +++ b/frappe/geo/doctype/currency/test_currency.py @@ -4,10 +4,19 @@ # pre loaded import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestUser(FrappeTestCase): +class UnitTestCurrency(UnitTestCase): + """ + Unit tests for Currency. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestUser(IntegrationTestCase): def test_default_currency_on_setup(self): usd = frappe.get_doc("Currency", "USD") self.assertDocumentEqual({"enabled": 1, "fraction": "Cent"}, usd) diff --git a/frappe/gettext/extractors/tests/test_javascript.py b/frappe/gettext/extractors/tests/test_javascript.py index 63805954ed..876ea5db14 100644 --- a/frappe/gettext/extractors/tests/test_javascript.py +++ b/frappe/gettext/extractors/tests/test_javascript.py @@ -1,8 +1,8 @@ from frappe.gettext.extractors.javascript import extract_javascript -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestJavaScript(FrappeTestCase): +class TestJavaScript(IntegrationTestCase): def test_extract_javascript(self): code = "let test = `

${__('Test')}

`;" self.assertEqual( diff --git a/frappe/gettext/test_translate.py b/frappe/gettext/test_translate.py index af6eb86d96..5998bac9c9 100644 --- a/frappe/gettext/test_translate.py +++ b/frappe/gettext/test_translate.py @@ -10,10 +10,10 @@ from frappe.gettext.translate import ( write_binary, write_catalog, ) -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestTranslate(FrappeTestCase): +class TestTranslate(IntegrationTestCase): def setUp(self): pass diff --git a/frappe/integrations/doctype/connected_app/test_connected_app.py b/frappe/integrations/doctype/connected_app/test_connected_app.py index 49ed6236ff..2e427793f7 100644 --- a/frappe/integrations/doctype/connected_app/test_connected_app.py +++ b/frappe/integrations/doctype/connected_app/test_connected_app.py @@ -8,7 +8,7 @@ import frappe from frappe.integrations.doctype.social_login_key.test_social_login_key import ( create_or_update_social_login_key, ) -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase def get_user(usr, pwd): @@ -48,7 +48,16 @@ def get_oauth_client(): return oauth_client -class TestConnectedApp(FrappeTestCase): +class UnitTestConnectedApp(UnitTestCase): + """ + Unit tests for ConnectedApp. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestConnectedApp(IntegrationTestCase): def setUp(self): """Set up a Connected App that connects to our own oAuth provider. diff --git a/frappe/integrations/doctype/dropbox_settings/test_dropbox_settings.py b/frappe/integrations/doctype/dropbox_settings/test_dropbox_settings.py index 1c95b130e8..0b56aa98d7 100644 --- a/frappe/integrations/doctype/dropbox_settings/test_dropbox_settings.py +++ b/frappe/integrations/doctype/dropbox_settings/test_dropbox_settings.py @@ -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 TestDropboxSettings(FrappeTestCase): +class UnitTestDropboxSettings(UnitTestCase): + """ + Unit tests for DropboxSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestDropboxSettings(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/geolocation_settings/test_geolocation_settings.py b/frappe/integrations/doctype/geolocation_settings/test_geolocation_settings.py index 90979b2949..cf0c2f7231 100644 --- a/frappe/integrations/doctype/geolocation_settings/test_geolocation_settings.py +++ b/frappe/integrations/doctype/geolocation_settings/test_geolocation_settings.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestGeolocationSettings(FrappeTestCase): +class UnitTestGeolocationSettings(UnitTestCase): + """ + Unit tests for GeolocationSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestGeolocationSettings(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/google_contacts/test_google_contacts.py b/frappe/integrations/doctype/google_contacts/test_google_contacts.py index d7ca08a082..667b568cd1 100644 --- a/frappe/integrations/doctype/google_contacts/test_google_contacts.py +++ b/frappe/integrations/doctype/google_contacts/test_google_contacts.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestGoogleContacts(FrappeTestCase): +class UnitTestGoogleContacts(UnitTestCase): + """ + Unit tests for GoogleContacts. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestGoogleContacts(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/google_drive/test_google_drive.py b/frappe/integrations/doctype/google_drive/test_google_drive.py index 1dd048048c..5d499da680 100644 --- a/frappe/integrations/doctype/google_drive/test_google_drive.py +++ b/frappe/integrations/doctype/google_drive/test_google_drive.py @@ -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 TestGoogleDrive(FrappeTestCase): +class UnitTestGoogleDrive(UnitTestCase): + """ + Unit tests for GoogleDrive. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestGoogleDrive(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/google_settings/test_google_settings.py b/frappe/integrations/doctype/google_settings/test_google_settings.py index 4b705a67f1..dccf03c1c3 100644 --- a/frappe/integrations/doctype/google_settings/test_google_settings.py +++ b/frappe/integrations/doctype/google_settings/test_google_settings.py @@ -2,12 +2,21 @@ # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from .google_settings import get_file_picker_settings -class TestGoogleSettings(FrappeTestCase): +class UnitTestGoogleSettings(UnitTestCase): + """ + Unit tests for GoogleSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestGoogleSettings(IntegrationTestCase): def setUp(self): settings = frappe.get_single("Google Settings") settings.client_id = "test_client_id" diff --git a/frappe/integrations/doctype/integration_request/test_integration_request.py b/frappe/integrations/doctype/integration_request/test_integration_request.py index d80d72fd7a..a218fe0fa8 100644 --- a/frappe/integrations/doctype/integration_request/test_integration_request.py +++ b/frappe/integrations/doctype/integration_request/test_integration_request.py @@ -1,10 +1,19 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase # test_records = frappe.get_test_records('Integration Request') -class TestIntegrationRequest(FrappeTestCase): +class UnitTestIntegrationRequest(UnitTestCase): + """ + Unit tests for IntegrationRequest. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestIntegrationRequest(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/oauth_authorization_code/test_oauth_authorization_code.py b/frappe/integrations/doctype/oauth_authorization_code/test_oauth_authorization_code.py index 775bc0f968..a5824be73f 100644 --- a/frappe/integrations/doctype/oauth_authorization_code/test_oauth_authorization_code.py +++ b/frappe/integrations/doctype/oauth_authorization_code/test_oauth_authorization_code.py @@ -1,10 +1,19 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase # test_records = frappe.get_test_records('OAuth Authorization Code') -class TestOAuthAuthorizationCode(FrappeTestCase): +class UnitTestOauthAuthorizationCode(UnitTestCase): + """ + Unit tests for OauthAuthorizationCode. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestOAuthAuthorizationCode(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/oauth_bearer_token/test_oauth_bearer_token.py b/frappe/integrations/doctype/oauth_bearer_token/test_oauth_bearer_token.py index 84b65893f6..8c5afea9e4 100644 --- a/frappe/integrations/doctype/oauth_bearer_token/test_oauth_bearer_token.py +++ b/frappe/integrations/doctype/oauth_bearer_token/test_oauth_bearer_token.py @@ -1,10 +1,19 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase # test_records = frappe.get_test_records('OAuth Bearer Token') -class TestOAuthBearerToken(FrappeTestCase): +class UnitTestOauthBearerToken(UnitTestCase): + """ + Unit tests for OauthBearerToken. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestOAuthBearerToken(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/oauth_client/test_oauth_client.py b/frappe/integrations/doctype/oauth_client/test_oauth_client.py index 53e7bff40e..8a87464aa9 100644 --- a/frappe/integrations/doctype/oauth_client/test_oauth_client.py +++ b/frappe/integrations/doctype/oauth_client/test_oauth_client.py @@ -1,10 +1,19 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase # test_records = frappe.get_test_records('OAuth Client') -class TestOAuthClient(FrappeTestCase): +class UnitTestOauthClient(UnitTestCase): + """ + Unit tests for OauthClient. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestOAuthClient(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/push_notification_settings/test_push_notification_settings.py b/frappe/integrations/doctype/push_notification_settings/test_push_notification_settings.py index bca569f948..43197862c0 100644 --- a/frappe/integrations/doctype/push_notification_settings/test_push_notification_settings.py +++ b/frappe/integrations/doctype/push_notification_settings/test_push_notification_settings.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestPushNotificationSettings(FrappeTestCase): +class UnitTestPushNotificationSettings(UnitTestCase): + """ + Unit tests for PushNotificationSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPushNotificationSettings(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/s3_backup_settings/test_s3_backup_settings.py b/frappe/integrations/doctype/s3_backup_settings/test_s3_backup_settings.py index add4e7a1b2..8a5688ac8e 100755 --- a/frappe/integrations/doctype/s3_backup_settings/test_s3_backup_settings.py +++ b/frappe/integrations/doctype/s3_backup_settings/test_s3_backup_settings.py @@ -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 TestS3BackupSettings(FrappeTestCase): +class UnitTestS3BackupSettings(UnitTestCase): + """ + Unit tests for S3BackupSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestS3BackupSettings(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/slack_webhook_url/test_slack_webhook_url.py b/frappe/integrations/doctype/slack_webhook_url/test_slack_webhook_url.py index 6697c2a320..62cfed6827 100644 --- a/frappe/integrations/doctype/slack_webhook_url/test_slack_webhook_url.py +++ b/frappe/integrations/doctype/slack_webhook_url/test_slack_webhook_url.py @@ -1,7 +1,16 @@ # Copyright (c) 2018, Frappe Technologies and Contributors # License: MIT. See LICENSE -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestSlackWebhookURL(FrappeTestCase): +class UnitTestSlackWebhookUrl(UnitTestCase): + """ + Unit tests for SlackWebhookUrl. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSlackWebhookURL(IntegrationTestCase): pass diff --git a/frappe/integrations/doctype/social_login_key/test_social_login_key.py b/frappe/integrations/doctype/social_login_key/test_social_login_key.py index 2a32ab8aa1..09e8fbf6c7 100644 --- a/frappe/integrations/doctype/social_login_key/test_social_login_key.py +++ b/frappe/integrations/doctype/social_login_key/test_social_login_key.py @@ -7,14 +7,23 @@ from rauth import OAuth2Service import frappe from frappe.auth import CookieManager, LoginManager from frappe.integrations.doctype.social_login_key.social_login_key import BaseUrlNotSetError -from frappe.tests.utils import FrappeTestCase, change_settings +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils import set_request from frappe.utils.oauth import login_via_oauth2 TEST_GITHUB_USER = "githublogin@example.com" -class TestSocialLoginKey(FrappeTestCase): +class UnitTestSocialLoginKey(UnitTestCase): + """ + Unit tests for SocialLoginKey. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestSocialLoginKey(IntegrationTestCase): def setUp(self) -> None: frappe.set_user("Administrator") frappe.delete_doc("User", TEST_GITHUB_USER, force=True) @@ -72,7 +81,7 @@ class TestSocialLoginKey(FrappeTestCase): login_via_oauth2("github", "iwriu", {"token": "ewrwerwer"}) self.assertEqual(frappe.session.user, "Guest") - @change_settings("Website Settings", disable_signup=1) + @IntegrationTestCase.change_settings("Website Settings", disable_signup=1) def test_force_enabled_signups(self): """Social login key can override website settings for disabled signups.""" key = github_social_login_setup() diff --git a/frappe/integrations/doctype/token_cache/test_token_cache.py b/frappe/integrations/doctype/token_cache/test_token_cache.py index 44b58fb238..7d918c5d85 100644 --- a/frappe/integrations/doctype/token_cache/test_token_cache.py +++ b/frappe/integrations/doctype/token_cache/test_token_cache.py @@ -1,12 +1,21 @@ # 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 test_dependencies = ["User", "Connected App", "Token Cache"] -class TestTokenCache(FrappeTestCase): +class UnitTestTokenCache(UnitTestCase): + """ + Unit tests for TokenCache. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestTokenCache(IntegrationTestCase): def setUp(self): self.token_cache = frappe.get_last_doc("Token Cache") self.token_cache.update({"connected_app": frappe.get_last_doc("Connected App").name}) diff --git a/frappe/integrations/doctype/webhook/test_webhook.py b/frappe/integrations/doctype/webhook/test_webhook.py index f6d9493dff..5059d75ea8 100644 --- a/frappe/integrations/doctype/webhook/test_webhook.py +++ b/frappe/integrations/doctype/webhook/test_webhook.py @@ -13,7 +13,7 @@ from frappe.integrations.doctype.webhook.webhook import ( get_webhook_data, get_webhook_headers, ) -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase @contextmanager @@ -29,7 +29,16 @@ def get_test_webhook(config): wh.delete() -class TestWebhook(FrappeTestCase): +class UnitTestWebhook(UnitTestCase): + """ + Unit tests for Webhook. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWebhook(IntegrationTestCase): @classmethod def setUpClass(cls): # delete any existing webhooks diff --git a/frappe/integrations/doctype/webhook_request_log/test_webhook_request_log.py b/frappe/integrations/doctype/webhook_request_log/test_webhook_request_log.py index fe15bb8b58..1a1f44335e 100644 --- a/frappe/integrations/doctype/webhook_request_log/test_webhook_request_log.py +++ b/frappe/integrations/doctype/webhook_request_log/test_webhook_request_log.py @@ -2,8 +2,17 @@ # License: MIT. See LICENSE # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestWebhookRequestLog(FrappeTestCase): +class UnitTestWebhookRequestLog(UnitTestCase): + """ + Unit tests for WebhookRequestLog. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestWebhookRequestLog(IntegrationTestCase): pass diff --git a/frappe/parallel_test_runner.py b/frappe/parallel_test_runner.py index 47b8ba375c..bd2028e1dc 100644 --- a/frappe/parallel_test_runner.py +++ b/frappe/parallel_test_runner.py @@ -11,8 +11,9 @@ import click import requests import frappe +from frappe.tests.utils import make_test_records -from .test_runner import TestResult, make_test_records +from .test_runner import TestResult click_ctx = click.get_current_context(True) if click_ctx: diff --git a/frappe/printing/doctype/letter_head/test_letter_head.py b/frappe/printing/doctype/letter_head/test_letter_head.py index 39cb0c9816..fe1b5da023 100644 --- a/frappe/printing/doctype/letter_head/test_letter_head.py +++ b/frappe/printing/doctype/letter_head/test_letter_head.py @@ -1,10 +1,19 @@ # 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 -class TestLetterHead(FrappeTestCase): +class UnitTestLetterHead(UnitTestCase): + """ + Unit tests for LetterHead. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestLetterHead(IntegrationTestCase): def test_auto_image(self): letter_head = frappe.get_doc( doctype="Letter Head", letter_head_name="Test", source="Image", image="/public/test.png" diff --git a/frappe/printing/doctype/network_printer_settings/test_network_printer_settings.py b/frappe/printing/doctype/network_printer_settings/test_network_printer_settings.py index de04b5277b..79aba2afd4 100644 --- a/frappe/printing/doctype/network_printer_settings/test_network_printer_settings.py +++ b/frappe/printing/doctype/network_printer_settings/test_network_printer_settings.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestNetworkPrinterSettings(FrappeTestCase): +class UnitTestNetworkPrinterSettings(UnitTestCase): + """ + Unit tests for NetworkPrinterSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestNetworkPrinterSettings(IntegrationTestCase): pass diff --git a/frappe/printing/doctype/print_format/test_print_format.py b/frappe/printing/doctype/print_format/test_print_format.py index 212fda2b9d..c2a48b2a12 100644 --- a/frappe/printing/doctype/print_format/test_print_format.py +++ b/frappe/printing/doctype/print_format/test_print_format.py @@ -6,7 +6,7 @@ import unittest from typing import TYPE_CHECKING import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase if TYPE_CHECKING: from frappe.printing.doctype.print_format.print_format import PrintFormat @@ -14,7 +14,16 @@ if TYPE_CHECKING: test_records = frappe.get_test_records("Print Format") -class TestPrintFormat(FrappeTestCase): +class UnitTestPrintFormat(UnitTestCase): + """ + Unit tests for PrintFormat. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPrintFormat(IntegrationTestCase): def test_print_user(self, style=None): print_html = frappe.get_print("User", "Administrator", style=style) self.assertTrue("" in print_html) diff --git a/frappe/printing/doctype/print_format_field_template/test_print_format_field_template.py b/frappe/printing/doctype/print_format_field_template/test_print_format_field_template.py index 74f495bd3a..503cf0774d 100644 --- a/frappe/printing/doctype/print_format_field_template/test_print_format_field_template.py +++ b/frappe/printing/doctype/print_format_field_template/test_print_format_field_template.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestPrintFormatFieldTemplate(FrappeTestCase): +class UnitTestPrintFormatFieldTemplate(UnitTestCase): + """ + Unit tests for PrintFormatFieldTemplate. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPrintFormatFieldTemplate(IntegrationTestCase): pass diff --git a/frappe/printing/doctype/print_heading/test_print_heading.py b/frappe/printing/doctype/print_heading/test_print_heading.py index 8fab30e79f..3011e20591 100644 --- a/frappe/printing/doctype/print_heading/test_print_heading.py +++ b/frappe/printing/doctype/print_heading/test_print_heading.py @@ -1,8 +1,17 @@ # 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 -class TestPrintHeading(FrappeTestCase): +class UnitTestPrintHeading(UnitTestCase): + """ + Unit tests for PrintHeading. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPrintHeading(IntegrationTestCase): pass diff --git a/frappe/printing/doctype/print_settings/test_print_settings.py b/frappe/printing/doctype/print_settings/test_print_settings.py index 80069824ab..a699c5aaf7 100644 --- a/frappe/printing/doctype/print_settings/test_print_settings.py +++ b/frappe/printing/doctype/print_settings/test_print_settings.py @@ -1,7 +1,16 @@ # Copyright (c) 2018, Frappe Technologies and Contributors # License: MIT. See LICENSE -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestPrintSettings(FrappeTestCase): +class UnitTestPrintSettings(UnitTestCase): + """ + Unit tests for PrintSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPrintSettings(IntegrationTestCase): pass diff --git a/frappe/printing/doctype/print_style/test_print_style.py b/frappe/printing/doctype/print_style/test_print_style.py index 744181ad3e..bfbf172279 100644 --- a/frappe/printing/doctype/print_style/test_print_style.py +++ b/frappe/printing/doctype/print_style/test_print_style.py @@ -1,8 +1,17 @@ # 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 -class TestPrintStyle(FrappeTestCase): +class UnitTestPrintStyle(UnitTestCase): + """ + Unit tests for PrintStyle. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestPrintStyle(IntegrationTestCase): pass diff --git a/frappe/search/test_full_text_search.py b/frappe/search/test_full_text_search.py index 0a11dd6953..803db51205 100644 --- a/frappe/search/test_full_text_search.py +++ b/frappe/search/test_full_text_search.py @@ -1,10 +1,10 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE from frappe.search.full_text_search import FullTextSearch -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestFullTextSearch(FrappeTestCase): +class TestFullTextSearch(IntegrationTestCase): def setUp(self): index = get_index() index.build() diff --git a/frappe/social/doctype/energy_point_log/test_energy_point_log.py b/frappe/social/doctype/energy_point_log/test_energy_point_log.py index 42c027f44d..a3a1edd86a 100644 --- a/frappe/social/doctype/energy_point_log/test_energy_point_log.py +++ b/frappe/social/doctype/energy_point_log/test_energy_point_log.py @@ -3,14 +3,23 @@ import frappe from frappe.desk.form.assign_to import add as assign_to from frappe.desk.page.user_profile.user_profile import get_energy_points_heatmap_data -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase from frappe.utils.testutils import add_custom_field, clear_custom_fields from .energy_point_log import create_review_points_log, review from .energy_point_log import get_energy_points as _get_energy_points -class TestEnergyPointLog(FrappeTestCase): +class UnitTestEnergyPointLog(UnitTestCase): + """ + Unit tests for EnergyPointLog. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEnergyPointLog(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/frappe/social/doctype/energy_point_settings/test_energy_point_settings.py b/frappe/social/doctype/energy_point_settings/test_energy_point_settings.py index 7907eecfe9..be441096f8 100644 --- a/frappe/social/doctype/energy_point_settings/test_energy_point_settings.py +++ b/frappe/social/doctype/energy_point_settings/test_energy_point_settings.py @@ -2,8 +2,17 @@ # See license.txt # import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase, UnitTestCase -class TestEnergyPointSettings(FrappeTestCase): +class UnitTestEnergyPointSettings(UnitTestCase): + """ + Unit tests for EnergyPointSettings. + Use this class for testing individual functions and methods. + """ + + pass + + +class TestEnergyPointSettings(IntegrationTestCase): pass diff --git a/frappe/test_runner.py b/frappe/test_runner.py index 218682e0f6..c6e5ced842 100644 --- a/frappe/test_runner.py +++ b/frappe/test_runner.py @@ -19,8 +19,7 @@ import sys import time import unittest from dataclasses import dataclass, field -from functools import cache, wraps -from importlib import reload +from functools import wraps from io import StringIO from pathlib import Path from typing import Optional, Union @@ -29,9 +28,8 @@ import click import frappe import frappe.utils.scheduler -from frappe.model.naming import revert_series_if_last -from frappe.modules import get_module_name, load_doctype_module -from frappe.tests.utils import FrappeIntegrationTestCase +from frappe.modules import get_module_name +from frappe.tests.utils import IntegrationTestCase, make_test_records from frappe.utils import cint SLOW_TEST_THRESHOLD = 2 @@ -229,7 +227,7 @@ class TestRunner(unittest.TextTestRunner): if config.tests and test._testMethodName not in config.tests: continue - category = "integration" if isinstance(test, FrappeIntegrationTestCase) else "unit" + category = "integration" if isinstance(test, IntegrationTestCase) else "unit" if config.selected_categories and category not in config.selected_categories: continue @@ -713,206 +711,6 @@ def _prepare_integration_tests( logger.debug("Skipping before_tests hooks and test record creation: No integration tests") -def make_test_records(doctype, force=False, commit=False): - """Make test records for the specified doctype""" - logger.debug(f"Making test records for doctype: {doctype}") - - for options in get_dependencies(doctype): - if options == "[Select]": - continue - - if options not in frappe.local.test_objects: - frappe.local.test_objects[options] = [] - make_test_records(options, force, commit=commit) - make_test_records_for_doctype(options, force, commit=commit) - - -@cache -def get_modules(doctype): - """Get the modules for the specified doctype""" - module = frappe.db.get_value("DocType", doctype, "module") - try: - test_module = load_doctype_module(doctype, module, "test_") - if test_module: - reload(test_module) - except ImportError: - test_module = None - - return module, test_module - - -@cache -def get_dependencies(doctype): - """Get the dependencies for the specified doctype""" - module, test_module = get_modules(doctype) - meta = frappe.get_meta(doctype) - link_fields = meta.get_link_fields() - - for df in meta.get_table_fields(): - link_fields.extend(frappe.get_meta(df.options).get_link_fields()) - - options_list = [df.options for df in link_fields] + [doctype] - - if hasattr(test_module, "test_dependencies"): - options_list += test_module.test_dependencies - - options_list = list(set(options_list)) - - if hasattr(test_module, "test_ignore"): - for doctype_name in test_module.test_ignore: - if doctype_name in options_list: - options_list.remove(doctype_name) - - options_list.sort() - - return options_list - - -def make_test_records_for_doctype(doctype, force=False, commit=False): - """Make test records for the specified doctype""" - - test_record_log_instance = TestRecordLog() - if not force and doctype in test_record_log_instance.get(): - return - - module, test_module = get_modules(doctype) - logger.debug(f"Making test records for {doctype}") - - if hasattr(test_module, "_make_test_records"): - frappe.local.test_objects[doctype] = ( - frappe.local.test_objects.get(doctype, []) + test_module._make_test_records() - ) - elif hasattr(test_module, "test_records"): - frappe.local.test_objects[doctype] = frappe.local.test_objects.get(doctype, []) + make_test_objects( - doctype, test_module.test_records, force, commit=commit - ) - else: - test_records = frappe.get_test_records(doctype) - if test_records: - frappe.local.test_objects[doctype] = frappe.local.test_objects.get( - doctype, [] - ) + make_test_objects(doctype, test_records, force, commit=commit) - elif logger.getEffectiveLevel() < logging.INFO: - print_mandatory_fields(doctype) - - test_record_log_instance.add(doctype) - - -def make_test_objects(doctype, test_records=None, reset=False, commit=False): - """Make test objects from given list of `test_records` or from `test_records.json`""" - logger.debug(f"Making test objects for doctype: {doctype}") - records = [] - - def revert_naming(d): - if getattr(d, "naming_series", None): - revert_series_if_last(d.naming_series, d.name) - - if test_records is None: - test_records = frappe.get_test_records(doctype) - - for doc in test_records: - if not reset: - frappe.db.savepoint("creating_test_record") - - if not doc.get("doctype"): - doc["doctype"] = doctype - - d = frappe.copy_doc(doc) - - if d.meta.get_field("naming_series"): - if not d.naming_series: - d.naming_series = "_T-" + d.doctype + "-" - - if doc.get("name"): - d.name = doc.get("name") - else: - d.set_new_name() - - if frappe.db.exists(d.doctype, d.name) and not reset: - frappe.db.rollback(save_point="creating_test_record") - # do not create test records, if already exists - continue - - # submit if docstatus is set to 1 for test record - docstatus = d.docstatus - - d.docstatus = 0 - - try: - d.run_method("before_test_insert") - d.insert(ignore_if_duplicate=True) - - if docstatus == 1: - d.submit() - - except frappe.NameError: - revert_naming(d) - - except Exception as e: - if ( - d.flags.ignore_these_exceptions_in_test - and e.__class__ in d.flags.ignore_these_exceptions_in_test - ): - revert_naming(d) - else: - logger.debug(f"Error in making test record for {d.doctype} {d.name}") - raise - - records.append(d.name) - - if commit: - frappe.db.commit() - return records - - -def print_mandatory_fields(doctype): - """Print mandatory fields for the specified doctype""" - meta = frappe.get_meta(doctype) - logger.debug(f"Please setup make_test_records for: {doctype}") - logger.debug("-" * 60) - logger.debug(f"Autoname: {meta.autoname or ''}") - logger.debug("Mandatory Fields:") - for d in meta.get("fields", {"reqd": 1}): - logger.debug(f" - {d.parent}:{d.fieldname} | {d.fieldtype} | {d.options or ''}") - logger.debug("") - - -class TestRecordLog: - def __init__(self): - self.log_file = Path(frappe.get_site_path(".test_log")) - self._log = None - - def get(self): - if self._log is None: - self._log = self._read_log() - return self._log - - def add(self, doctype): - log = self.get() - if doctype not in log: - log.append(doctype) - self._write_log(log) - - def _read_log(self): - if self.log_file.exists(): - with self.log_file.open() as f: - return f.read().splitlines() - return [] - - def _write_log(self, log): - with self.log_file.open("w") as f: - f.write("\n".join(l for l in log if l is not None)) - - -# Compatibility functions -def add_to_test_record_log(doctype): - TestRecordLog().add(doctype) - - -def get_test_record_log(): - return TestRecordLog().get() - - @debug_timer def _run_before_test_hooks(config: TestConfig, app: str | None): """Run 'before_tests' hooks""" @@ -926,3 +724,23 @@ def _execute_test_record_callbacks(runner): """Execute test record creation callbacks""" logger.debug("Running test record creation callbacks") runner.execute_test_record_callbacks() + + +# Backwards-compatible aliases +from frappe.tests.utils import ( + TestRecordLog, + get_dependencies, + get_modules, + make_test_objects, + make_test_records_for_doctype, + print_mandatory_fields, +) + + +# Compatibility functions +def add_to_test_record_log(doctype): + TestRecordLog().add(doctype) + + +def get_test_record_log(): + return TestRecordLog().get() diff --git a/frappe/tests/__init__.py b/frappe/tests/__init__.py index eda83bd14b..8b2f31dc26 100644 --- a/frappe/tests/__init__.py +++ b/frappe/tests/__init__.py @@ -1,6 +1,10 @@ +# TODO: move to dumpster import frappe +from .utils import IntegrationTestCase, MockedRequestTestCase, UnitTestCase + +# TODO: move to dumpster def update_system_settings(args, commit=False): doc = frappe.get_doc("System Settings") doc.update(args) @@ -10,6 +14,7 @@ def update_system_settings(args, commit=False): frappe.db.commit() +# TODO: move to dumpster def get_system_setting(key): return frappe.db.get_single_value("System Settings", key) diff --git a/frappe/tests/test_api.py b/frappe/tests/test_api.py index 913c70169c..7a478b80f8 100644 --- a/frappe/tests/test_api.py +++ b/frappe/tests/test_api.py @@ -15,7 +15,7 @@ from werkzeug.test import TestResponse import frappe from frappe.installer import update_site_config -from frappe.tests.utils import FrappeTestCase, patch_hooks +from frappe.tests import IntegrationTestCase from frappe.utils import cint, get_test_client, get_url try: @@ -84,7 +84,7 @@ resource_key = { } -class FrappeAPITestCase(FrappeTestCase): +class FrappeAPITestCase(IntegrationTestCase): version = "" # Empty implies v1 TEST_CLIENT = get_test_client() @@ -362,7 +362,7 @@ class TestWSGIApp(FrappeAPITestCase): def test_request_hooks(self): self.addCleanup(lambda: _test_REQ_HOOK.clear()) - with patch_hooks( + with self.patch_hooks( { "before_request": ["frappe.tests.test_api.before_request"], "after_request": ["frappe.tests.test_api.after_request"], diff --git a/frappe/tests/test_assign.py b/frappe/tests/test_assign.py index 171fd04925..06957fa45e 100644 --- a/frappe/tests/test_assign.py +++ b/frappe/tests/test_assign.py @@ -9,10 +9,10 @@ from frappe.automation.doctype.assignment_rule.test_assignment_rule import ( ) from frappe.desk.form.load import get_assignments from frappe.desk.listview import get_group_by_count -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestAssign(FrappeTestCase): +class TestAssign(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/frappe/tests/test_auth.py b/frappe/tests/test_auth.py index 447ae37a96..23a98d55be 100644 --- a/frappe/tests/test_auth.py +++ b/frappe/tests/test_auth.py @@ -9,8 +9,8 @@ import frappe from frappe.auth import LoginAttemptTracker from frappe.frappeclient import AuthError, FrappeClient from frappe.sessions import Session, get_expired_sessions, get_expiry_in_seconds +from frappe.tests import IntegrationTestCase from frappe.tests.test_api import FrappeAPITestCase -from frappe.tests.utils import FrappeTestCase from frappe.utils import get_datetime, get_site_url, now from frappe.utils.data import add_to_date from frappe.www.login import _generate_temporary_login_link @@ -27,7 +27,7 @@ def add_user(email, password, username=None, mobile_no=None): frappe.db.commit() -class TestAuth(FrappeTestCase): +class TestAuth(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -165,7 +165,7 @@ class TestAuth(FrappeTestCase): self.assertAlmostEqual(get_expiry_in_seconds(), expiry_time - current_time, delta=60 * 60) -class TestLoginAttemptTracker(FrappeTestCase): +class TestLoginAttemptTracker(IntegrationTestCase): def test_account_lock(self): """Make sure that account locks after `n consecutive failures""" tracker = LoginAttemptTracker("tester", max_consecutive_login_attempts=3, lock_interval=60) diff --git a/frappe/tests/test_background_jobs.py b/frappe/tests/test_background_jobs.py index e19e15655a..1770d1092a 100644 --- a/frappe/tests/test_background_jobs.py +++ b/frappe/tests/test_background_jobs.py @@ -6,7 +6,7 @@ from rq import Queue import frappe from frappe.core.doctype.rq_job.rq_job import remove_failed_jobs -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.background_jobs import ( RQ_JOB_FAILURE_TTL, RQ_RESULTS_TTL, @@ -17,7 +17,7 @@ from frappe.utils.background_jobs import ( ) -class TestBackgroundJobs(FrappeTestCase): +class TestBackgroundJobs(IntegrationTestCase): def test_remove_failed_jobs(self): frappe.enqueue(method="frappe.tests.test_background_jobs.fail_function", queue="short") # wait for enqueued job to execute diff --git a/frappe/tests/test_base_document.py b/frappe/tests/test_base_document.py index 0f49e7d7f5..59f0dcf81b 100644 --- a/frappe/tests/test_base_document.py +++ b/frappe/tests/test_base_document.py @@ -1,8 +1,8 @@ from frappe.model.base_document import BaseDocument -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestBaseDocument(FrappeTestCase): +class TestBaseDocument(IntegrationTestCase): def test_docstatus(self): doc = BaseDocument({"docstatus": 0, "doctype": "ToDo"}) self.assertTrue(doc.docstatus.is_draft()) diff --git a/frappe/tests/test_boot.py b/frappe/tests/test_boot.py index 62d8e7fd6d..32cc8b986e 100644 --- a/frappe/tests/test_boot.py +++ b/frappe/tests/test_boot.py @@ -1,10 +1,10 @@ import frappe from frappe.boot import get_unseen_notes, get_user_pages_or_reports from frappe.desk.doctype.note.note import mark_as_seen -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestBootData(FrappeTestCase): +class TestBootData(IntegrationTestCase): def test_get_unseen_notes(self): frappe.db.delete("Note") frappe.db.delete("Note Seen By") @@ -28,7 +28,7 @@ class TestBootData(FrappeTestCase): self.assertListEqual(unseen_notes, []) -class TestPermissionQueries(FrappeTestCase): +class TestPermissionQueries(IntegrationTestCase): @classmethod def setUpClass(cls) -> None: cls.enable_safe_exec() diff --git a/frappe/tests/test_caching.py b/frappe/tests/test_caching.py index 3eeefaa67d..c390a7e500 100644 --- a/frappe/tests/test_caching.py +++ b/frappe/tests/test_caching.py @@ -3,8 +3,8 @@ from unittest.mock import MagicMock import frappe from frappe.core.doctype.doctype.test_doctype import new_doctype +from frappe.tests import IntegrationTestCase from frappe.tests.test_api import FrappeAPITestCase -from frappe.tests.utils import FrappeTestCase from frappe.utils.caching import redis_cache, request_cache, site_cache CACHE_TTL = 4 @@ -35,7 +35,7 @@ def ping_with_ttl() -> str: return frappe.local.site -class TestCachingUtils(FrappeTestCase): +class TestCachingUtils(IntegrationTestCase): def test_request_cache(self): retval = [] acceptable_args = [ diff --git a/frappe/tests/test_child_table.py b/frappe/tests/test_child_table.py index 920a800bf0..7d2f7b7b92 100644 --- a/frappe/tests/test_child_table.py +++ b/frappe/tests/test_child_table.py @@ -2,10 +2,10 @@ from collections.abc import Callable import frappe from frappe.model import child_table_fields -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestChildTable(FrappeTestCase): +class TestChildTable(IntegrationTestCase): def tearDown(self) -> None: try: frappe.delete_doc("DocType", self.doctype_name, force=1) diff --git a/frappe/tests/test_client.py b/frappe/tests/test_client.py index 5b338f5fe5..e6d0cc9552 100644 --- a/frappe/tests/test_client.py +++ b/frappe/tests/test_client.py @@ -3,11 +3,11 @@ from unittest.mock import patch import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import get_site_url -class TestClient(FrappeTestCase): +class TestClient(IntegrationTestCase): def test_set_value(self): todo = frappe.get_doc(doctype="ToDo", description="test").insert() frappe.set_value("ToDo", todo.name, "description", "test 1") diff --git a/frappe/tests/test_commands.py b/frappe/tests/test_commands.py index 49f788d5bd..baf4d32436 100644 --- a/frappe/tests/test_commands.py +++ b/frappe/tests/test_commands.py @@ -33,8 +33,9 @@ import frappe.commands.utils import frappe.recorder from frappe.installer import add_to_installed_apps, remove_app from frappe.query_builder.utils import db_type_is +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import run_only_if -from frappe.tests.utils import FrappeTestCase, timeout +from frappe.tests.utils import timeout from frappe.utils import add_to_date, get_bench_path, get_bench_relative_path, now from frappe.utils.backups import BackupGenerator, fetch_latest_backups from frappe.utils.jinja_globals import bundled_asset @@ -133,7 +134,7 @@ def cli(cmd: Command, args: list | None = None): importlib.invalidate_caches() -class BaseTestCommands(FrappeTestCase): +class BaseTestCommands(IntegrationTestCase): @classmethod def setUpClass(cls) -> None: super().setUpClass() @@ -825,7 +826,7 @@ class TestBackups(BaseTestCommands): self.assertEqual([], missing_in_backup(self.backup_map["excludes"]["excludes"], database)) -class TestRemoveApp(FrappeTestCase): +class TestRemoveApp(IntegrationTestCase): def test_delete_modules(self): from frappe.installer import ( _delete_doctypes, @@ -944,7 +945,7 @@ class TestSchedulerUtils(BaseTestCommands): self.assertEqual(result.exit_code, 0) -class TestCommandUtils(FrappeTestCase): +class TestCommandUtils(IntegrationTestCase): def test_bench_helper(self): from frappe.utils.bench_helper import get_app_groups diff --git a/frappe/tests/test_config.py b/frappe/tests/test_config.py index cbc51f331e..38e81e0eb6 100644 --- a/frappe/tests/test_config.py +++ b/frappe/tests/test_config.py @@ -1,11 +1,11 @@ # Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.modules import get_modules_from_all_apps_for_user -class TestConfig(FrappeTestCase): +class TestConfig(IntegrationTestCase): def test_get_modules(self): frappe_modules = frappe.get_all("Module Def", filters={"app_name": "frappe"}, pluck="name") all_modules_data = get_modules_from_all_apps_for_user() diff --git a/frappe/tests/test_cors.py b/frappe/tests/test_cors.py index 1974c174db..bc73fcd7c8 100644 --- a/frappe/tests/test_cors.py +++ b/frappe/tests/test_cors.py @@ -4,7 +4,7 @@ from werkzeug.wrappers import Response import frappe from frappe.app import process_response -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase HEADERS = ( "Access-Control-Allow-Origin", @@ -15,7 +15,7 @@ HEADERS = ( ) -class TestCORS(FrappeTestCase): +class TestCORS(IntegrationTestCase): def make_request_and_test(self, origin="http://example.com", absent=False): self.origin = origin diff --git a/frappe/tests/test_dashboard_connections.py b/frappe/tests/test_dashboard_connections.py index 4d0f892558..dc16c88f24 100644 --- a/frappe/tests/test_dashboard_connections.py +++ b/frappe/tests/test_dashboard_connections.py @@ -8,10 +8,10 @@ import frappe.utils from frappe.core.doctype.doctype.test_doctype import new_doctype from frappe.custom.doctype.customize_form.test_customize_form import TestCustomizeForm from frappe.desk.notifications import get_open_count -from frappe.tests.utils import FrappeTestCase, patch_hooks +from frappe.tests import IntegrationTestCase -class TestDashboardConnections(FrappeTestCase): +class TestDashboardConnections(IntegrationTestCase): @patch.dict(frappe.conf, {"developer_mode": 1}) def setUp(self): delete_test_data() @@ -138,7 +138,7 @@ class TestDashboardConnections(FrappeTestCase): self.assertEqual(len(connections["external_links_found"]), 2) # Change standard fieldname, see if all custom links still work - with patch_hooks( + with self.patch_hooks( { "override_doctype_dashboards": { "ToDo": ["frappe.tests.test_dashboard_connections.get_dashboard_for_todo"] diff --git a/frappe/tests/test_db.py b/frappe/tests/test_db.py index 6d2994dd90..6e878ee5b1 100644 --- a/frappe/tests/test_db.py +++ b/frappe/tests/test_db.py @@ -14,14 +14,15 @@ from frappe.database.database import get_query_execution_timeout from frappe.database.utils import FallBackDateTimeStr from frappe.query_builder import Field from frappe.query_builder.functions import Concat_ws +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import db_type_is, run_only_if -from frappe.tests.utils import FrappeTestCase, patch_hooks, timeout +from frappe.tests.utils import timeout from frappe.utils import add_days, now, random_string, set_request from frappe.utils.data import now_datetime from frappe.utils.testutils import clear_custom_fields -class TestDB(FrappeTestCase): +class TestDB(IntegrationTestCase): def test_datetime_format(self): now_str = now() self.assertEqual(frappe.db.format_datetime(None), FallBackDateTimeStr) @@ -464,7 +465,7 @@ class TestDB(FrappeTestCase): hook_name = f"{bad_hook.__module__}.{bad_hook.__name__}" nested_hook_name = f"{bad_nested_hook.__module__}.{bad_nested_hook.__name__}" - with patch_hooks( + with self.patch_hooks( {"doc_events": {"*": {"before_validate": hook_name, "on_update": nested_hook_name}}} ): note = frappe.new_doc("Note", title=frappe.generate_hash()) @@ -651,7 +652,7 @@ class TestDB(FrappeTestCase): @run_only_if(db_type_is.MARIADB) -class TestDDLCommandsMaria(FrappeTestCase): +class TestDDLCommandsMaria(IntegrationTestCase): test_table_name = "TestNotes" def setUp(self) -> None: @@ -713,7 +714,7 @@ class TestDDLCommandsMaria(FrappeTestCase): self.assertEqual(len(indexs_in_table), 2) -class TestDBSetValue(FrappeTestCase): +class TestDBSetValue(IntegrationTestCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -859,7 +860,7 @@ class TestDBSetValue(FrappeTestCase): @run_only_if(db_type_is.POSTGRES) -class TestDDLCommandsPost(FrappeTestCase): +class TestDDLCommandsPost(IntegrationTestCase): test_table_name = "TestNotes" def setUp(self) -> None: @@ -968,7 +969,7 @@ class TestDDLCommandsPost(FrappeTestCase): @run_only_if(db_type_is.POSTGRES) -class TestTransactionManagement(FrappeTestCase): +class TestTransactionManagement(IntegrationTestCase): def test_create_proper_transactions(self): def _get_transaction_id(): return frappe.db.sql("select txid_current()", pluck=True) @@ -983,7 +984,7 @@ class TestTransactionManagement(FrappeTestCase): # Treat same DB as replica for tests, a separate connection will be opened -class TestReplicaConnections(FrappeTestCase): +class TestReplicaConnections(IntegrationTestCase): def test_switching_to_replica(self): with patch.dict(frappe.local.conf, {"read_from_replica": 1, "replica_host": "127.0.0.1"}): @@ -1013,7 +1014,7 @@ class TestReplicaConnections(FrappeTestCase): self.assertEqual(write_connection, db_id()) -class TestConcurrency(FrappeTestCase): +class TestConcurrency(IntegrationTestCase): @timeout(5, "There shouldn't be any lock wait") def test_skip_locking(self): with self.primary_connection(): @@ -1062,7 +1063,7 @@ def bad_nested_hook(doc, *args, **kwargs): frappe.db.rollback() -class TestSqlIterator(FrappeTestCase): +class TestSqlIterator(IntegrationTestCase): def test_db_sql_iterator(self): test_queries = [ "select * from `tabCountry` order by name", @@ -1095,7 +1096,7 @@ class TestSqlIterator(FrappeTestCase): self.test_db_sql_iterator() -class ExtFrappeTestCase(FrappeTestCase): +class ExtIntegrationTestCase(IntegrationTestCase): def assertSqlException(self): class SqlExceptionContextManager: def __init__(self, test_case): @@ -1116,7 +1117,7 @@ class ExtFrappeTestCase(FrappeTestCase): @run_only_if(db_type_is.POSTGRES) -class TestPostgresSchemaQueryIndependence(ExtFrappeTestCase): +class TestPostgresSchemaQueryIndependence(ExtIntegrationTestCase): test_table_name = "TestSchemaTable" def setUp(self, rollback=False) -> None: @@ -1275,7 +1276,7 @@ class TestPostgresSchemaQueryIndependence(ExtFrappeTestCase): del frappe.conf["db_schema"] -class TestDbConnectWithEnvCredentials(FrappeTestCase): +class TestDbConnectWithEnvCredentials(IntegrationTestCase): current_site = frappe.local.site def tearDown(self): diff --git a/frappe/tests/test_db_query.py b/frappe/tests/test_db_query.py index 7d539cdf47..e40b3a3b53 100644 --- a/frappe/tests/test_db_query.py +++ b/frappe/tests/test_db_query.py @@ -14,8 +14,8 @@ from frappe.handler import execute_cmd from frappe.model.db_query import DatabaseQuery, get_between_date_filter from frappe.permissions import add_user_permission, clear_user_permissions_for_doctype from frappe.query_builder import Column +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import db_type_is, run_only_if -from frappe.tests.utils import FrappeTestCase from frappe.utils.testutils import add_custom_field, clear_custom_fields test_dependencies = ["User", "Blog Post", "Blog Category", "Blogger"] @@ -47,7 +47,7 @@ def setup_patched_blog_post(): yield -class TestDBQuery(FrappeTestCase): +class TestDBQuery(IntegrationTestCase): def setUp(self): frappe.set_user("Administrator") @@ -1193,7 +1193,7 @@ class TestDBQuery(FrappeTestCase): self.assertEqual(count[1], frappe.db.count("Language")) -class TestReportView(FrappeTestCase): +class TestReportView(IntegrationTestCase): @run_only_if(db_type_is.MARIADB) # TODO: postgres name casting is messed up def test_get_count(self): frappe.local.request = frappe._dict() diff --git a/frappe/tests/test_db_update.py b/frappe/tests/test_db_update.py index aebd5ed8e8..a62a6433a9 100644 --- a/frappe/tests/test_db_update.py +++ b/frappe/tests/test_db_update.py @@ -3,12 +3,12 @@ from frappe.core.doctype.doctype.test_doctype import new_doctype from frappe.core.utils import find from frappe.custom.doctype.property_setter.property_setter import make_property_setter from frappe.query_builder.utils import db_type_is +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import run_only_if -from frappe.tests.utils import FrappeTestCase from frappe.utils import cstr -class TestDBUpdate(FrappeTestCase): +class TestDBUpdate(IntegrationTestCase): def test_db_update(self): doctype = "User" frappe.reload_doctype("User", force=True) diff --git a/frappe/tests/test_defaults.py b/frappe/tests/test_defaults.py index 9f4024de4d..a46195f2b5 100644 --- a/frappe/tests/test_defaults.py +++ b/frappe/tests/test_defaults.py @@ -4,11 +4,11 @@ import frappe from frappe.core.doctype.user_permission.test_user_permission import create_user from frappe.defaults import * from frappe.query_builder.utils import db_type_is +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import run_only_if -from frappe.tests.utils import FrappeTestCase -class TestDefaults(FrappeTestCase): +class TestDefaults(IntegrationTestCase): def test_global(self): clear_user_default("key1") set_global_default("key1", "value1") diff --git a/frappe/tests/test_deferred_insert.py b/frappe/tests/test_deferred_insert.py index 8c44b87591..d024eecee5 100644 --- a/frappe/tests/test_deferred_insert.py +++ b/frappe/tests/test_deferred_insert.py @@ -1,9 +1,9 @@ import frappe from frappe.deferred_insert import deferred_insert, save_to_db -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestDeferredInsert(FrappeTestCase): +class TestDeferredInsert(IntegrationTestCase): def test_deferred_insert(self): route_history = {"route": frappe.generate_hash(), "user": "Administrator"} deferred_insert("Route History", [route_history]) diff --git a/frappe/tests/test_docstatus.py b/frappe/tests/test_docstatus.py index ae29681206..7d428720a6 100644 --- a/frappe/tests/test_docstatus.py +++ b/frappe/tests/test_docstatus.py @@ -1,8 +1,8 @@ from frappe.model.docstatus import DocStatus -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestDocStatus(FrappeTestCase): +class TestDocStatus(IntegrationTestCase): def test_draft(self): self.assertEqual(DocStatus(0), DocStatus.draft()) diff --git a/frappe/tests/test_document.py b/frappe/tests/test_document.py index 5f7c0a5efb..f06a73214d 100644 --- a/frappe/tests/test_document.py +++ b/frappe/tests/test_document.py @@ -9,7 +9,7 @@ from frappe.app import make_form_dict from frappe.core.doctype.doctype.test_doctype import new_doctype from frappe.desk.doctype.note.note import Note from frappe.model.naming import make_autoname, parse_naming_series, revert_series_if_last -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import cint, now_datetime, set_request from frappe.website.serve import get_response @@ -27,7 +27,7 @@ class CustomNoteWithoutProperty(Note): return now_datetime() - self.creation -class TestDocument(FrappeTestCase): +class TestDocument(IntegrationTestCase): def test_get_return_empty_list_for_table_field_if_none(self): d = frappe.get_doc({"doctype": "User"}) self.assertEqual(d.get("roles"), []) @@ -524,7 +524,7 @@ class TestDocument(FrappeTestCase): self.assertEqual(val, changed_val) -class TestDocumentWebView(FrappeTestCase): +class TestDocumentWebView(IntegrationTestCase): def get(self, path, user="Guest"): frappe.set_user(user) set_request(method="GET", path=path) diff --git a/frappe/tests/test_document_locks.py b/frappe/tests/test_document_locks.py index e01705187a..c636480605 100644 --- a/frappe/tests/test_document_locks.py +++ b/frappe/tests/test_document_locks.py @@ -1,11 +1,11 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.data import add_to_date, today -class TestDocumentLocks(FrappeTestCase): +class TestDocumentLocks(IntegrationTestCase): def test_locking(self): todo = frappe.get_doc(doctype="ToDo", description="test").insert() todo_1 = frappe.get_doc("ToDo", todo.name) diff --git a/frappe/tests/test_document_ro_mode.py b/frappe/tests/test_document_ro_mode.py index bf0767d094..a621f89c2b 100644 --- a/frappe/tests/test_document_ro_mode.py +++ b/frappe/tests/test_document_ro_mode.py @@ -3,10 +3,10 @@ from contextlib import contextmanager import frappe from frappe.model.document import Document, read_only_document -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestReadOnlyDocument(FrappeTestCase): +class TestReadOnlyDocument(IntegrationTestCase): def setUp(self): # Create a test document self.test_doc = frappe.get_doc({"doctype": "ToDo", "description": "Test ToDo"}) diff --git a/frappe/tests/test_domainification.py b/frappe/tests/test_domainification.py index 577110e938..99a9b734d1 100644 --- a/frappe/tests/test_domainification.py +++ b/frappe/tests/test_domainification.py @@ -8,10 +8,10 @@ from frappe.desk.doctype.desktop_icon.desktop_icon import ( clear_desktop_icons_cache, get_desktop_icons, ) -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestDomainification(FrappeTestCase): +class TestDomainification(IntegrationTestCase): def setUp(self): # create test domain self.new_domain("_Test Domain 1") diff --git a/frappe/tests/test_dynamic_links.py b/frappe/tests/test_dynamic_links.py index 95f613fc70..c34fa9ab96 100644 --- a/frappe/tests/test_dynamic_links.py +++ b/frappe/tests/test_dynamic_links.py @@ -1,10 +1,10 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestDynamicLinks(FrappeTestCase): +class TestDynamicLinks(IntegrationTestCase): def setUp(self): frappe.db.delete("Email Unsubscribe") diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index c16ff79839..74a4cb6ae3 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -13,13 +13,13 @@ from frappe.desk.form.load import get_attachments from frappe.email.doctype.email_account.test_email_account import TestEmailAccount from frappe.email.doctype.email_queue.email_queue import QueueBuilder from frappe.query_builder.utils import db_type_is +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import run_only_if -from frappe.tests.utils import FrappeTestCase, change_settings test_dependencies = ["Email Account"] -class TestEmail(FrappeTestCase): +class TestEmail(IntegrationTestCase): def setUp(self): frappe.db.delete("Email Unsubscribe") frappe.db.delete("Email Queue") @@ -306,7 +306,7 @@ class TestEmail(FrappeTestCase): email_account.enable_incoming = False -class TestVerifiedRequests(FrappeTestCase): +class TestVerifiedRequests(IntegrationTestCase): def test_round_trip(self): from frappe.utils import set_request from frappe.utils.verified_command import get_signed_params, verify_request @@ -320,7 +320,7 @@ class TestVerifiedRequests(FrappeTestCase): frappe.local.request = None -class TestEmailIntegrationTest(FrappeTestCase): +class TestEmailIntegrationTest(IntegrationTestCase): """Sends email to local SMTP server and verifies correctness. SMTP4Dev runs as a service in unit test CI job. @@ -372,7 +372,7 @@ class TestEmailIntegrationTest(FrappeTestCase): self.assertSetEqual(set(recipients.split(",")), {m["to"][0] for m in sent_mails}) @run_only_if(db_type_is.MARIADB) - @change_settings("System Settings", store_attached_pdf_document=1) + @IntegrationTestCase.change_settings("System Settings", store_attached_pdf_document=1) def test_store_attachments(self): """ "attach print" feature just tells email queue which document to attach, this is not actually stored unless system setting says so.""" diff --git a/frappe/tests/test_exporter_fixtures.py b/frappe/tests/test_exporter_fixtures.py index 8b8ca1b8d8..85b2812402 100644 --- a/frappe/tests/test_exporter_fixtures.py +++ b/frappe/tests/test_exporter_fixtures.py @@ -5,10 +5,10 @@ import os import frappe import frappe.defaults from frappe.core.doctype.data_import.data_import import export_csv -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestDataImportFixtures(FrappeTestCase): +class TestDataImportFixtures(IntegrationTestCase): def setUp(self): pass diff --git a/frappe/tests/test_fixture_import.py b/frappe/tests/test_fixture_import.py index 8e4fa16763..976c4df0db 100644 --- a/frappe/tests/test_fixture_import.py +++ b/frappe/tests/test_fixture_import.py @@ -4,10 +4,10 @@ import frappe from frappe.core.doctype.data_import.data_import import export_json, import_doc from frappe.desk.form.save import savedocs from frappe.model.delete_doc import delete_doc -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestFixtureImport(FrappeTestCase): +class TestFixtureImport(IntegrationTestCase): def create_new_doctype(self, DocType: str) -> None: file = frappe.get_app_path("frappe", "custom", "fixtures", f"{DocType}.json") diff --git a/frappe/tests/test_fmt_datetime.py b/frappe/tests/test_fmt_datetime.py index 43cf701c33..88d45ad18e 100644 --- a/frappe/tests/test_fmt_datetime.py +++ b/frappe/tests/test_fmt_datetime.py @@ -3,7 +3,7 @@ import datetime import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import ( format_datetime, format_time, @@ -33,7 +33,7 @@ test_time_formats = { } -class TestFmtDatetime(FrappeTestCase): +class TestFmtDatetime(IntegrationTestCase): """Tests date, time and datetime formatters and some associated utility functions. These rely on the system-wide date and time formats. diff --git a/frappe/tests/test_fmt_money.py b/frappe/tests/test_fmt_money.py index 0fbd38cbcc..2ae3fd4b86 100644 --- a/frappe/tests/test_fmt_money.py +++ b/frappe/tests/test_fmt_money.py @@ -1,11 +1,11 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import fmt_money -class TestFmtMoney(FrappeTestCase): +class TestFmtMoney(IntegrationTestCase): def test_standard(self): frappe.db.set_default("number_format", "#,###.##") self.assertEqual(fmt_money(100), "100.00") diff --git a/frappe/tests/test_form_load.py b/frappe/tests/test_form_load.py index d9f031b3e3..bf410e1d6e 100644 --- a/frappe/tests/test_form_load.py +++ b/frappe/tests/test_form_load.py @@ -4,13 +4,13 @@ import frappe from frappe.core.page.permission_manager.permission_manager import add, reset, update from frappe.custom.doctype.property_setter.property_setter import make_property_setter from frappe.desk.form.load import get_docinfo, getdoc, getdoctype -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.file_manager import save_file test_dependencies = ["Blog Category", "Blogger"] -class TestFormLoad(FrappeTestCase): +class TestFormLoad(IntegrationTestCase): def test_load(self): getdoctype("DocType") meta = next(filter(lambda d: d.name == "DocType", frappe.response.docs)) diff --git a/frappe/tests/test_formatter.py b/frappe/tests/test_formatter.py index c7dca303ec..565c321725 100644 --- a/frappe/tests/test_formatter.py +++ b/frappe/tests/test_formatter.py @@ -1,9 +1,9 @@ import frappe from frappe import format -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestFormatter(FrappeTestCase): +class TestFormatter(IntegrationTestCase): def test_currency_formatting(self): df = frappe._dict({"fieldname": "amount", "fieldtype": "Currency", "options": "currency"}) diff --git a/frappe/tests/test_frappe_client.py b/frappe/tests/test_frappe_client.py index 10061cce8a..cc32404baf 100644 --- a/frappe/tests/test_frappe_client.py +++ b/frappe/tests/test_frappe_client.py @@ -9,11 +9,11 @@ import frappe from frappe.core.doctype.user.user import generate_keys from frappe.frappeclient import FrappeClient, FrappeException from frappe.model import default_fields -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.data import get_url -class TestFrappeClient(FrappeTestCase): +class TestFrappeClient(IntegrationTestCase): PASSWORD = frappe.conf.admin_password or "admin" def test_insert_many(self): diff --git a/frappe/tests/test_geo_ip.py b/frappe/tests/test_geo_ip.py index 101512a5f1..4ff4333e27 100644 --- a/frappe/tests/test_geo_ip.py +++ b/frappe/tests/test_geo_ip.py @@ -1,9 +1,9 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: MIT. See LICENSE -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestGeoIP(FrappeTestCase): +class TestGeoIP(IntegrationTestCase): def test_geo_ip(self): return from frappe.sessions import get_geo_ip_country diff --git a/frappe/tests/test_global_search.py b/frappe/tests/test_global_search.py index f59970acfa..069d2523a2 100644 --- a/frappe/tests/test_global_search.py +++ b/frappe/tests/test_global_search.py @@ -4,12 +4,12 @@ import frappe from frappe.custom.doctype.property_setter.property_setter import make_property_setter from frappe.desk.page.setup_wizard.install_fixtures import update_global_search_doctypes -from frappe.test_runner import make_test_objects -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase +from frappe.tests.utils import make_test_objects from frappe.utils import global_search, now_datetime -class TestGlobalSearch(FrappeTestCase): +class TestGlobalSearch(IntegrationTestCase): def setUp(self): update_global_search_doctypes() global_search.setup_global_search_table() diff --git a/frappe/tests/test_goal.py b/frappe/tests/test_goal.py index b624717c64..c5ca245b94 100644 --- a/frappe/tests/test_goal.py +++ b/frappe/tests/test_goal.py @@ -2,13 +2,13 @@ # License: MIT. See LICENSE import frappe -from frappe.test_runner import make_test_objects -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase +from frappe.tests.utils import make_test_objects from frappe.utils import format_date, today from frappe.utils.goal import get_monthly_goal_graph_data, get_monthly_results -class TestGoal(FrappeTestCase): +class TestGoal(IntegrationTestCase): def setUp(self): make_test_objects("Event", reset=True) diff --git a/frappe/tests/test_hooks.py b/frappe/tests/test_hooks.py index 972e68a3d3..976b07736d 100644 --- a/frappe/tests/test_hooks.py +++ b/frappe/tests/test_hooks.py @@ -3,11 +3,11 @@ import frappe from frappe.cache_manager import clear_controller_cache from frappe.desk.doctype.todo.todo import ToDo +from frappe.tests import IntegrationTestCase from frappe.tests.test_api import FrappeAPITestCase -from frappe.tests.utils import FrappeTestCase, patch_hooks -class TestHooks(FrappeTestCase): +class TestHooks(IntegrationTestCase): def test_hooks(self): hooks = frappe.get_hooks() self.assertTrue(isinstance(hooks.get("app_name"), list)) @@ -188,7 +188,7 @@ class TestHooks(FrappeTestCase): class TestAPIHooks(FrappeAPITestCase): def test_auth_hook(self): - with patch_hooks({"auth_hooks": ["frappe.tests.test_hooks.custom_auth"]}): + with self.patch_hooks({"auth_hooks": ["frappe.tests.test_hooks.custom_auth"]}): site_url = frappe.utils.get_site_url(frappe.local.site) response = self.get( site_url + "/api/method/frappe.auth.get_logged_user", diff --git a/frappe/tests/test_linked_with.py b/frappe/tests/test_linked_with.py index bab775b8cb..fa3a5a7af5 100644 --- a/frappe/tests/test_linked_with.py +++ b/frappe/tests/test_linked_with.py @@ -5,10 +5,10 @@ import frappe from frappe.core.doctype.doctype.test_doctype import new_doctype from frappe.database import savepoint from frappe.desk.form import linked_with -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestLinkedWith(FrappeTestCase): +class TestLinkedWith(IntegrationTestCase): def setUp(self): parent_doctype = new_doctype("Parent DocType") parent_doctype.is_submittable = 1 diff --git a/frappe/tests/test_listview.py b/frappe/tests/test_listview.py index f5d0b857ba..45b6e629db 100644 --- a/frappe/tests/test_listview.py +++ b/frappe/tests/test_listview.py @@ -5,10 +5,10 @@ import json import frappe from frappe.desk.listview import get_group_by_count, get_list_settings, set_list_settings from frappe.desk.reportview import get -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestListView(FrappeTestCase): +class TestListView(IntegrationTestCase): def setUp(self): if frappe.db.exists("List View Settings", "DocType"): frappe.delete_doc("List View Settings", "DocType") diff --git a/frappe/tests/test_model_utils.py b/frappe/tests/test_model_utils.py index c58f845161..8e6b44f203 100644 --- a/frappe/tests/test_model_utils.py +++ b/frappe/tests/test_model_utils.py @@ -4,10 +4,10 @@ from random import choice import frappe from frappe.model import core_doctypes_list, get_permitted_fields, is_default_field from frappe.model.utils import get_fetch_values -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestModelUtils(FrappeTestCase): +class TestModelUtils(IntegrationTestCase): def test_get_fetch_values(self): doctype = "ToDo" diff --git a/frappe/tests/test_modules.py b/frappe/tests/test_modules.py index 8c2597dc05..22a8359528 100644 --- a/frappe/tests/test_modules.py +++ b/frappe/tests/test_modules.py @@ -12,7 +12,7 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_ from frappe.model.meta import trim_table from frappe.modules import export_customizations, export_module_json, get_module_path from frappe.modules.utils import export_doc, sync_customizations -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import now_datetime @@ -31,7 +31,7 @@ def delete_path(path): shutil.rmtree(path, ignore_errors=True) -class TestUtils(FrappeTestCase): +class TestUtils(IntegrationTestCase): def setUp(self): self._dev_mode = frappe.local.conf.developer_mode frappe.local.conf.developer_mode = True diff --git a/frappe/tests/test_monitor.py b/frappe/tests/test_monitor.py index ef2854515e..96f11be353 100644 --- a/frappe/tests/test_monitor.py +++ b/frappe/tests/test_monitor.py @@ -4,12 +4,12 @@ import frappe import frappe.monitor from frappe.monitor import MONITOR_REDIS_KEY, get_trace_id -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import set_request from frappe.utils.response import build_response -class TestMonitor(FrappeTestCase): +class TestMonitor(IntegrationTestCase): def setUp(self): frappe.conf.monitor = 1 frappe.cache.delete_value(MONITOR_REDIS_KEY) diff --git a/frappe/tests/test_naming.py b/frappe/tests/test_naming.py index d55179520b..365bcbfac2 100644 --- a/frappe/tests/test_naming.py +++ b/frappe/tests/test_naming.py @@ -21,12 +21,12 @@ from frappe.model.naming import ( revert_series_if_last, ) from frappe.query_builder.utils import db_type_is +from frappe.tests import IntegrationTestCase from frappe.tests.test_query_builder import run_only_if -from frappe.tests.utils import FrappeTestCase, patch_hooks from frappe.utils import now_datetime, nowdate, nowtime -class TestNaming(FrappeTestCase): +class TestNaming(IntegrationTestCase): def setUp(self): frappe.db.delete("Note") @@ -396,7 +396,7 @@ class TestNaming(FrappeTestCase): series = "TODO-.PM.-.####" frappe.clear_cache() - with patch_hooks( + with self.patch_hooks( { "naming_series_variables": { "PM": ["frappe.tests.test_naming.parse_naming_series_variable"], diff --git a/frappe/tests/test_nestedset.py b/frappe/tests/test_nestedset.py index 8e52db93a5..cb2a3c42cc 100644 --- a/frappe/tests/test_nestedset.py +++ b/frappe/tests/test_nestedset.py @@ -8,7 +8,7 @@ from frappe.core.doctype.doctype.test_doctype import new_doctype from frappe.desk.treeview import get_children from frappe.query_builder import Field from frappe.query_builder.functions import Max -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils import random_string from frappe.utils.nestedset import ( NestedSetChildExistsError, @@ -83,7 +83,7 @@ class NestedSetTestUtil: return len(get_descendants_of(TEST_DOCTYPE, record_name, ignore_permissions=True)) -class TestNestedSet(FrappeTestCase): +class TestNestedSet(IntegrationTestCase): @classmethod def setUpClass(cls) -> None: cls.nsu = NestedSetTestUtil() diff --git a/frappe/tests/test_non_nullable_docfield.py b/frappe/tests/test_non_nullable_docfield.py index d79e6cde64..120fb38e2b 100644 --- a/frappe/tests/test_non_nullable_docfield.py +++ b/frappe/tests/test_non_nullable_docfield.py @@ -1,10 +1,10 @@ import frappe from frappe.core.doctype.doctype.test_doctype import new_doctype from frappe.database.schema import DBTable -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestNonNullableDocfield(FrappeTestCase): +class TestNonNullableDocfield(IntegrationTestCase): def setUp(self): doc = new_doctype( fields=[ diff --git a/frappe/tests/test_oauth20.py b/frappe/tests/test_oauth20.py index 83c5625bff..b76df3293f 100644 --- a/frappe/tests/test_oauth20.py +++ b/frappe/tests/test_oauth20.py @@ -9,15 +9,15 @@ from werkzeug.test import TestResponse import frappe from frappe.integrations.oauth2 import encode_params -from frappe.test_runner import make_test_records +from frappe.tests import IntegrationTestCase from frappe.tests.test_api import get_test_client, make_request, suppress_stdout -from frappe.tests.utils import FrappeTestCase +from frappe.tests.utils import make_test_records if TYPE_CHECKING: from frappe.integrations.doctype.social_login_key.social_login_key import SocialLoginKey -class FrappeRequestTestCase(FrappeTestCase): +class FrappeRequestTestCase(IntegrationTestCase): @property def sid(self) -> str: if not getattr(self, "_sid", None): diff --git a/frappe/tests/test_password.py b/frappe/tests/test_password.py index d58118d6f7..098ce36d07 100644 --- a/frappe/tests/test_password.py +++ b/frappe/tests/test_password.py @@ -3,11 +3,11 @@ from cryptography.fernet import Fernet import frappe -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase from frappe.utils.password import check_password, decrypt, encrypt, passlibctx, update_password -class TestPassword(FrappeTestCase): +class TestPassword(IntegrationTestCase): def setUp(self): frappe.delete_doc("Email Account", "Test Email Account Password") frappe.delete_doc("Email Account", "Test Email Account Password-new") diff --git a/frappe/tests/test_patches.py b/frappe/tests/test_patches.py index 2e803708e5..fc6e466bed 100644 --- a/frappe/tests/test_patches.py +++ b/frappe/tests/test_patches.py @@ -3,7 +3,7 @@ from unittest.mock import mock_open, patch import frappe from frappe.modules import patch_handler -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase EMTPY_FILE = "" EMTPY_SECTION = """ @@ -48,7 +48,7 @@ app.module.patch4 """ -class TestPatches(FrappeTestCase): +class TestPatches(IntegrationTestCase): def test_patch_module_names(self): frappe.flags.final_patches = [] frappe.flags.in_install = True @@ -78,7 +78,7 @@ class TestPatches(FrappeTestCase): self.assertGreaterEqual(finished_patches, len(all_patches)) -class TestPatchReader(FrappeTestCase): +class TestPatchReader(IntegrationTestCase): def get_patches(self): return ( patch_handler.get_patches_from_app("frappe"), diff --git a/frappe/tests/test_pdf.py b/frappe/tests/test_pdf.py index 243cd0f7b2..84bf5e0895 100644 --- a/frappe/tests/test_pdf.py +++ b/frappe/tests/test_pdf.py @@ -7,10 +7,10 @@ from pypdf import PdfReader import frappe import frappe.utils.pdf as pdfgen from frappe.core.doctype.file.test_file import make_test_image_file -from frappe.tests.utils import FrappeTestCase +from frappe.tests import IntegrationTestCase -class TestPdf(FrappeTestCase): +class TestPdf(IntegrationTestCase): @property def html(self): return """