Skip to content

Commit

Permalink
Fix press summary urls
Browse files Browse the repository at this point in the history
Enriched press summaries were being submitted to /judgment-url/press/summary/1?unlock=True,
not press-summary.

We special case press-summary as a quick fix.
  • Loading branch information
dragon-dxw committed Oct 30, 2024
1 parent 9957eca commit 31aff74
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v6.0.2 (2024-10-03)

- Enrich press summaries by fixing patch url to be press-summary, not press/summary

## v6.0.1 (2024-07-16)

- Fix CI by reflecting changed output from legislation SPARQL output
Expand Down
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[pytest]
addopts = --disable-socket --allow-hosts=127.0.0.1 --allow-hosts=localhost
env =
SOURCE_BUCKET=X
API_USERNAME=X
API_PASSWORD=X
ENVIRONMENT=X
2 changes: 1 addition & 1 deletion src/lambdas/determine_legislation_provisions/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def add_timestamp_and_engine_version(
"uk:tna-enrichment-engine",
attrs={"xmlns:uk": "https://caselaw.nationalarchives.gov.uk/akn"},
)
enrichment_version.string = "6.0.1"
enrichment_version.string = "6.0.2"

if not soup.proprietary:
msg = "This document does not have a <proprietary> element."
Expand Down
1 change: 1 addition & 0 deletions src/lambdas/push_enriched_xml/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def process_event(sqs_rec: SQSRecord) -> None:

print(source_key)
judgment_uri = source_key.replace("-", "/").split(".")[0]
judgment_uri = judgment_uri.replace("press/summary", "press-summary")
print(judgment_uri)

# patch the judgment
Expand Down
28 changes: 28 additions & 0 deletions src/tests/lambda_tests/push_enriched_xml/test_push_enriched_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# from lambdas.push_enriched_xml.index import ( # noqa: E402
# process_event,
# )
from unittest.mock import patch

from lambdas.push_enriched_xml.index import ( # noqa: E402
process_event,
)


class FakeSQSRecord(dict):
def __init__(self):
self.body = '{"Validated": true}'
self["messageAttributes"] = {
"source_key": {"stringValue": "uksc/2024/1/press-summary/1"},
"source_bucket": {"stringValue": ""},
}
self["Validated"] = None


@patch("lambdas.push_enriched_xml.index.boto3")
@patch("lambdas.push_enriched_xml.index.requests")
def test_patch_url_has_press_summary_with_a_hyphen(requests, boto3):
process_event(FakeSQSRecord())
assert (
requests.patch.call_args_list[0][0][0]
== "https://api.caselaw.nationalarchives.gov.uk/judgment/uksc/2024/1/press-summary/1"
)
1 change: 1 addition & 0 deletions src/tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ds-caselaw-marklogic-api-client==25.0.0
boto3-stubs[essential] ==1.35.49
aws_lambda_powertools ==3.2.0
pytest-socket==0.7.0
pytest-env==1.1.5

0 comments on commit 31aff74

Please sign in to comment.