Skip to content

Commit c4cefe9

Browse files
authored
test(fix): destroy the default integration before testing (#417)
Starting in 2025.05.0, a default integration is created by Connect. We want to destroy that integration before running the test suite.
1 parent def37c7 commit c4cefe9

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

integration/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ PYTEST_ARGS ?= "-s"
2626

2727
# Versions
2828
CONNECT_VERSIONS := \
29+
2025.06.0 \
30+
2025.05.0 \
2931
2025.04.0 \
3032
2025.03.0 \
3133
2025.02.0 \

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ class TestAssociations:
1616
@classmethod
1717
def setup_class(cls):
1818
cls.client = connect.Client()
19+
20+
# Destroy existing integrations.
21+
#
22+
# Starting with Connect 2025.05.0, a default integration is created automatically.
23+
# https://github.com/posit-dev/connect/issues/31570
24+
for integration in cls.client.oauth.integrations.find():
25+
integration.delete()
26+
27+
# Assert that no integrations exist
28+
assert len(cls.client.oauth.integrations.find()) == 0
29+
1930
cls.integration = cls.client.oauth.integrations.create(
2031
name="example integration",
2132
description="integration description",
@@ -49,10 +60,12 @@ def setup_class(cls):
4960
# create content
5061
# requires full bundle deployment to produce an interactive content type
5162
cls.content = cls.client.content.create(name="example-flask-minimal")
63+
5264
# create bundle
5365
path = Path("../../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz")
5466
path = (Path(__file__).parent / path).resolve()
5567
bundle = cls.content.bundles.create(str(path))
68+
5669
# deploy bundle
5770
task = bundle.deploy()
5871
task.wait_for()
@@ -61,11 +74,17 @@ def setup_class(cls):
6174

6275
@classmethod
6376
def teardown_class(cls):
77+
# Destroy created integrations.
6478
cls.integration.delete()
6579
cls.another_integration.delete()
80+
81+
# Assert that no integrations exist
6682
assert len(cls.client.oauth.integrations.find()) == 0
6783

84+
# Destroy created content
6885
cls.content.delete()
86+
87+
# Assert that no content exists
6988
assert cls.client.content.count() == 0
7089

7190
def test_find_by_integration(self):

integration/tests/posit/connect/test_groups.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ class TestGroups:
55
@classmethod
66
def setup_class(cls):
77
cls.client = connect.Client()
8-
cls.item = cls.client.groups.create(name="Friends")
8+
cls.group = cls.client.groups.create(name="Friends")
99

1010
@classmethod
1111
def teardown_class(cls):
12-
cls.item.delete()
12+
cls.group.delete()
1313
assert cls.client.groups.count() == 0
1414

1515
def test_count(self):
1616
assert self.client.groups.count() == 1
1717

1818
def test_get(self):
19-
assert self.client.groups.get(self.item["guid"])
19+
assert self.client.groups.get(self.group["guid"])
2020

2121
def test_find(self):
22-
assert self.client.groups.find() == [self.item]
22+
assert self.client.groups.find() == [self.group]
2323

2424
def test_find_one(self):
25-
assert self.client.groups.find_one() == self.item
25+
assert self.client.groups.find_one() == self.group

tests/posit/connect/test_client.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,35 +234,45 @@ def test_get(self, MockSession):
234234
url = "https://connect.example.com"
235235
client = Client(api_key=api_key, url=url)
236236
client.get("/foo")
237-
client.session.get.assert_called_once_with("https://connect.example.com/__api__/foo")
237+
MockSession.return_value.get.assert_called_once_with(
238+
"https://connect.example.com/__api__/foo"
239+
)
238240

239241
def test_post(self, MockSession):
240242
api_key = "12345"
241243
url = "https://connect.example.com"
242244
client = Client(api_key=api_key, url=url)
243245
client.post("/foo")
244-
client.session.post.assert_called_once_with("https://connect.example.com/__api__/foo")
246+
MockSession.return_value.post.assert_called_once_with(
247+
"https://connect.example.com/__api__/foo"
248+
)
245249

246250
def test_put(self, MockSession):
247251
api_key = "12345"
248252
url = "https://connect.example.com"
249253
client = Client(api_key=api_key, url=url)
250254
client.put("/foo")
251-
client.session.put.assert_called_once_with("https://connect.example.com/__api__/foo")
255+
MockSession.return_value.put.assert_called_once_with(
256+
"https://connect.example.com/__api__/foo"
257+
)
252258

253259
def test_patch(self, MockSession):
254260
api_key = "12345"
255261
url = "https://connect.example.com"
256262
client = Client(api_key=api_key, url=url)
257263
client.patch("/foo")
258-
client.session.patch.assert_called_once_with("https://connect.example.com/__api__/foo")
264+
MockSession.return_value.patch.assert_called_once_with(
265+
"https://connect.example.com/__api__/foo"
266+
)
259267

260268
def test_delete(self, MockSession):
261269
api_key = "12345"
262270
url = "https://connect.example.com"
263271
client = Client(api_key=api_key, url=url)
264272
client.delete("/foo")
265-
client.session.delete.assert_called_once_with("https://connect.example.com/__api__/foo")
273+
MockSession.return_value.delete.assert_called_once_with(
274+
"https://connect.example.com/__api__/foo"
275+
)
266276

267277

268278
class TestClientOAuth:

tests/posit/connect/test_hooks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,8 @@ def test_deprecation_warning():
7777
)
7878
c = Client("https://connect.example", "12345")
7979

80-
with pytest.warns(DeprecationWarning):
80+
with pytest.warns(
81+
DeprecationWarning,
82+
match="https://connect.example/__api__/v0 is deprecated and will be removed in a future version of Connect. Please upgrade `posit-sdk` in order to use the new APIs.",
83+
):
8184
c.get("v0")

0 commit comments

Comments
 (0)