Skip to content

Commit

Permalink
Merge pull request #827 from nationalarchives/str-of-identifier
Browse files Browse the repository at this point in the history
str(identifier) should be just the value
  • Loading branch information
jacksonj04 authored Jan 6, 2025
2 parents 8326cce + 3cb2bb7 commit ae1d9e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/caselawclient/models/identifiers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def __init_subclass__(cls: type["Identifier"], **kwargs: Any) -> None:
def __repr__(self) -> str:
return f"<{self.schema.name} {self.value}: {self.uuid}>"

def __str__(self) -> str:
return self.value

def __init__(self, value: str, uuid: Optional[str] = None) -> None:
self.value = value
if uuid:
Expand Down
2 changes: 0 additions & 2 deletions src/caselawclient/models/utilities/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ def request_parse(
},
}

# breakpoint()

client.publish(
TopicArn=env("REPARSE_SNS_TOPIC"),
Message=json.dumps(message_to_send),
Expand Down
10 changes: 8 additions & 2 deletions tests/models/identifiers/test_identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def identifiers():
)


TEST_NCN_1701 = NeutralCitationNumber(value="[1701] UKSC 999")
TEST_NCN_1234 = NeutralCitationNumber(value="[1234] UKSC 999")
TEST_NCN_1701 = NeutralCitationNumber(value="[1701] UKSC 999", uuid="id-1701")
TEST_NCN_1234 = NeutralCitationNumber(value="[1234] UKSC 999", uuid="id-1234")
TEST_IDENTIFIER_999 = TestIdentifier("TEST-999")


Expand Down Expand Up @@ -89,6 +89,12 @@ def test_same_as_different_values(self):
id_b = NeutralCitationNumber("X")
assert not id_a.same_as(id_b)

def test_str(self):
assert f"{TEST_NCN_1234}" == "[1234] UKSC 999"

def test_repr(self):
assert f"{TEST_NCN_1234!r}" == "<Neutral Citation Number [1234] UKSC 999: id-1234>"


class TestIdentifiersCRUD:
def test_delete(self, identifiers):
Expand Down

0 comments on commit ae1d9e1

Please sign in to comment.