Skip to content

Commit

Permalink
Merge pull request #1619 from nationalarchives/chore/bump-api-client-…
Browse files Browse the repository at this point in the history
…to-v28

[FCL-467] Bump API client to v28
  • Loading branch information
jacksonj04 authored Nov 18, 2024
2 parents 46e8c51 + fbefe40 commit 750ce9b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions judgments/tests/template_tags/test_document_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
29 changes: 17 additions & 12 deletions judgments/tests/test_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']"
Expand Down Expand Up @@ -350,15 +355,15 @@ 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",
),
)
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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -508,15 +513,15 @@ 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)"
),
)
else:
return JudgmentFactory.build(
uri="eat/2023/1",
uri=DocumentURIString("eat/2023/1"),
is_published=True,
body=DocumentBodyFactory.build(name="Judgment A"),
)
Expand All @@ -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"),
)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion judgments/tests/test_judgment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion judgments/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 750ce9b

Please sign in to comment.