* fix(query): check standard field definitions Signed-off-by: Akhil Narang <me@akhilnarang.dev> * fix(postgres): fix order_by problem in pg * fix(postgres): fix order_by in get_all for _test_connection_query * fix: add check to a proper numeric fallback in _get_ifnull_fallback * test(postgres): fix pg query used in assertion in test_permission_query * fix(postgres): fix order_by in get_all for possible_link * fix(postgres): fix order_by in get_all for set_modules * fix(postgres): fix pg query count * * fix(postgres): fix order_by in get_all for ask_pass_update * fix(postgres): fix order_by statement in search_widget * fix(postgres): fix order_by in get_list for get_stats * test(postgres): normalize_sql for pg queries in test_arithmetic_operators_in_fields * test(postgres): normalize_sql for pg queries in test_field_alias_in_group_by * test(postgres): normalize_sql for pg queries in test_field_alias_permission_check * test(postgres): fix order_by statement in get_all for test_db_keywords_as_fields * test(postgres): fix order_by statement in get_all for test_prepare_select_args * fix(treeview): use 0 instead of false to check since check field is an integer * fix(postgres): fix order_by in get_all for sync_communication * fix(postgres): fix order_by in get_all for get_references_across_doctypes_by_dynamic_link_field * test(postgres): fix order_by in get_all for test_list_summary * fix(postgres): fix order_by in get_all for email queries * test(postgres): use order_by none and update assertion for postgres * fix(postgres): use ILIKE to support case insensitive search in postgres * test(test_query): update pg specific query assert to use ILIKE * test(test_query): update test_nested_filters to use ilike instead for PG * test(postgres): update pg query in assert to test updated qb query * fix(search): update query to be db-agnostic * test(postgres): normalize query for pg in test_build_match_conditions * fix(postgres): suppress ORDER BY when SELECT DISTINCT in query for postgres specific behavior * fix(postgres): suppress ORDER BY when GROUP BY is explicitly asked for pg specific behavior * test(postgres): fix test behavior for pg ORDER BY drop when used with GROUP BY * refactor: reducing noise in code by formatting code * fix(query): use Star() to handle SQL wildcard character * correctly * fix(postgres): display warning for ORDER BY fields that will be dropped --------- Signed-off-by: Akhil Narang <me@akhilnarang.dev> Co-authored-by: Akhil Narang <me@akhilnarang.dev> |
||
|---|---|---|
| .. | ||
| classes | ||
| data | ||
| utils | ||
| __init__.py | ||
| README.md | ||
| test_api.py | ||
| test_api_v2.py | ||
| test_assign.py | ||
| test_auth.py | ||
| test_background_jobs.py | ||
| test_base_document.py | ||
| test_boilerplate.py | ||
| test_boot.py | ||
| test_caching.py | ||
| test_child_table.py | ||
| test_client.py | ||
| test_client_cache.py | ||
| test_config.py | ||
| test_cors.py | ||
| test_dashboard_connections.py | ||
| test_db.py | ||
| test_db_query.py | ||
| test_db_update.py | ||
| test_defaults.py | ||
| test_deferred_insert.py | ||
| test_docstatus.py | ||
| test_document.py | ||
| test_document_locks.py | ||
| test_domainification.py | ||
| test_dynamic_links.py | ||
| test_email.py | ||
| test_exporter_fixtures.py | ||
| test_fixture_import.py | ||
| test_fmt_datetime.py | ||
| test_fmt_money.py | ||
| test_form_load.py | ||
| test_formatter.py | ||
| test_frappe_client.py | ||
| test_global_search.py | ||
| test_goal.py | ||
| test_helpers.py | ||
| test_hooks.py | ||
| test_linked_with.py | ||
| test_listview.py | ||
| test_local_proxy.py | ||
| test_model_utils.py | ||
| test_modules.py | ||
| test_monitor.py | ||
| test_naming.py | ||
| test_nestedset.py | ||
| test_non_nullable_docfield.py | ||
| test_oauth20.py | ||
| test_password.py | ||
| test_password_strength.py | ||
| test_patches.py | ||
| test_pdf.py | ||
| test_perf.py | ||
| test_permissions.py | ||
| test_printview.py | ||
| test_project_meta.py | ||
| test_query.py | ||
| test_query_builder.py | ||
| test_query_report.py | ||
| test_rate_limiter.py | ||
| test_rating.py | ||
| test_recorder.py | ||
| test_redis.py | ||
| test_rename_doc.py | ||
| test_reportview.py | ||
| test_safe_exec.py | ||
| test_scheduler.py | ||
| test_search.py | ||
| test_seen.py | ||
| test_sequence.py | ||
| test_sitemap.py | ||
| test_sqlite_search.py | ||
| test_test_utils.py | ||
| test_trace.py | ||
| test_translate.py | ||
| test_twofactor.py | ||
| test_utils.py | ||
| test_virtual_doctype.py | ||
| test_webform.py | ||
| test_website.py | ||
| translation_test_file.txt | ||
| ui_test_helpers.py | ||
Frappe Test Framework
This README provides an overview of the test case framework available in Frappe. These utilities are designed to facilitate efficient and effective testing of Frappe applications.
This is different from the frappe.testing module which houses the discovery and runner infrastructure for CLI and CI.
Directory Structure
The test framework is organized into the following structure:
frappe/tests/
├── classes/
│ ├── context_managers.py
│ ├── unit_test_case.py
│ └── ...
├── utils/
│ ├── generators.py
│ └── ...
├── test_api.py
├── test_child_table.py
└── ...
Key Components
- Test case classes (UnitTestCase and IntegrationTestCase)
- Framework and class specific context managers
- Utility functions and generators
- Specific test modules for various Frappe components
Test Case Classes
UnitTestCase (classes/unit_test_case.py)
Import convention: from frappe.tests import UnitTestCase
This class extends unittest.TestCase and provides additional utilities specific to the Frappe framework. It's designed for testing individual components or functions in isolation.
Key features include:
- Custom assertions for Frappe-specific comparisons
- Utilities for HTML and SQL normalization
- Context managers for user switching and time freezing
IntegrationTestCase (classes/integration_test_case.py)
Import convention: from frappe.tests import IntegrationTestCase
This class extends UnitTestCase and is designed for integration testing. It provides features for:
- Automatic site and connection setup
- Automatic test records loading
- Automatic reset of thread locals
- Context managers that depend on a site connection
- Asserts that depend on a site connection
For a detailed list of context managers, please refer to the code.
Utility Functions and Generators (utils/generators.py)
This module contains utility functions for generating test records and managing test data.
Specific Test Modules
Various test modules (e.g., test_api.py, test_document.py) contain tests for specific Frappe core components and functionalities.
Note that Document tests are collocated alongside each Document module.
Usage
To use these test utilities in your Frappe application tests, you can inherit from the appropriate test case class:
from frappe.tests import UnitTestCase
class MyTestCase(UnitTestCase):
def test_something(self):
# Your test code here
pass
Contributing
When adding new test utilities or modifying existing ones:
- Place them in the appropriate directory based on their function.
- Update this README to reflect any significant changes in the framework structure or usage.
- Ensure that your changes follow the existing coding style and conventions.
Remember to always refer to the actual code for the most up-to-date and detailed information on available methods and their usage.