"""Unit tests for worksheet_correction marshmallow schemas.""" from decimal import Decimal from abacus_worksheet.schemas import worksheet_correction from tests.utils.factories import WorksheetCorrectionFactory def test_worksheet_correction_detail_schema(): """Test worksheet_correction detail marshmallow schema.""" correction = WorksheetCorrectionFactory.create( mechanical_deduction_total=Decimal(80.89), mechanical_deduction_admin_fee_total=Decimal(78.11), ) res = worksheet_correction.WorksheetCorrectionDetailSchema().dump(correction) assert res == { 'account_id': correction.account_id, 'contract_id': correction.contract_id, 'correction_statement_period_id': correction.correction_statement_period_id, 'correction_type': correction.correction_type, 'currency_code': correction.currency_code, 'gross_revenue': str(correction.gross_revenue), 'distribution_fee': str(correction.distribution_fee), 'mechanical_deduction_total': str(correction.mechanical_deduction_total), 'mechanical_deduction_admin_fee_total': str( correction.mechanical_deduction_admin_fee_total ), 'net_revenue': str(correction.net_revenue), 'note': correction.note, 'statement_period_id': correction.statement_period_id, 'worksheet_correction_id': correction.worksheet_correction_id, }