"""Unit tests for Payment Group Payment Batch Account handlers.""" from unittest.mock import patch from payment.schemas.payment_group_payment_batch_account import ( PaymentGroupPaymentBatchAccountSchema, ) from tests.utils.factories import PaymentGroupPaymentBatchAccountFactory @patch('payment.blueprints.payment_group_payment_batch_account.logic') def test_bulk_create_payment_group_payment_batch_account(mock_logic, fixture_client): """Test POST /payment-group-payment-batch-account/bulk/.""" mock_batches = PaymentGroupPaymentBatchAccountFactory.build_batch(2) mock_logic.bulk_create.return_value = mock_batches create_params = [ {'payment_group_payment_account_id': 1, 'payment_group_payment_batch_id': 1}, {'payment_group_payment_account_id': 2, 'payment_group_payment_batch_id': 1}, ] res = fixture_client.post( '/payment-group-payment-batch-account/bulk/', json=create_params ) assert res.status_code == 201 assert res.json == PaymentGroupPaymentBatchAccountSchema(many=True).dump( mock_batches ) mock_logic.bulk_create.assert_called_once_with(tuple(create_params))