* feat: Style builder for report xlsx formatting * fix: update report to use direct import for query report execution * refactor: simplify module method retrieval in report execution * feat: get xlsx styles for report * refactor: enhance XLSXStyleBuilder with currency formatting and default style registration * feat: add xlsxwriter dependency for enhanced XLSX report generation * refactor: enhance XLSXStyleBuilder with improved style registration and formatting methods * feat: enhance XLSX export functionality with improved styling and metadata support * refactor: default formatting of currency * chore: remove some typo * feat: update make_xlsx function to use xlsxwriter for improved Excel file generation and styling * perf: some micro optimisations * refactor: inline generator back and improve condition * refactor: replace frappe.request_cache with functools.cache * fix: handle styling in email * fix: fix old test case to handle styles in export * refactor: enhance XLSX style handling and registration methods * refactor: improve currency formatting logic * fix: update make_xlsx to use constant_memory for large datasets and improve row style handling * fix: handle None style_id in XLSXStyleBuilder methods to prevent errors * fix: include owner field with proper doctype naming * fix: set default date format in XLSX workbook creation * fix: pass applied filters to metadata * fix: getting accurate field info for report view exporting * chore: Minor changes * feat: add function to generate default XLSX styles for exports * feat: integrate default XLSX styles into builder report export functionality * feat: styles on export docs xlsx * feat: enhance make_xlsx function to support file path saving * feat: add make_xls function for creating Excel files in old format and improve sheet name sanitization * fix: handle default date formatting * refactor: changes xlsx builder usage * refactor: update xlsx style builder usage * refactor: enhance field info retrieval with default field support * fix: handle update key in report data * refactor: enhance get_field_info to include options and improve label retrieval * fix: improve error handling for unsupported file formats and ensure applied filters are set correctly * refactor: update XLSX header index handling and improve metadata structure * fix: handle currency formatting in reportview export * fix: update default date format to datetime format in XLSX creation * fix: update serial number field in auto email report to use 'sr' instead of 'idx' * fix: enhance XLSX styling by adding right alignment for specific field types * chore: remove unused code * fix: update XLSXMetadata attributes for improved report styling options * perf: further improve currency styling * fix: correct column index mapping in XLSX export header * refactor: optimize indentation style registration in XLSXStyleBuilder * perf: improve apply_indentations * fix: reduce more attr lookup * refactor: remove duplication * fix: use report name in XLSX export instead of hardcoded title * fix: remove ignore_visible_idx from XLSXMetadata * fix: review * fix: update XLSX style fetching logic in build_xlsx_data function * fix: add right alignment to date, time, and datetime styles in XLSXStyleBuilder * fix: simplify number format handling in XLSXStyleBuilder * fix: register common styles in XLSXStyleBuilder for improved style management * test: add tests for XLSX styles structure and fieldtype column styles in XLSXStyleBuilder --------- Co-authored-by: Sagar Vora <16315650+sagarvora@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| 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_removing_orphans.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.