"""Tests for the report handlers.""" import json from unittest.mock import patch from tests.testutils import mock_auth @patch("collaborator.logic.recipient.get_by_id") @patch("collaborator.logic.recipient.check_can_access_recipient_data") def test_get_recipient( mock_access_by_id, mock_get_by_id, mock_account, auth_client, mocker ): """Test getting recipient by id.""" mock_auth(mocker, 6666) mock_access_by_id.return_value = None mock_get_by_id.return_value = {"id": 1} result = auth_client.get("/recipient/1") assert result.status_code == 200 mock_get_by_id.assert_called_with(1) @patch("collaborator.logic.recipient.get_by_ids") @patch("collaborator.logic.recipient.check_can_access_recipient_data") def test_get_recipients_by_id( mock_access_by_id, mock_get_by_id, mock_account, auth_client, mocker ): """Test getting multiple recipients by id.""" mock_auth(mocker, 6666) mock_access_by_id.return_value = None mock_get_by_id.return_value = [{"id": 1}] body = {"recipient_ids": [1, 2]} result = auth_client.post( "/recipient/dataloader", data=json.dumps(body), content_type="application/json" ) assert result.status_code == 200 mock_get_by_id.assert_called_with([1, 2])