Skip to content

Commit

Permalink
Rename notify_changed to announce_document_event
Browse files Browse the repository at this point in the history
This makes it clearer what this function is actually doing; it's not
telling people the document has changed, it's notifying them of an
event.
  • Loading branch information
jacksonj04 committed Nov 28, 2023
1 parent a0da8bb commit ed54b68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/caselawclient/models/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from .utilities import VersionsDict, get_judgment_root, render_versions
from .utilities.aws import (
ParserInstructionsDict,
announce_document_event,
delete_documents_from_private_bucket,
generate_docx_url,
generate_pdf_url,
notify_changed,
publish_documents,
request_parse,
unpublish_documents,
Expand Down Expand Up @@ -450,7 +450,7 @@ def status(self) -> str:
return DOCUMENT_STATUS_NEW

def enrich(self) -> None:
notify_changed(
announce_document_event(
uri=self.uri,
status="published",
enrich=True,
Expand All @@ -466,7 +466,7 @@ def publish(self) -> None:

publish_documents(uri_for_s3(self.uri))
self.api_client.set_published(self.uri, True)
notify_changed(
announce_document_event(
uri=self.uri,
status="published",
enrich=True,
Expand All @@ -476,7 +476,7 @@ def unpublish(self) -> None:
self.api_client.break_checkout(self.uri)
unpublish_documents(uri_for_s3(self.uri))
self.api_client.set_published(self.uri, False)
notify_changed(
announce_document_event(
uri=self.uri,
status="not published",
enrich=False,
Expand Down
2 changes: 1 addition & 1 deletion src/caselawclient/models/utilities/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def delete_documents_from_private_bucket(uri: str) -> None:
delete_from_bucket(uri, env("PRIVATE_ASSET_BUCKET"))


def notify_changed(uri: str, status: str, enrich: bool = False) -> None:
def announce_document_event(uri: str, status: str, enrich: bool = False) -> None:
client = create_sns_client()

message_attributes: dict[str, MessageAttributeValueTypeDef] = {}
Expand Down
12 changes: 6 additions & 6 deletions tests/models/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,31 +362,31 @@ def test_publish_fails_if_not_publishable(self, mock_api_client):
document.publish()
mock_api_client.set_published.assert_not_called()

@patch("caselawclient.models.documents.notify_changed")
@patch("caselawclient.models.documents.announce_document_event")
@patch("caselawclient.models.documents.publish_documents")
def test_publish(
self, mock_publish_documents, mock_notify_changed, mock_api_client
self, mock_publish_documents, mock_announce_document_event, mock_api_client
):
document = Document("test/1234", mock_api_client)
document.is_publishable = True
document.publish()
mock_publish_documents.assert_called_once_with("test/1234")
mock_api_client.set_published.assert_called_once_with("test/1234", True)
mock_notify_changed.assert_called_once_with(
mock_announce_document_event.assert_called_once_with(
uri="test/1234", status="published", enrich=True
)

@patch("caselawclient.models.documents.notify_changed")
@patch("caselawclient.models.documents.announce_document_event")
@patch("caselawclient.models.documents.unpublish_documents")
def test_unpublish(
self, mock_unpublish_documents, mock_notify_changed, mock_api_client
self, mock_unpublish_documents, mock_announce_document_event, mock_api_client
):
document = Document("test/1234", mock_api_client)
document.unpublish()
mock_unpublish_documents.assert_called_once_with("test/1234")
mock_api_client.set_published.assert_called_once_with("test/1234", False)
mock_api_client.break_checkout.assert_called_once_with("test/1234")
mock_notify_changed.assert_called_once_with(
mock_announce_document_event.assert_called_once_with(
uri="test/1234", status="not published", enrich=False
)

Expand Down

0 comments on commit ed54b68

Please sign in to comment.