def test_project_client_get(mocker): mocker.patch.object(ProjectClient, "_get", return_value=PROJECT) schema_mock = mocker.patch("faculty.clients.project._ProjectSchema") client = ProjectClient(mocker.Mock(), mocker.Mock()) assert client.get(PROJECT.id) == PROJECT schema_mock.assert_called_once_with() ProjectClient._get.assert_called_once_with( "/project/{}".format(PROJECT.id), schema_mock.return_value)
def test_project_client_list_accessible_by_user(mocker): mocker.patch.object(ProjectClient, "_get", return_value=[PROJECT]) schema_mock = mocker.patch("faculty.clients.project._ProjectSchema") client = ProjectClient(mocker.Mock(), mocker.Mock()) assert client.list_accessible_by_user(USER_ID) == [PROJECT] schema_mock.assert_called_once_with(many=True) ProjectClient._get.assert_called_once_with("/user/{}".format(USER_ID), schema_mock.return_value)
def test_project_client_get_by_owner_and_name(mocker): mocker.patch.object(ProjectClient, "_get", return_value=PROJECT) schema_mock = mocker.patch("faculty.clients.project.ProjectSchema") client = ProjectClient(mocker.Mock()) assert client.get_by_owner_and_name(USER_ID, PROJECT.name) == PROJECT schema_mock.assert_called_once_with() ProjectClient._get.assert_called_once_with( "/project/{}/{}".format(USER_ID, PROJECT.name), schema_mock.return_value, )
def test_project_client_create(mocker): mocker.patch.object(ProjectClient, "_post", return_value=PROJECT) schema_mock = mocker.patch("faculty.clients.project._ProjectSchema") client = ProjectClient(mocker.Mock(), mocker.Mock()) assert client.create(PROJECT.owner_id, PROJECT.name) == PROJECT schema_mock.assert_called_once_with() ProjectClient._post.assert_called_once_with( "/project", schema_mock.return_value, json={"owner_id": str(PROJECT.owner_id), "name": PROJECT.name}, )
def test_project_client_list_all(mocker, include_archived, include_archived_param): mocker.patch.object(ProjectClient, "_get", return_value=[PROJECT]) schema_mock = mocker.patch("faculty.clients.project._ProjectSchema") client = ProjectClient(mocker.Mock(), mocker.Mock()) assert client.list_all(include_archived) == [PROJECT] schema_mock.assert_called_once_with(many=True) ProjectClient._get.assert_called_once_with( "/project", schema_mock.return_value, params={"includeArchived": include_archived_param}, )