Skip to content

test(fix): destroy the default integration before testing #417

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 3 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions integration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ PYTEST_ARGS ?= "-s"

# Versions
CONNECT_VERSIONS := \
2025.06.0 \
2025.05.0 \
2025.04.0 \
2025.03.0 \
2025.02.0 \
Expand Down
19 changes: 19 additions & 0 deletions integration/tests/posit/connect/oauth/test_associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ class TestAssociations:
@classmethod
def setup_class(cls):
cls.client = connect.Client()

# Destroy existing integrations.
#
# Starting with Connect 2025.05.0, a default integration is created automatically.
# https://github.com/posit-dev/connect/issues/31570
for integration in cls.client.oauth.integrations.find():
integration.delete()

# Assert that no integrations exist
assert len(cls.client.oauth.integrations.find()) == 0

cls.integration = cls.client.oauth.integrations.create(
name="example integration",
description="integration description",
Expand Down Expand Up @@ -49,10 +60,12 @@ def setup_class(cls):
# create content
# requires full bundle deployment to produce an interactive content type
cls.content = cls.client.content.create(name="example-flask-minimal")

# create bundle
path = Path("../../../../resources/connect/bundles/example-flask-minimal/bundle.tar.gz")
path = (Path(__file__).parent / path).resolve()
bundle = cls.content.bundles.create(str(path))

# deploy bundle
task = bundle.deploy()
task.wait_for()
Expand All @@ -61,11 +74,17 @@ def setup_class(cls):

@classmethod
def teardown_class(cls):
# Destroy created integrations.
cls.integration.delete()
cls.another_integration.delete()

# Assert that no integrations exist
assert len(cls.client.oauth.integrations.find()) == 0

# Destroy created content
cls.content.delete()

# Assert that no content exists
assert cls.client.content.count() == 0

def test_find_by_integration(self):
Expand Down
10 changes: 5 additions & 5 deletions integration/tests/posit/connect/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ class TestGroups:
@classmethod
def setup_class(cls):
cls.client = connect.Client()
cls.item = cls.client.groups.create(name="Friends")
cls.group = cls.client.groups.create(name="Friends")

@classmethod
def teardown_class(cls):
cls.item.delete()
cls.group.delete()
assert cls.client.groups.count() == 0

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

def test_get(self):
assert self.client.groups.get(self.item["guid"])
assert self.client.groups.get(self.group["guid"])

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

def test_find_one(self):
assert self.client.groups.find_one() == self.item
assert self.client.groups.find_one() == self.group
20 changes: 15 additions & 5 deletions tests/posit/connect/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,35 +234,45 @@ def test_get(self, MockSession):
url = "https://connect.example.com"
client = Client(api_key=api_key, url=url)
client.get("/foo")
client.session.get.assert_called_once_with("https://connect.example.com/__api__/foo")
MockSession.return_value.get.assert_called_once_with(
"https://connect.example.com/__api__/foo"
)

def test_post(self, MockSession):
api_key = "12345"
url = "https://connect.example.com"
client = Client(api_key=api_key, url=url)
client.post("/foo")
client.session.post.assert_called_once_with("https://connect.example.com/__api__/foo")
MockSession.return_value.post.assert_called_once_with(
"https://connect.example.com/__api__/foo"
)

def test_put(self, MockSession):
api_key = "12345"
url = "https://connect.example.com"
client = Client(api_key=api_key, url=url)
client.put("/foo")
client.session.put.assert_called_once_with("https://connect.example.com/__api__/foo")
MockSession.return_value.put.assert_called_once_with(
"https://connect.example.com/__api__/foo"
)

def test_patch(self, MockSession):
api_key = "12345"
url = "https://connect.example.com"
client = Client(api_key=api_key, url=url)
client.patch("/foo")
client.session.patch.assert_called_once_with("https://connect.example.com/__api__/foo")
MockSession.return_value.patch.assert_called_once_with(
"https://connect.example.com/__api__/foo"
)

def test_delete(self, MockSession):
api_key = "12345"
url = "https://connect.example.com"
client = Client(api_key=api_key, url=url)
client.delete("/foo")
client.session.delete.assert_called_once_with("https://connect.example.com/__api__/foo")
MockSession.return_value.delete.assert_called_once_with(
"https://connect.example.com/__api__/foo"
)


class TestClientOAuth:
Expand Down
5 changes: 4 additions & 1 deletion tests/posit/connect/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,8 @@ def test_deprecation_warning():
)
c = Client("https://connect.example", "12345")

with pytest.warns(DeprecationWarning):
with pytest.warns(
DeprecationWarning,
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.",
):
c.get("v0")