"""Unit testcases for ledger_contract_flowthrough handlers.""" from unittest.mock import patch from owsresponse import response @patch('ledger.blueprints.ledger_contract_flowthrough.logic') def test_bulk_create_ledger_contract_flowthrough_entries(mock_logic, fixture_client): """Test endpoint to create ledger_contract_flowthrough entries.""" mock_logic.handle_bulk_ledger_entries.return_value = response.Response( message={'message': 'OK'}, status=201 ) mock_post_request = [ { 'currency_amount': 44.44, 'currency_code': 'USD', 'abacus_event_id': 1, 'model_type': 'account', 'account_id': 1, 'contract_id': 1, }, { 'currency_code': 'USD', 'abacus_event_id': 1, 'model_type': 'deposit', 'remaining_amount': 0.004444444444444444, 'rounded_amount': 44.44, 'contract_id': 1, 'account_id': 1, }, ] res = fixture_client.post( '/ledger-contract-flowthrough/bulk', json=mock_post_request ) assert res.status_code == 201 assert res.json == {'message': 'OK'} mock_logic.handle_bulk_ledger_entries.assert_called_once()