Skip to content

Commit

Permalink
feat(FCL-553): NCNs are no longer mandatory when publishing a document
Browse files Browse the repository at this point in the history
We can no longer guarantee that documents have an NCN, so it's now possible to publish a document without one.

BREAKING CHANGE: `has_ncn()` has been removed for documents using `NeutralCitationMixin`
  • Loading branch information
jacksonj04 committed Dec 19, 2024
1 parent 734df18 commit 08c2bfe
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 36 deletions.
10 changes: 0 additions & 10 deletions src/caselawclient/models/neutral_citation_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ class NeutralCitationMixin(ABC):

def __init__(self, document_noun: str, *args: Any, **kwargs: Any) -> None:
self.attributes_to_validate: list[tuple[str, bool, str]] = self.attributes_to_validate + [
(
"has_ncn",
True,
f"This {document_noun} has no neutral citation number",
),
(
"has_valid_ncn",
True,
Expand All @@ -42,11 +37,6 @@ def __init__(self, document_noun: str, *args: Any, **kwargs: Any) -> None:
@deprecated("Legacy usage of NCNs is deprecated; you should be moving to the Identifiers framework")
def neutral_citation(self) -> Optional[NeutralCitationString]: ...

@cached_property
@deprecated("Legacy usage of NCNs is deprecated; you should be moving to the Identifiers framework")
def has_ncn(self) -> bool:
return self.neutral_citation is not None and self.neutral_citation != ""

@cached_property
@deprecated("Legacy usage of NCNs is deprecated; you should be moving to the Identifiers framework")
def has_valid_ncn(self) -> bool:
Expand Down
13 changes: 0 additions & 13 deletions tests/models/test_judgments.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from caselawclient.models.documents import DocumentURIString
from caselawclient.models.identifiers.neutral_citation import NeutralCitationNumber
from caselawclient.models.judgments import Judgment
from caselawclient.models.neutral_citation_mixin import NeutralCitationString


class TestJudgment:
Expand All @@ -19,16 +18,6 @@ def test_best_identifier(self, mock_api_client):


class TestJudgmentValidation:
def test_has_ncn(self, mock_api_client):
document_with_ncn = Judgment(DocumentURIString("test/1234"), mock_api_client)
document_with_ncn.neutral_citation = NeutralCitationString("[2023] TEST 1234")

document_without_ncn = Judgment(DocumentURIString("test/1234"), mock_api_client)
document_without_ncn.neutral_citation = NeutralCitationString("")

assert document_with_ncn.has_ncn is True
assert document_without_ncn.has_ncn is False

def test_judgment_neutral_citation(self, mock_api_client):
mock_api_client.get_judgment_xml_bytestring.return_value = b"""
<akomaNtoso xmlns:uk="https://caselaw.nationalarchives.gov.uk/akn"
Expand Down Expand Up @@ -85,7 +74,6 @@ def test_judgment_validation_failure_messages_if_failing(self, mock_api_client):
judgment.is_parked = True
judgment.is_held = True
judgment.has_name = False
judgment.has_ncn = False
judgment.has_valid_ncn = False
judgment.has_valid_court = False

Expand All @@ -95,7 +83,6 @@ def test_judgment_validation_failure_messages_if_failing(self, mock_api_client):
"This judgment is currently parked at a temporary URI",
"This judgment is currently on hold",
"This judgment has no name",
"This judgment has no neutral citation number",
"The neutral citation number of this judgment is not valid",
"The court for this judgment is not valid",
],
Expand Down
13 changes: 0 additions & 13 deletions tests/models/test_press_summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from caselawclient.factories import JudgmentFactory
from caselawclient.models.documents import DocumentURIString
from caselawclient.models.identifiers.neutral_citation import NeutralCitationNumber
from caselawclient.models.neutral_citation_mixin import NeutralCitationString
from caselawclient.models.press_summaries import PressSummary


Expand All @@ -19,16 +18,6 @@ def test_best_identifier(self, mock_api_client):


class TestPressSummaryValidation:
def test_has_ncn(self, mock_api_client):
document_with_ncn = PressSummary(DocumentURIString("test/1234"), mock_api_client)
document_with_ncn.neutral_citation = NeutralCitationString("[2023] TEST 1234")

document_without_ncn = PressSummary(DocumentURIString("test/1234"), mock_api_client)
document_without_ncn.neutral_citation = NeutralCitationString("")

assert document_with_ncn.has_ncn is True
assert document_without_ncn.has_ncn is False

def test_press_summary_neutral_citation(self, mock_api_client):
mock_api_client.get_judgment_xml_bytestring.return_value = b"""
<akomaNtoso xmlns:uk="https://caselaw.nationalarchives.gov.uk/akn"
Expand Down Expand Up @@ -94,7 +83,6 @@ def test_press_summary_validation_failure_messages_if_failing(
press_summary.is_parked = True
press_summary.is_held = True
press_summary.has_name = False
press_summary.has_ncn = False
press_summary.has_valid_ncn = False
press_summary.has_valid_court = False

Expand All @@ -104,7 +92,6 @@ def test_press_summary_validation_failure_messages_if_failing(
"This press summary is currently parked at a temporary URI",
"This press summary is currently on hold",
"This press summary has no name",
"This press summary has no neutral citation number",
"The neutral citation number of this press summary is not valid",
"The court for this press summary is not valid",
],
Expand Down

0 comments on commit 08c2bfe

Please sign in to comment.