Skip to content

Commit

Permalink
Reinstate Forbidding parser logs from being published
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Jun 4, 2024
1 parent 1bcce7b commit 7918bdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ds-caselaw-ingester/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ class DocumentInsertionError(ReportableException):
pass


class ErrorLogWouldOverwritePublishedDocument(ReportableException):
pass


def modify_filename(original: str, addition: str) -> str:
"Add an addition after the filename, so TRE-2024-A.tar.gz becomes TRE-2024-A_nodocx.tar.gz"
path, basename = os.path.split(original)
Expand Down
21 changes: 13 additions & 8 deletions ds-caselaw-ingester/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def create_fake_bulk_file(*args, **kwargs):
shutil.copyfile(BULK_TARBALL_PATH, "/tmp/BULK-0.tar.gz")


def assert_log_sensible(log):
assert "Ingester Start: Consignment reference" in log
assert "tar.gz saved locally as" in log
assert "Ingesting document" in log
assert "Updated judgment xml" in log
assert "Upload Successful" in log
assert "Ingestion complete" in log
assert "Invalid XML file" not in log
assert "No XML file found" not in log


@pytest.fixture
@patch(
"lambda_function.Ingest.save_tar_file_in_s3",
Expand Down Expand Up @@ -131,6 +142,7 @@ def test_handler_messages_v2(
apiclient,
capsys,
):

boto_session.return_value.client.return_value.download_file = (
create_fake_tdr_file
)
Expand All @@ -142,15 +154,8 @@ def test_handler_messages_v2(
lambda_function.handler(event=event, context=None)

log = capsys.readouterr().out
assert "Ingester Start: Consignment reference TDR-2022-DNWR" in log
assert "tar.gz saved locally as /tmp/TDR-2022-DNWR.tar.gz" in log
assert "Ingesting document" in log
assert "Updated judgment xml" in log
assert "Upload Successful" in log
assert "Ingestion complete" in log
assert_log_sensible(log)
assert "publishing" not in log
assert "Invalid XML file" not in log
assert "No XML file found" not in log
assert "image1.png" in log
notify_update.assert_called()
assert notify_update.call_count == 2
Expand Down

0 comments on commit 7918bdc

Please sign in to comment.