vendor_bill_editable_totals/tests/INTEGRATION_TESTS.md
2025-11-21 18:02:20 +07:00

103 lines
3.6 KiB
Markdown

# Integration Tests for Vendor Bill Editable Totals
## Overview
This document describes the integration tests implemented for the `vendor_bill_editable_totals` module.
## Test Coverage
The integration tests verify the following workflows and requirements:
### 1. Full Workflow - Modify price_subtotal (Requirement 4.3)
- Creates a vendor bill with invoice lines
- Modifies the `price_subtotal` field
- Verifies that `price_unit` is automatically recalculated
- Saves the bill and verifies persistence
- Validates that `price_total` is correctly computed with taxes
### 2. Full Workflow - Modify price_total (Requirement 4.3)
- Creates a vendor bill with invoice lines and taxes
- Modifies the `price_total` field
- Verifies that `price_unit` is automatically recalculated
- Ensures `price_subtotal` is correctly derived from `price_total`
- Saves the bill and verifies persistence
### 3. Multiple Lines Workflow (Requirement 4.3)
- Creates a vendor bill with multiple invoice lines
- Modifies different fields on different lines
- Verifies that each line is calculated independently
- Ensures no interference between lines
### 4. Compatibility with Standard Validations (Requirement 4.3)
- Verifies that standard Odoo validations still work
- Tests that standard compute methods function correctly
- Ensures the module doesn't break existing Odoo behavior
- Validates that bills can be saved after modifications
### 5. Refund Workflow (Requirement 4.3)
- Creates a vendor refund (credit note)
- Tests with negative values
- Verifies calculations work correctly with negative amounts
- Ensures refunds can be saved
### 6. No Interference with Other Move Types (Requirement 4.2)
- Creates a customer invoice (out_invoice)
- Attempts to modify totals
- Verifies that the module only affects vendor bills
- Ensures customer invoices are not affected
## Running the Tests
### Standalone Tests
The standalone integration tests can be run without a full Odoo database:
```bash
python3 customaddons/vendor_bill_editable_totals/tests/run_integration_tests.py
```
### Full Odoo Integration Tests
For complete integration testing with Odoo's test framework:
```bash
python3 odoo/odoo-bin -c odoo.conf --test-enable --stop-after-init \
-d odoo17 -u vendor_bill_editable_totals --log-level=test
```
Or to run only the integration tests:
```bash
python3 odoo/odoo-bin -c odoo.conf --test-enable --stop-after-init \
-d odoo17 --test-tags vendor_bill_editable_totals.test_integration
```
## Test Files
- `test_integration.py` - Full Odoo integration tests using TransactionCase
- `run_integration_tests.py` - Standalone test runner with mock objects
## Test Results
All integration tests pass successfully:
- ✓ Full workflow - modify price_subtotal
- ✓ Full workflow - modify price_total
- ✓ Multiple lines workflow
- ✓ Compatibility with standard validations
- ✓ Refund workflow
- ✓ No interference with other move types
## Requirements Validated
These integration tests validate the following requirements:
- **Requirement 4.2**: Module doesn't interfere with standard Odoo flows
- **Requirement 4.3**: Standard Odoo validations and computations work correctly
## Notes
The integration tests complement the existing test suite:
- **Unit tests** (`test_edge_cases.py`) - Test specific scenarios and edge cases
- **Property-based tests** - Test universal properties across random inputs
- **Integration tests** - Test full workflows from creation to save
- **View tests** (`test_view_configuration.py`) - Test UI configuration
Together, these tests provide comprehensive coverage of the module's functionality.