-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Content repository resource #300
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
Merged
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
2de5dd6
wip implementation of git repo resource
zackverham cb3f83a
WIP: better ergonomics
zackverham 0dde373
Merge branch 'main' into zack-192-git-repo-settings
schloerke cad4808
Merge branch 'main' into zack-192-git-repo-settings
schloerke 32e5d8a
Run slow tests last
schloerke 3200268
Make sure args are never unused
schloerke 05ed953
Add utils file containing `drop_none(x)`
schloerke 22b62ba
Update hooks.py
schloerke 02be543
Consolidate methods into a single call
schloerke 3f68756
Fix incorrect default values
schloerke 087124a
Only display warnings once for per python session.
schloerke 3168f58
Update resources.py
schloerke 1fd77ab
Fix default values to None; Fix some attr access
schloerke 0ccf961
`Active` -> `ActiveParams`
schloerke 224efed
Merge branch 'main' into zack-192-git-repo-settings
schloerke 395a100
Update .gitignore
schloerke 2fda267
Create _api.py
schloerke 2128318
Create _json.py
schloerke f104149
Small nit updates
schloerke 1c4b79f
Use new `ApiEndpoint` class for `ContentItemRepository`
schloerke cb7af36
Update _api.py
schloerke 849ab75
Create test_api_endpoint.py
schloerke 5e60fce
Add note
schloerke 19a3249
Add WIP tests for content item repository
schloerke 44b26c7
commit before computer blows up
schloerke d7a25bf
Make sure content_guid is a kwarg only
schloerke 1c890e9
Move creation code to a helper method
schloerke 7922f93
Add notes and str / repr methods
schloerke 7eeeafc
Do not fetch all data immediately. Instead, use generator
schloerke 5483a40
Update test_content.py
schloerke a0fd651
Fix integration test for repository
schloerke a92f024
Update content.py
schloerke 6a474f7
Allow for single warning in the future
schloerke 40354df
Remove usage of `drop_none()` and leverage `._Attrs` unpacking
schloerke bc8d1e0
Add typing extensions helper module for legacy support
schloerke 7bb5c04
Skip test on connect versions < 2022.12.0
schloerke c885eb8
More typing extensions impl
schloerke 947daab
Missing import
schloerke 3bf353e
Remove usage of `dict | dict`
schloerke 48d3049
Remove some TODOs
schloerke 20f3e5c
Update notes
schloerke 61b6e56
Use `.items()` comparison
schloerke 9774612
Destroy class content on teardown
schloerke 182384d
Don't use overwritten helper method
schloerke e7d509b
Revert `has_shown_warning_dict` changes
schloerke ef98862
Use posixpath.join to merge url components
schloerke cb09123
Use NotImplementedError not AttributeError for setitem call
schloerke 5a9fb55
Used variables for position only args to methods
schloerke bf2102a
Merge branch 'zack-192-git-repo-settings' of https://github.com/posit…
schloerke 0de7d4f
Update test_api_endpoint.py
schloerke 208048d
Followup to using `*path` for endpoint calls
schloerke c1ff61e
Merge branch 'main' into zack-192-git-repo-settings
schloerke 21021aa
Add comment about unused args
schloerke 9dd1f24
Add `Jsonifiable` typing for `load_mock`. Add `load_mock_dict`
schloerke a0e404c
Fix init typing with name
schloerke df9cdb3
Use files for mocked info
schloerke 4456814
Update test_content_item_repository.py
schloerke 222130e
Add comment
schloerke 7236487
style: Lint testing folders (#326)
schloerke d14f618
Remove repr and str
schloerke fa21a42
Merge branch 'main' into zack-192-git-repo-settings
schloerke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,3 +169,4 @@ cython_debug/ | |
| .ruff_cache/ | ||
|
|
||
| /.luarc.json | ||
| _dev/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
integration/tests/posit/connect/test_content_item_repository.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import pytest | ||
| from packaging import version | ||
|
|
||
| from posit import connect | ||
| from posit.connect.content import ContentItem, ContentItemRepository | ||
|
|
||
| from . import CONNECT_VERSION | ||
|
|
||
|
|
||
| class TestContentItemRepository: | ||
| content: ContentItem | ||
|
|
||
| @classmethod | ||
| def setup_class(cls): | ||
| cls.client = connect.Client() | ||
| cls.content = cls.client.content.create(name="example") | ||
|
|
||
| @classmethod | ||
| def teardown_class(cls): | ||
| cls.content.delete() | ||
| assert cls.client.content.count() == 0 | ||
|
|
||
| @property | ||
| def repo_repository(self): | ||
| return "https://github.com/posit-dev/posit-sdk-py" | ||
|
|
||
| @property | ||
| def repo_branch(self): | ||
| return "1dacc4dd" | ||
|
|
||
| @property | ||
| def repo_directory(self): | ||
| return "integration/resources/connect/bundles/example-quarto-minimal" | ||
|
|
||
| @property | ||
| def repo_polling(self): | ||
| return False | ||
|
|
||
| @property | ||
| def default_repository(self): | ||
| return { | ||
| "repository": self.repo_repository, | ||
| "branch": self.repo_branch, | ||
| "directory": self.repo_directory, | ||
| "polling": self.repo_polling, | ||
| } | ||
|
|
||
| @pytest.mark.skipif( | ||
| # Added to the v2022.12.0 milestone | ||
| # https://github.com/rstudio/connect/issues/22242#event-7859377097 | ||
| CONNECT_VERSION < version.parse("2022.12.0"), | ||
| reason="Repository routes not implemented", | ||
| ) | ||
| def test_create_get_update_delete(self): | ||
| content = self.content | ||
|
|
||
| # None by default | ||
| assert content.repository is None | ||
|
|
||
| # Create | ||
| new_repo = content.create_repository(**self.default_repository) | ||
|
|
||
| # Get | ||
| content_repo = content.repository | ||
| assert content_repo is not None | ||
|
|
||
| def assert_repo(r: ContentItemRepository): | ||
| assert isinstance(content_repo, ContentItemRepository) | ||
| assert r["repository"] == self.repo_repository | ||
| assert r["branch"] == self.repo_branch | ||
| assert r["directory"] == self.repo_directory | ||
| assert r["polling"] is self.repo_polling | ||
|
|
||
| assert_repo(new_repo) | ||
| assert_repo(content_repo) | ||
|
|
||
| # Update | ||
| ex_branch = "main" | ||
| updated_repo = content_repo.update(branch=ex_branch) | ||
| assert updated_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 | ||
|
|
||
| # Delete | ||
| content_repo.destroy() | ||
| assert content.repository is None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.