-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: adds count method to resources #105
Conversation
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
@@ -0,0 +1,19 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd delete this and just use tests/posit/connect/__api__/v1/users?page_number=1&page_size=2.json
in the test
responses.get( | ||
"https://connect.example/__api__/v1/users", | ||
json=load_mock("v1/users.json"), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you took the suggestion to only request page_size=1 above, add this here:
match=[
responses.matchers.query_param_matcher(
{"page_size": 1}
)
],
@@ -148,3 +148,8 @@ def update(self) -> User: | |||
|
|||
def delete(self) -> None: | |||
raise NotImplementedError() | |||
|
|||
def count(self) -> int: | |||
response: requests.Response = self.session.get(self.url, json={"page_size": 1}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own edification: is this type hint necessary? Doesn't it (waves hands) know that requests.Session.get()
returns requests.Response
? And that Response.json()
returns dict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it isn't necessary. Once I added the correct type declaration to session
in the __init__
method, this type declaration became redundant.
Your understanding is correct 😄
Resolves #47