From eb70b5f115685db85f81125f2623cfd179a9546d Mon Sep 17 00:00:00 2001 From: tdstein Date: Thu, 13 Jun 2024 09:56:05 -0400 Subject: [PATCH] assert user endpoint called once --- integration/tests/posit/connect/test_content.py | 7 ++++++- tests/posit/connect/test_content.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/integration/tests/posit/connect/test_content.py b/integration/tests/posit/connect/test_content.py index 53422742..5e62f1fb 100644 --- a/integration/tests/posit/connect/test_content.py +++ b/integration/tests/posit/connect/test_content.py @@ -22,7 +22,12 @@ def test_find(self): def test_find_one(self): assert self.client.content.find_one() - def test_content_item_owner(self): + def test_content_item_owner_without_in(self): item = self.client.content.find_one(include=None) owner = item.owner assert owner.guid == self.client.me.guid + + def test_content_item_owner_from_include(self): + item = self.client.content.find_one(include="owner") + owner = item.owner + assert owner.guid == self.client.me.guid diff --git a/tests/posit/connect/test_content.py b/tests/posit/connect/test_content.py index a85e9ba5..4980029f 100644 --- a/tests/posit/connect/test_content.py +++ b/tests/posit/connect/test_content.py @@ -198,7 +198,7 @@ def test_owner(self): json=mock_content, ) - responses.get( + mock_user_get = responses.get( f"https://connect.example/__api__/v1/users/20a79ce3-6e87-4522-9faf-be24228800a4", json=load_mock( f"v1/users/20a79ce3-6e87-4522-9faf-be24228800a4.json" @@ -210,6 +210,11 @@ def test_owner(self): owner = item.owner assert owner.guid == "20a79ce3-6e87-4522-9faf-be24228800a4" + # load a second time, assert tha owner is loaded from cached result + owner = item.owner + assert owner.guid == "20a79ce3-6e87-4522-9faf-be24228800a4" + assert mock_user_get.call_count == 1 + class TestContentItemDelete: @responses.activate