diff --git a/judgments/tests/template_tags/test_document_utils.py b/judgments/tests/template_tags/test_document_utils.py index 356254423..c3c7e89bd 100644 --- a/judgments/tests/template_tags/test_document_utils.py +++ b/judgments/tests/template_tags/test_document_utils.py @@ -9,7 +9,7 @@ class TestDocumentUtils(unittest.TestCase): @patch("judgments.utils.formatted_document_uri") def test_formatted_document_uri(self, mock_formatted_document_uri): - document_uri = DocumentURIString("/foo/bar") + document_uri = DocumentURIString("foo/bar") formatted_document_uri(document_uri, "xml") - mock_formatted_document_uri.assert_called_with("/foo/bar", "xml") + mock_formatted_document_uri.assert_called_with("foo/bar", "xml") diff --git a/judgments/tests/test_detail.py b/judgments/tests/test_detail.py index c4627c83f..d0e6fe032 100644 --- a/judgments/tests/test_detail.py +++ b/judgments/tests/test_detail.py @@ -5,6 +5,7 @@ import pytest from caselawclient.errors import DocumentNotFoundError from caselawclient.factories import DocumentBodyFactory, JudgmentFactory, PressSummaryFactory +from caselawclient.models.documents import DocumentURIString from django.http import Http404, HttpResponseRedirect from django.template.defaultfilters import filesizeformat from django.test import Client, TestCase @@ -166,7 +167,9 @@ def test_download_options( class TestDocumentURIRedirects(TestCase): @patch("judgments.views.detail.detail_html.get_published_document_by_uri") def test_non_canonical_uri_redirects(self, mock_get_document_by_uri): - mock_get_document_by_uri.return_value = JudgmentFactory.build(uri="test/1234/567", is_published=True) + mock_get_document_by_uri.return_value = JudgmentFactory.build( + uri=DocumentURIString("test/1234/567"), is_published=True + ) response = self.client.get("/test/1234/567/") assert isinstance(response, HttpResponseRedirect) assert response.status_code == 302 @@ -197,7 +200,9 @@ def test_no_press_summary_label_when_on_judgment(self, mock_get_document_by_uri, WHEN request is made with judgment uri THEN response should NOT contain the press summary label """ - mock_get_document_by_uri.return_value = JudgmentFactory.build(uri="eat/2023/1", is_published=True) + mock_get_document_by_uri.return_value = JudgmentFactory.build( + uri=DocumentURIString("eat/2023/1"), is_published=True + ) response = self.client.get("/eat/2023/1") xpath_query = "//p[@class='judgment-toolbar__press-summary-title']" @@ -350,7 +355,7 @@ def test_breadcrumb_when_press_summary(self, mock_get_document_by_uri, mock_pdf) def get_document_by_uri_side_effect(uri, cache_if_not_found=False, search_query: Optional[str] = None): if "press" in uri: return PressSummaryFactory.build( - uri="eat/2023/1/press-summary/1", + uri=DocumentURIString("eat/2023/1/press-summary/1"), is_published=True, body=DocumentBodyFactory.build( name="Press Summary of Judgment A", @@ -358,7 +363,7 @@ def get_document_by_uri_side_effect(uri, cache_if_not_found=False, search_query: ) else: return JudgmentFactory.build( - uri="eat/2023/1/the_judgment_uri", + uri=DocumentURIString("eat/2023/1/the_judgment_uri"), is_published=True, body=DocumentBodyFactory.build( name="The Title of Judgment A", @@ -388,7 +393,7 @@ def test_breadcrumb_when_judgment(self, mock_get_document_by_uri, mock_pdf): AND NOT contain an additional `Press Summary` breadcrumb """ mock_get_document_by_uri.return_value = JudgmentFactory.build( - uri="eat/2023/1", + uri=DocumentURIString("eat/2023/1"), is_published=True, body=DocumentBodyFactory.build( name="Judgment A", @@ -444,7 +449,7 @@ def test_document_headings_when_press_summary(self, mock_get_document_by_uri, mo def get_document_by_uri_side_effect(document_uri, cache_if_not_found=False, search_query: Optional[str] = None): if document_uri == "eat/2023/1/press-summary/1": return PressSummaryFactory.build( - uri="eat/2023/1/press-summary/1", + uri=DocumentURIString("eat/2023/1/press-summary/1"), is_published=True, body=DocumentBodyFactory.build( name="Press Summary of Judgment A (with some slightly different wording)", @@ -453,7 +458,7 @@ def get_document_by_uri_side_effect(document_uri, cache_if_not_found=False, sear ) elif document_uri == "eat/2023/1": return JudgmentFactory.build( - uri="eat/2023/1", + uri=DocumentURIString("eat/2023/1"), is_published=True, body=DocumentBodyFactory.build( name="Judgment A", @@ -481,7 +486,7 @@ def test_document_headings_when_judgment(self, mock_get_document_by_uri, mock_pd AND a p tag subheading with the judgment's NCN """ mock_get_document_by_uri.return_value = JudgmentFactory.build( - uri="eat/2023/1", + uri=DocumentURIString("eat/2023/1"), is_published=True, body=DocumentBodyFactory.build(name="Judgment A"), neutral_citation="Judgment_A_NCN", @@ -508,7 +513,7 @@ def test_html_title_when_press_summary(self, mock_get_document_by_uri, mock_pdf) def get_document_by_uri_side_effect(document_uri, cache_if_not_found=False, search_query: Optional[str] = None): if document_uri == "eat/2023/1/press-summary/1": return JudgmentFactory.build( - uri="eat/2023/1/press-summary/1", + uri=DocumentURIString("eat/2023/1/press-summary/1"), is_published=True, body=DocumentBodyFactory.build( name="Press Summary of Judgment A (with some slightly different wording)" @@ -516,7 +521,7 @@ def get_document_by_uri_side_effect(document_uri, cache_if_not_found=False, sear ) else: return JudgmentFactory.build( - uri="eat/2023/1", + uri=DocumentURIString("eat/2023/1"), is_published=True, body=DocumentBodyFactory.build(name="Judgment A"), ) @@ -540,7 +545,7 @@ def test_html_title_when_judgment(self, mock_get_document_by_uri, mock_pdf): name and "- Find Case Law - The National Archives" """ mock_get_document_by_uri.return_value = JudgmentFactory.build( - uri="eat/2023/1", + uri=DocumentURIString("eat/2023/1"), is_published=True, body=DocumentBodyFactory.build(name="Judgment A"), ) @@ -554,7 +559,7 @@ class TestNoNeutralCitation(TestCase): @patch("judgments.views.detail.detail_html.get_published_document_by_uri") def test_document_baseclass_raises_error(self, get_document): doc = JudgmentFactory.build( - uri="eat/2023/1", + uri=DocumentURIString("eat/2023/1"), is_published=True, name="Judgment A", neutral_citation=None, diff --git a/judgments/tests/test_judgment_utils.py b/judgments/tests/test_judgment_utils.py index 114f6b2cc..47a52f8fe 100644 --- a/judgments/tests/test_judgment_utils.py +++ b/judgments/tests/test_judgment_utils.py @@ -34,7 +34,7 @@ def test_judgment_missing(self, mock_get_document_by_uri): @patch("judgments.utils.judgment_utils.get_document_by_uri") def test_press_summary_is_published(self, mock_get_document_by_uri): - judgment = JudgmentFactory.build(is_published=True, uri="2022/eat/1/press-summary/1") + judgment = JudgmentFactory.build(is_published=True, uri=DocumentURIString("2022/eat/1/press-summary/1")) mock_get_document_by_uri.return_value = judgment document_uri = DocumentURIString("2022/eat/1/press-summary/1") assert get_published_document_by_uri(document_uri) == judgment diff --git a/judgments/tests/test_utils.py b/judgments/tests/test_utils.py index 1a4570dfa..632fa268f 100644 --- a/judgments/tests/test_utils.py +++ b/judgments/tests/test_utils.py @@ -70,7 +70,7 @@ def test_linked_doc_url_returns_press_summary_for_a_judgement(self): assert linked_doc_url(document) == document.uri + "/press-summary/1" def test_linked_doc_url_returns_judgement_for_a_press_summary(self): - document = PressSummaryFactory.build(uri="/foo/bar/press-summary/1") + document = PressSummaryFactory.build(uri=DocumentURIString("foo/bar/press-summary/1")) assert linked_doc_url(document) == "foo/bar" diff --git a/requirements/base.txt b/requirements/base.txt index 75af983b4..5528615b9 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -9,7 +9,7 @@ django-environ==0.11.2 # https://github.com/joke2k/django-environ django-model-utils==5.0.0 # https://github.com/jazzband/django-model-utils requests~=2.32.2 wsgi-basic-auth~=1.1.0 -ds-caselaw-marklogic-api-client~=27.4.0 +ds-caselaw-marklogic-api-client~=28.0.0 ds-caselaw-utils==2.0.0 rollbar django-weasyprint==2.3.0