Skip to content

Commit c1ff61e

Browse files
authored
Merge branch 'main' into zack-192-git-repo-settings
2 parents 208048d + e507d3f commit c1ff61e

File tree

18 files changed

+83
-303
lines changed

18 files changed

+83
-303
lines changed

integration/tests/posit/connect/oauth/test_associations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def test_find_update_by_content(self):
8787
updated_associations = self.content.oauth.associations.find()
8888
assert len(updated_associations) == 1
8989
assert updated_associations[0]["app_guid"] == self.content["guid"]
90-
assert updated_associations[0]["oauth_integration_guid"] == self.another_integration.guid
90+
assert (
91+
updated_associations[0]["oauth_integration_guid"] == self.another_integration["guid"]
92+
)
9193

9294
# unset content association
9395
self.content.oauth.associations.delete()

integration/tests/posit/connect/oauth/test_integrations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_create_update_delete(self):
8888

8989
created.update(name="updated integration name")
9090
updated = self.client.oauth.integrations.get(integration["guid"])
91-
assert updated.name == "updated integration name"
91+
assert updated["name"] == "updated integration name"
9292

9393
# delete the new integration
9494

integration/tests/posit/connect/test_groups.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33

44
class TestGroups:
5+
@classmethod
56
def setup_class(cls):
67
cls.client = connect.Client()
78
cls.item = cls.client.groups.create(name="Friends")
89

10+
@classmethod
911
def teardown_class(cls):
1012
cls.item.delete()
1113
assert cls.client.groups.count() == 0
@@ -14,7 +16,7 @@ def test_count(self):
1416
assert self.client.groups.count() == 1
1517

1618
def test_get(self):
17-
assert self.client.groups.get(self.item.guid)
19+
assert self.client.groups.get(self.item["guid"])
1820

1921
def test_find(self):
2022
assert self.client.groups.find() == [self.item]

src/posit/connect/bundles.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def metadata(self) -> BundleMetadata:
1919

2020
def delete(self) -> None:
2121
"""Delete the bundle."""
22-
path = f"v1/content/{self.content_guid}/bundles/{self.id}"
22+
path = f"v1/content/{self['content_guid']}/bundles/{self['id']}"
2323
url = self.params.url + path
2424
self.params.session.delete(url)
2525

@@ -41,7 +41,7 @@ def deploy(self) -> tasks.Task:
4141
"""
4242
path = f"v1/content/{self['content_guid']}/deploy"
4343
url = self.params.url + path
44-
response = self.params.session.post(url, json={"bundle_id": self.id})
44+
response = self.params.session.post(url, json={"bundle_id": self["id"]})
4545
result = response.json()
4646
ts = tasks.Tasks(self.params)
4747
return ts.get(result["task_id"])
@@ -77,7 +77,7 @@ def download(self, output: io.BufferedWriter | str) -> None:
7777
f"download() expected argument type 'io.BufferedWriter` or 'str', but got '{type(output).__name__}'",
7878
)
7979

80-
path = f"v1/content/{self.content_guid}/bundles/{self.id}/download"
80+
path = f"v1/content/{self['content_guid']}/bundles/{self['id']}/download"
8181
url = self.params.url + path
8282
response = self.params.session.get(url, stream=True)
8383
if isinstance(output, io.BufferedWriter):

src/posit/connect/content.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def create_repository(
261261

262262
def delete(self) -> None:
263263
"""Delete the content item."""
264-
path = f"v1/content/{self.guid}"
264+
path = f"v1/content/{self['guid']}"
265265
url = self.params.url + path
266266
self.params.session.delete(url)
267267

@@ -281,7 +281,7 @@ def deploy(self) -> tasks.Task:
281281
>>> task.wait_for()
282282
None
283283
"""
284-
path = f"v1/content/{self.guid}/deploy"
284+
path = f"v1/content/{self['guid']}/deploy"
285285
url = self.params.url + path
286286
response = self.params.session.post(url, json={"bundle_id": None})
287287
result = response.json()
@@ -305,7 +305,7 @@ def render(self) -> Task:
305305

