Skip to content

Commit

Permalink
merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Dec 17, 2024
2 parents 2f87694 + 1a2cc55 commit 66ccabc
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 463 deletions.
13 changes: 7 additions & 6 deletions integration/tests/posit/connect/test_content_item_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from packaging import version

from posit import connect
from posit.connect.content import ContentItem, ContentItemRepository
from posit.connect.content import ContentItem
from posit.connect.repository import ContentItemRepository

from . import CONNECT_VERSION

Expand Down Expand Up @@ -76,12 +77,12 @@ def assert_repo(r: ContentItemRepository):

# Update
ex_branch = "main"
updated_repo = content_repo.update(branch=ex_branch)
assert updated_repo["branch"] == ex_branch
content_repo.update(branch=ex_branch)
assert content_repo["branch"] == ex_branch

assert updated_repo["repository"] == self.repo_repository
assert updated_repo["directory"] == self.repo_directory
assert updated_repo["polling"] is self.repo_polling
assert content_repo["repository"] == self.repo_repository
assert content_repo["directory"] == self.repo_directory
assert content_repo["polling"] is self.repo_polling

# Delete
content_repo.destroy()
Expand Down
8 changes: 4 additions & 4 deletions integration/tests/posit/connect/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ def test_tag_content_items(self):
}

# Update tag
tagDName = tagD.update(name="tagD_updated")
assert tagDName["name"] == "tagD_updated"
tagD.update(name="tagD_updated")
assert tagD["name"] == "tagD_updated"
assert self.client.tags.get(tagD["id"])["name"] == "tagD_updated"

tagDParent = tagDName.update(parent=tagB)
assert tagDParent["parent_id"] == tagB["id"]
tagD.update(parent=tagB)
assert tagD["parent_id"] == tagB["id"]
assert self.client.tags.get(tagD["id"])["parent_id"] == tagB["id"]

# Cleanup
Expand Down
143 changes: 0 additions & 143 deletions src/posit/connect/_api.py

This file was deleted.

73 changes: 0 additions & 73 deletions src/posit/connect/_api_call.py

This file was deleted.

37 changes: 0 additions & 37 deletions src/posit/connect/_json.py

This file was deleted.

27 changes: 25 additions & 2 deletions src/posit/connect/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,28 @@
from typing_extensions import Any


def drop_none(x: dict[str, Any]) -> dict[str, Any]:
return {k: v for k, v in x.items() if v is not None}
def update_dict_values(obj: dict[str, Any], /, **kwargs: Any) -> None:
"""
Update the values of a dictionary.
This helper method exists as a workaround for the `dict.update` method. Sometimes, `super()` does not return the `dict` class and. If `super().update(**kwargs)` is called unintended behavior will occur.
Therefore, this helper method exists to update the `dict`'s values.
Parameters
----------
obj : dict[str, Any]
The object to update.
kwargs : Any
The key-value pairs to update the object with.
See Also
--------
* https://github.com/posit-dev/posit-sdk-py/pull/366#discussion_r1887845267
"""
# Could also be performed with:
# for key, value in kwargs.items():
# obj[key] = value

# Use the `dict` class to explicity update the object in-place
dict.update(obj, **kwargs)
Loading

0 comments on commit 66ccabc

Please sign in to comment.