Skip to content

Commit

Permalink
#250: Add test to mock Python ICAT data update failure
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Aug 13, 2021
1 parent f6e8ebd commit 01cb60c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/icat/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from unittest.mock import patch

from icat.exception import ICATInternalError
import pytest

from datagateway_api.common.exceptions import BadRequestError
from datagateway_api.common.icat.helpers import get_icat_entity_name_as_camel_case
from datagateway_api.common.exceptions import BadRequestError, PythonICATError
from datagateway_api.common.icat.helpers import (
get_icat_entity_name_as_camel_case,
push_data_updates_to_icat,
)


class TestICATHelpers:
Expand Down Expand Up @@ -32,3 +38,12 @@ def test_valid_get_icat_entity_name_as_camel_case(
def test_invalid_get_icat_entity_name_as_camel_case(self, icat_client):
with pytest.raises(BadRequestError):
get_icat_entity_name_as_camel_case(icat_client, "UnknownEntityName")

def test_invalid_update_pushes(self, icat_client):
with patch(
"icat.entity.Entity.update",
side_effect=ICATInternalError("Mocked Exception"),
):
inv_entity = icat_client.new("investigation", name="Investigation A")
with pytest.raises(PythonICATError):
push_data_updates_to_icat(inv_entity)

0 comments on commit 01cb60c

Please sign in to comment.