Skip to content
Merged
Show file tree
Hide file tree
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 Sep 26, 2024
cb3f83a
WIP: better ergonomics
zackverham Sep 30, 2024
0dde373
Merge branch 'main' into zack-192-git-repo-settings
schloerke Oct 31, 2024
cad4808
Merge branch 'main' into zack-192-git-repo-settings
schloerke Oct 31, 2024
32e5d8a
Run slow tests last
schloerke Oct 31, 2024
3200268
Make sure args are never unused
schloerke Oct 31, 2024
05ed953
Add utils file containing `drop_none(x)`
schloerke Oct 31, 2024
22b62ba
Update hooks.py
schloerke Oct 31, 2024
02be543
Consolidate methods into a single call
schloerke Oct 31, 2024
3f68756
Fix incorrect default values
schloerke Oct 31, 2024
087124a
Only display warnings once for per python session.
schloerke Oct 31, 2024
3168f58
Update resources.py
schloerke Oct 31, 2024
1fd77ab
Fix default values to None; Fix some attr access
schloerke Nov 1, 2024
0ccf961
`Active` -> `ActiveParams`
schloerke Nov 1, 2024
224efed
Merge branch 'main' into zack-192-git-repo-settings
schloerke Nov 4, 2024
395a100
Update .gitignore
schloerke Nov 4, 2024
2fda267
Create _api.py
schloerke Nov 4, 2024
2128318
Create _json.py
schloerke Nov 4, 2024
f104149
Small nit updates
schloerke Nov 4, 2024
1c4b79f
Use new `ApiEndpoint` class for `ContentItemRepository`
schloerke Nov 4, 2024
cb7af36
Update _api.py
schloerke Nov 4, 2024
849ab75
Create test_api_endpoint.py
schloerke Nov 4, 2024
5e60fce
Add note
schloerke Nov 4, 2024
19a3249
Add WIP tests for content item repository
schloerke Nov 4, 2024
44b26c7
commit before computer blows up
schloerke Nov 5, 2024
d7a25bf
Make sure content_guid is a kwarg only
schloerke Nov 6, 2024
1c890e9
Move creation code to a helper method
schloerke Nov 6, 2024
7922f93
Add notes and str / repr methods
schloerke Nov 6, 2024
7eeeafc
Do not fetch all data immediately. Instead, use generator
schloerke Nov 6, 2024
5483a40
Update test_content.py
schloerke Nov 6, 2024
a0fd651
Fix integration test for repository
schloerke Nov 6, 2024
a92f024
Update content.py
schloerke Nov 6, 2024
6a474f7
Allow for single warning in the future
schloerke Nov 6, 2024
40354df
Remove usage of `drop_none()` and leverage `._Attrs` unpacking
schloerke Nov 6, 2024
bc8d1e0
Add typing extensions helper module for legacy support
schloerke Nov 6, 2024
7bb5c04
Skip test on connect versions < 2022.12.0
schloerke Nov 6, 2024
c885eb8
More typing extensions impl
schloerke Nov 6, 2024
947daab
Missing import
schloerke Nov 6, 2024
3bf353e
Remove usage of `dict | dict`
schloerke Nov 6, 2024
48d3049
Remove some TODOs
schloerke Nov 6, 2024
20f3e5c
Update notes
schloerke Nov 6, 2024
61b6e56
Use `.items()` comparison
schloerke Nov 7, 2024
9774612
Destroy class content on teardown
schloerke Nov 7, 2024
182384d
Don't use overwritten helper method
schloerke Nov 7, 2024
e7d509b
Revert `has_shown_warning_dict` changes
schloerke Nov 7, 2024
ef98862
Use posixpath.join to merge url components
schloerke Nov 7, 2024
cb09123
Use NotImplementedError not AttributeError for setitem call
schloerke Nov 7, 2024
5a9fb55
Used variables for position only args to methods
schloerke Nov 8, 2024
bf2102a
Merge branch 'zack-192-git-repo-settings' of https://github.com/posit…
schloerke Nov 8, 2024
0de7d4f
Update test_api_endpoint.py
schloerke Nov 8, 2024
208048d
Followup to using `*path` for endpoint calls
schloerke Nov 8, 2024
c1ff61e
Merge branch 'main' into zack-192-git-repo-settings
schloerke Nov 8, 2024
21021aa
Add comment about unused args
schloerke Nov 8, 2024
9dd1f24
Add `Jsonifiable` typing for `load_mock`. Add `load_mock_dict`
schloerke Nov 8, 2024
a0e404c
Fix init typing with name
schloerke Nov 8, 2024
df9cdb3
Use files for mocked info
schloerke Nov 8, 2024
4456814
Update test_content_item_repository.py
schloerke Nov 8, 2024
222130e
Add comment
schloerke Nov 8, 2024
7236487
style: Lint testing folders (#326)
schloerke Nov 8, 2024
d14f618
Remove repr and str
schloerke Nov 8, 2024
fa21a42
Merge branch 'main' into zack-192-git-repo-settings
schloerke Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ cython_debug/
.ruff_cache/

/.luarc.json
_dev/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ it: $(UV_LOCK)
$(MAKE) -C ./integration

lint: dev
$(UV) run pyright
$(UV) run ruff check
$(UV) run pyright

test: dev
$(UV) run coverage run --source=src -m pytest tests
Expand Down
4 changes: 3 additions & 1 deletion integration/tests/posit/connect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
from posit import connect

client = connect.Client()
CONNECT_VERSION = version.parse(client.version)
client_version = client.version
assert client_version is not None
CONNECT_VERSION = version.parse(client_version)
2 changes: 1 addition & 1 deletion integration/tests/posit/connect/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_find(self):
assert self.client.content.find()

def test_find_by(self):
assert self.client.content.find_by(guid=self.content["guid"]) == self.content
assert self.client.content.find_by(name=self.content["name"]) == self.content

def test_find_one(self):
assert self.client.content.find_one()
Expand Down
88 changes: 88 additions & 0 deletions integration/tests/posit/connect/test_content_item_repository.py
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
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Source = "https://github.com/posit-dev/posit-sdk-py"
Issues = "https://github.com/posit-dev/posit-sdk-py/issues"

[tool.pyright]
include = ["src"]
include = ["src", "tests", "integration/tests"]

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down Expand Up @@ -70,6 +70,7 @@ extend-select = [
# Check docstring formatting. Many of these rules are intentionally ignored below.
"D",

"ARG", # ARG; flake8-argparse: https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"E", # E; pycodestyle: https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"F", # F; Pyflakes: https://docs.astral.sh/ruff/rules/#pyflakes-f
"I", # I; isort: https://docs.astral.sh/ruff/rules/#isort-i
Expand Down Expand Up @@ -111,8 +112,8 @@ ignore = [
]

[tool.ruff.lint.per-file-ignores]
"examples/*" = ["D"]
"tests/*" = ["D"]
"examples/connect*" = ["D", "ARG"]
"tests/posit/connect/*" = ["D", "ARG"]


[tool.ruff.lint.pydocstyle]
Expand All @@ -130,7 +131,7 @@ exclude = ".*"
[dependency-groups]
build = ["build"]
coverage = ["coverage"]
examples = ["rsconnect-python", "pandas"]
examples = ["rsconnect-python", "pandas", "databricks", "shiny"]
git = ["pre-commit"]
lint = ["ruff", "pyright"]
test = ["rsconnect-python", "responses", "pytest", "pyjson5"]
Expand Down
Loading