Skip to content

Test suite refactor - #440

Draft
Sachin1043 wants to merge 3 commits into
frappe:developfrom
aerele:test-suite-refactor
Draft

Test suite refactor#440
Sachin1043 wants to merge 3 commits into
frappe:developfrom
aerele:test-suite-refactor

Conversation

@Sachin1043

Copy link
Copy Markdown

Refactor: modernize the ecommerce_integrations test suite

Summary

Migrates every integration's tests (Amazon, Shopify, Unicommerce) onto a single shared test-suite base, modernizes the app's source for ERPNext v16, and bumps dependencies. Net effect is a leaner, self-contained, and faster test suite with the app code updated to current framework APIs.

Test infrastructure

  • New shared base: ecommerce_integrations/tests/utils.py (EcommerceTestSuite) — a central suite all integration tests now inherit from, providing consistent setup, fixture loading (load_fixture), and transaction-based isolation.
  • Retired the old bootstrap: removed the before_tests hook (hooks.py) and deleted ecommerce_integrations/utils/before_test.py.
  • Per-integration test utils modernized: new amazon/tests/utils.py; rewritten shopify/tests/utils.py and unicommerce/tests/utils.py — HTTP now mocked with the responses library instead of live/ad-hoc mocks.
  • Fixtures reorganized: Amazon test_data.json moved into amazon/tests/fixtures/; removed the obsolete shopify/tests/test_order.py.
  • Rewrote the bulk of the Amazon / Shopify / Unicommerce test modules to use the shared helpers.

Source modernization (ERPNext v16 compatibility)

  • Updated ERPNext imports from the doctype controllers to the new mapper modules — make_sales_invoice, make_delivery_note, make_sales_return — across shopify/fulfillment.py, shopify/invoice.py, unicommerce/invoice.py, unicommerce/delivery_note.py, unicommerce/cancellation_and_returns.py.
  • unicommerce/invoice.py: replaced a raw frappe.db.sql UPDATE with the frappe.qb query builder.
  • ecommerce_integration_log.py: made logging test-safe — skips commit()/rollback() under frappe.flags.in_test so log writes don't break test isolation.

Efficiency cleanups

  • unicommerce/tests/utils.py: simplified the enable_setting decorator — dropped the redundant read + finally restore (per-test rollback already undoes it).
  • amazon/tests/utils.py: removed the pointless retry/time.sleep(3) loop in the mock SP-API caller (mocks are deterministic).
  • shopify/.../test_shopify_import_products.py: reuse the inherited load_fixture() instead of manual file I/O.
  • unicommerce/tests/test_customer.py: removed a redundant setUpClass override (base suite already seeds channels via the non-deprecated path).

Dependencies (pyproject.toml)

  • boto3 ~=1.28.10 -> >=1.35.0
  • Added dev-dependency responses == 0.23.1 (HTTP mocking).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants