Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MarklogicCommunicationErrors to crash ingester #94

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions ds-caselaw-ingester/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from caselawclient.Client import (
DEFAULT_USER_AGENT,
MarklogicApiClient,
MarklogicCommunicationError,
MarklogicResourceNotFoundError,
)
from dotenv import load_dotenv
Expand Down Expand Up @@ -380,16 +379,13 @@ def update_judgment_xml(uri, xml) -> bool:
api_client.get_judgment_xml(uri, show_unpublished=True)
api_client.save_judgment_xml(uri, xml)
return True
except (MarklogicResourceNotFoundError, MarklogicCommunicationError):
except MarklogicResourceNotFoundError:
return False


def insert_document_xml(uri, xml) -> bool:
try:
api_client.insert_document_xml(uri, xml)
return True
except MarklogicCommunicationError:
return False
api_client.insert_document_xml(uri, xml)
return True


def get_best_xml(uri, tar, xml_file_name, consignment_reference):
Expand Down
8 changes: 4 additions & 4 deletions ds-caselaw-ingester/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,8 @@ def test_update_judgment_xml_judgment_does_not_save(self, api_client):
api_client.save_judgment_xml = MagicMock(
side_effect=MarklogicCommunicationError("error")
)
result = lambda_function.update_judgment_xml("a/fake/uri", xml)
assert result is False
with pytest.raises(MarklogicCommunicationError):
lambda_function.update_judgment_xml("a/fake/uri", xml)

@patch("lambda_function.api_client")
def test_insert_document_xml_success(self, api_client):
Expand All @@ -686,8 +686,8 @@ def test_insert_document_xml_failure(self, api_client):
api_client.insert_document_xml = MagicMock(
side_effect=MarklogicCommunicationError("error")
)
result = lambda_function.insert_document_xml("a/fake/uri", xml)
assert result is False
with pytest.raises(MarklogicCommunicationError):
lambda_function.insert_document_xml("a/fake/uri", xml)

def test_get_best_xml_with_valid_xml_file(self):
filename = "TDR-2022-DNWR.xml"
Expand Down