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

feat: adds count method to resources #105

Merged
merged 3 commits into from
Mar 19, 2024
Merged

feat: adds count method to resources #105

merged 3 commits into from
Mar 19, 2024

Conversation

tdstein
Copy link
Collaborator

@tdstein tdstein commented Mar 19, 2024

Resolves #47

Copy link

github-actions bot commented Mar 19, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
515 428 83% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/posit/connect/content.py 73% 🟢
src/posit/connect/resources.py 100% 🟢
src/posit/connect/users.py 92% 🟢
TOTAL 89% 🟢

updated for commit: 34c15e0 by action🐍

src/posit/connect/users.py Outdated Show resolved Hide resolved
src/posit/connect/users.py Outdated Show resolved Hide resolved
@@ -0,0 +1,19 @@
{
Copy link
Collaborator

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"),
)
Copy link
Collaborator

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}
                )
            ],

tinkering.py Outdated Show resolved Hide resolved
@tdstein tdstein merged commit de863a2 into main Mar 19, 2024
7 checks passed
@tdstein tdstein deleted the tdstein/47 branch March 19, 2024 18:54
@@ -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})
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collections should have __len__
2 participants