Skip to content

Commit

Permalink
Fix incorrect way of getting whether the document is published
Browse files Browse the repository at this point in the history
Document.is_published() or api_client.get_published()
  • Loading branch information
dragon-dxw committed Jun 5, 2024
1 parent 9cdfa66 commit 3bffee6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions ds-caselaw-ingester/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
)
from caselawclient.client_helpers import VersionAnnotation, VersionType
from caselawclient.errors import DocumentNotFoundError
from caselawclient.models.documents import Document
from dotenv import load_dotenv
from notifications_python_client.notifications import NotificationsAPIClient

Expand Down Expand Up @@ -496,7 +495,7 @@ def process_message(message):
is_akoma = xml.tag == "{http://docs.oasis-open.org/legaldocml/ns/akn/3.0}akomaNtoso"

try:
target_published = Document(uri, api_client).get_published()
target_published = api_client.get_published(uri)
except DocumentNotFoundError: # the target does not exist
target_published = False

Expand Down
8 changes: 2 additions & 6 deletions ds-caselaw-ingester/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ class TestHandler:
@patch("lambda_function.send_new_judgment_notification")
@patch("lambda_function.VersionAnnotation")
@patch("lambda_function.modify_filename")
@patch("lambda_function.Document")
def test_handler_messages_v2(
self,
document,
modify_filename,
annotation,
notify_new,
Expand All @@ -106,7 +104,7 @@ def test_handler_messages_v2(
capsys,
):

document.return_value.get_published.return_value = False
apiclient.return_value.get_published.return_value = False
boto_session.return_value.client.return_value.download_file = (
create_fake_tdr_file
)
Expand Down Expand Up @@ -140,10 +138,8 @@ def test_handler_messages_v2(
@patch("lambda_function.send_updated_judgment_notification")
@patch("lambda_function.VersionAnnotation")
@patch("lambda_function.modify_filename")
@patch("lambda_function.Document")
def test_handler_messages_s3(
self,
document,
modify_filename,
annotation,
notify_new,
Expand All @@ -156,7 +152,7 @@ def test_handler_messages_s3(
boto_session.return_value.client.return_value.download_file = (
create_fake_bulk_file
)
document.return_value.get_published.return_value = False
apiclient.return_value.get_published.return_value = False

message = s3_message_raw
event = {
Expand Down

0 comments on commit 3bffee6

Please sign in to comment.