Skip to content

Commit

Permalink
fix(SearchResponse): total now returns an int, not a str
Browse files Browse the repository at this point in the history
The total number of results is inherently an integer, and we should treat it as such.
  • Loading branch information
jacksonj04 committed Oct 1, 2024
1 parent f153eff commit 9b07bc5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog 1.0.0].

## Unreleased

### BREAKING CHANGE

- The `models.documents.body.CourtIdentifierString` type has been replaced with the more specific `courts.CourtCode` type from ds-caselaw-utils.

### Fix

- **SearchResponse**: total now returns an int, not a str
- **SearchResult**: update behaviour to meet type checking
- **deps**: update dependency ds-caselaw-utils to v1.7.0
- **deps**: update dependency boto3 to v1.35.28
- **deps**: update dependency ds-caselaw-utils to v1.5.7
- **deps**: update dependency boto3 to v1.35.25

### Refactor

- **DocumentBody**: replace CourtIdentifierString with utils.courts.CourtCode

## v26.0.0 (2024-09-25)

### BREAKING CHANGE
Expand Down
4 changes: 2 additions & 2 deletions src/caselawclient/responses/search_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def __init__(self, node: etree._Element, client: MarklogicApiClient) -> None:
self.client = client

@property
def total(self) -> str:
def total(self) -> int:
"""
The total number of search results.
:return: The total number of search results
"""
return str(
return int(
self.node.xpath("//search:response/@total", namespaces=self.NAMESPACES)[0],
)

Expand Down
4 changes: 2 additions & 2 deletions tests/responses/test_search_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_total(
"""
Given a SearchResponse instance
When calling 'total' on it
Then it should return a string representing the total number of results
Then it should return an integer representing the total number of results
"""
search_response = SearchResponse(
etree.fromstring(
Expand All @@ -32,7 +32,7 @@ def test_total(
self.client,
)

assert search_response.total == "5"
assert search_response.total == 5

def test_results(
self,
Expand Down

0 comments on commit 9b07bc5

Please sign in to comment.