Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str(identifier) should be just the value #827

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good delete! Wonder why ruff didn't catch this?


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
Loading