306306
if self.is_rendered:
307307
variants = self._variants.find()
308-
variants = [variant for variant in variants if variant.is_default]
308+
variants = [variant for variant in variants if variant["is_default"]]
309309
if len(variants) != 1:
310310
raise RuntimeError(
311311
f"Found {len(variants)} default variants. Expected 1. Without a single default variant, the content cannot be refreshed. This is indicative of a corrupted state.",
@@ -314,7 +314,7 @@ def render(self) -> Task:
314314
return variant.render()
315315
else:
316316
raise ValueError(
317-
f"Render not supported for this application mode: {self.app_mode}. Did you need to use the 'restart()' method instead? Note that some application modes do not support 'render()' or 'restart()'.",
317+
f"Render not supported for this application mode: {self['app_mode']}. Did you need to use the 'restart()' method instead? Note that some application modes do not support 'render()' or 'restart()'.",
318318
)
319319

320320
def restart(self) -> None:
@@ -338,12 +338,12 @@ def restart(self) -> None:
338338
self.environment_variables.create(key, unix_epoch_in_seconds)
339339
self.environment_variables.delete(key)
340340
# GET via the base Connect URL to force create a new worker thread.
341-
url = posixpath.join(dirname(self.params.url), f"content/{self.guid}")
341+
url = posixpath.join(dirname(self.params.url), f"content/{self['guid']}")
342342
self.params.session.get(url)
343343
return None
344344
else:
345345
raise ValueError(
346-
f"Restart not supported for this application mode: {self.app_mode}. Did you need to use the 'render()' method instead? Note that some application modes do not support 'render()' or 'restart()'.",
346+
f"Restart not supported for this application mode: {self['app_mode']}. Did you need to use the 'render()' method instead? Note that some application modes do not support 'render()' or 'restart()'.",
347347
)
348348

349349
def update(
@@ -444,7 +444,7 @@ def _variants(self) -> Variants:
444444

445445
@property
446446
def is_interactive(self) -> bool:
447-
return self.app_mode in {
447+
return self["app_mode"] in {
448448
"api",
449449
"jupyter-voila",
450450
"python-api",
@@ -461,7 +461,7 @@ def is_interactive(self) -> bool:
461461

462462
@property
463463
def is_rendered(self) -> bool:
464-
return self.app_mode in {
464+
return self["app_mode"] in {
465465
"rmd-static",
466466
"jupyter-static",
467467
"quarto-static",

src/posit/connect/groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Group(Resource):
1515
def delete(self) -> None:
1616
"""Delete the group."""
17-
path = f"v1/groups/{self.guid}"
17+
path = f"v1/groups/{self['guid']}"
1818
url = self.params.url + path
1919
self.params.session.delete(url)
2020

src/posit/connect/permissions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Permission(Resource):
1313
def delete(self) -> None:
1414
"""Delete the permission."""
15-
path = f"v1/content/{self.content_guid}/permissions/{self.id}"
15+
path = f"v1/content/{self['content_guid']}/permissions/{self['id']}"
1616
url = self.params.url + path
1717
self.params.session.delete(url)
1818

@@ -33,13 +33,13 @@ def update(self, *args, **kwargs) -> None:
3333
def update(self, *args, **kwargs) -> None:
3434
"""Update the permission."""
3535
body = {
36-
"principal_guid": self.principal_guid,
37-
"principal_type": self.principal_type,
38-
"role": self.role,
36+
"principal_guid": self.get("principal_guid"),
37+
"principal_type": self.get("principal_type"),
38+
"role": self.get("role"),
3939
}
4040
body.update(dict(*args))
4141
body.update(**kwargs)
42-
path = f"v1/content/{self.content_guid}/permissions/{self.id}"
42+
path = f"v1/content/{self['content_guid']}/permissions/{self['id']}"
4343
url = self.params.url + path
4444
response = self.params.session.put(
4545
url,

src/posit/connect/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def update(self, *args, **kwargs) -> None:
9090
]
9191
"""
9292
params = dict(*args, **kwargs)
93-
path = f"v1/tasks/{self.id}"
93+
path = f"v1/tasks/{self['id']}"
9494
url = self.params.url + path
9595
response = self.params.session.get(url, params=kwargs)
9696
result = response.json()

src/posit/connect/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def lock(self, *, force: bool = False):
4242
>>> user.lock(force=True)
4343
"""
4444
_me = me.get(self.params)
45-
if _me.guid == self["guid"] and not force:
45+
if _me["guid"] == self["guid"] and not force:
4646
raise RuntimeError(
4747
"You cannot lock your own account. Set force=True to override this behavior.",
4848
)

tests/posit/connect/oauth/test_integrations.py

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,11 @@
1-
from unittest import mock
2-
31
import responses
42
from responses import matchers
53

64
from posit.connect.client import Client
7-
from posit.connect.oauth.associations import IntegrationAssociations
8-
from posit.connect.oauth.integrations import Integration
95

106
from ..api import load_mock # type: ignore
117

128

13-
class TestIntegrationAttributes:
14-
@classmethod
15-
def setup_class(cls):
16-
guid = "22644575-a27b-4118-ad06-e24459b05126"
17-
fake_item = load_mock(f"v1/oauth/integrations/{guid}.json")
18-
cls.item = Integration(mock.Mock(), **fake_item)
19-
20-
def test_id(self):
21-
assert self.item.id == "3"
22-
23-
def test_guid(self):
24-
assert self.item.guid == "22644575-a27b-4118-ad06-e24459b05126"
25-
26-
def test_name(self):
27-
assert self.item.name == "keycloak integration"
28-
29-
def test_description(self):
30-
assert self.item.description == "integration description"
31-
32-
def test_template(self):
33-
assert self.item.template == "custom"
34-
35-
def test_config(self):
36-
assert self.item.config["auth_mode"] == "Confidential"
37-
assert (
38-
self.item.config["authorization_uri"]
39-
== "http://keycloak:8080/realms/rsconnect/protocol/openid-connect/auth"
40-
)
41-
assert self.item.config["client_id"] == "rsconnect-oidc"
42-
assert self.item.config["scopes"] == "email"
43-
assert self.item.config["token_endpoint_auth_method"] == "client_secret_basic"
44-
assert (
45-
self.item.config["token_uri"]
46-
== "http://keycloak:8080/realms/rsconnect/protocol/openid-connect/token"
47-
)
48-
49-
def test_created_time(self):
50-
assert self.item.created_time == "2024-07-16T19:28:05Z"
51-
52-
def test_updated_time(self):
53-
assert self.item.updated_time == "2024-07-17T19:28:05Z"
54-
55-
def test_associations(self):
56-
assert isinstance(self.item.associations, IntegrationAssociations)
57-
58-
599
class TestIntegrationDelete:
6010
@responses.activate
6111
def test(self):
@@ -96,7 +46,7 @@ def test(self):
9646
c = Client("https://connect.example", "12345")
9747
c.ctx.version = None
9848
integration = c.oauth.integrations.get(guid)
99-
assert integration.guid == guid
49+
assert integration["guid"] == guid
10050

10151
new_name = "New Name"
10252

@@ -111,7 +61,7 @@ def test(self):
11161

11262
integration.update(name=new_name)
11363
assert mock_update.call_count == 1
114-
assert integration.name == new_name
64+
assert integration["name"] == new_name
11565

11666

11767
class TestIntegrationsCreate:
@@ -151,10 +101,10 @@ def test(self):
151101

152102
# assert
153103
assert mock_create.call_count == 1
154-
assert integration.name == fake_integration["name"]
155-
assert integration.description == fake_integration["description"]
156-
assert integration.template == fake_integration["template"]
157-
assert integration.config == fake_integration["config"]
104+
assert integration["name"] == fake_integration["name"]
105+
assert integration["description"] == fake_integration["description"]
106+
assert integration["template"] == fake_integration["template"]
107+
assert integration["config"] == fake_integration["config"]
158108

159109

160110
class TestIntegrationsFind:
@@ -176,8 +126,8 @@ def test(self):
176126
# assert
177127
assert mock_get.call_count == 1
178128
assert len(integrations) == 2
179-
assert integrations[0].id == "3"
180-
assert integrations[1].id == "4"
129+
assert integrations[0]["id"] == "3"
130+
assert integrations[1]["id"] == "4"
181131

182132

183133
class TestIntegrationsGet:
@@ -197,4 +147,4 @@ def test(self):
197147
integration = c.oauth.integrations.get(guid)
198148

199149
assert mock_get.call_count == 1
200-
assert integration.guid == guid
150+
assert integration["guid"] == guid

0 commit comments

Comments
 (0)