Skip to content

Commit

Permalink
Merge pull request #722 from nationalarchives/fix-content_as_html
Browse files Browse the repository at this point in the history
fix content_as_html
  • Loading branch information
dragon-dxw authored Oct 17, 2024
2 parents 416f3e8 + bb21e90 commit 74ef5e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/caselawclient/factories.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from typing import Any, Optional, cast
from unittest.mock import Mock, patch
from unittest.mock import Mock

from typing_extensions import TypeAlias

Expand Down Expand Up @@ -63,10 +63,8 @@ def build(
api_client = Mock(spec=MarklogicApiClient)
api_client.get_judgment_xml_bytestring.return_value = DEFAULT_DOCUMENT_BODY_XML.encode(encoding="utf-8")

with patch.object(cls.target_class, "content_as_html") as mock_content_as_html:
mock_content_as_html.return_value = html
document = cls.target_class(uri, api_client=api_client)

document = cls.target_class(uri, api_client=api_client)
document.content_as_html = Mock(return_value=html) # type: ignore[method-assign]
document.body = kwargs.pop("body") if "body" in kwargs else DocumentBodyFactory.build()

for param_name, default_value in cls.PARAMS_MAP.items():
Expand Down
6 changes: 6 additions & 0 deletions tests/test_factories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from caselawclient.factories import DocumentFactory


def test_content_as_html():
doc = DocumentFactory.build()
assert doc.content_as_html() == "<p>This is a judgment.</p>"

0 comments on commit 74ef5e5

Please sign in to comment.