From c63c341797703024511eb84c3e6f6227d3a72030 Mon Sep 17 00:00:00 2001 From: tdstein Date: Tue, 1 Jul 2025 11:36:58 -0400 Subject: [PATCH 1/3] test(fix): destroy the default integration before testing. --- integration/Makefile | 2 ++ .../posit/connect/oauth/test_associations.py | 19 +++++++++++++++++++ .../tests/posit/connect/test_groups.py | 10 +++++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/integration/Makefile b/integration/Makefile index 7627a755..a00278a1 100644 --- a/integration/Makefile +++ b/integration/Makefile @@ -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 \ diff --git a/integration/tests/posit/connect/oauth/test_associations.py b/integration/tests/posit/connect/oauth/test_associations.py index 6ec3759d..45abdbcf 100644 --- a/integration/tests/posit/connect/oauth/test_associations.py +++ b/integration/tests/posit/connect/oauth/test_associations.py @@ -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", @@ -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() @@ -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): diff --git a/integration/tests/posit/connect/test_groups.py b/integration/tests/posit/connect/test_groups.py index 6c64dd81..4ecb992d 100644 --- a/integration/tests/posit/connect/test_groups.py +++ b/integration/tests/posit/connect/test_groups.py @@ -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 From 261a792b30f5634c44c934d156989e5b16ad712d Mon Sep 17 00:00:00 2001 From: tdstein Date: Tue, 1 Jul 2025 11:39:04 -0400 Subject: [PATCH 2/3] fix deprecation warning test --- tests/posit/connect/test_hooks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/posit/connect/test_hooks.py b/tests/posit/connect/test_hooks.py index 62a061aa..e058013e 100644 --- a/tests/posit/connect/test_hooks.py +++ b/tests/posit/connect/test_hooks.py @@ -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") From 4e469deadca8461d4f4b4f670eb3c864ce25498b Mon Sep 17 00:00:00 2001 From: tdstein Date: Tue, 1 Jul 2025 12:29:28 -0400 Subject: [PATCH 3/3] fix linting error --- tests/posit/connect/test_client.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/posit/connect/test_client.py b/tests/posit/connect/test_client.py index be6fe9f9..f72bf505 100644 --- a/tests/posit/connect/test_client.py +++ b/tests/posit/connect/test_client.py @@ -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: