Skip to content

Commit b3ff1cd

Browse files
committed
remove self imposed complexity of the method
1 parent ac488c7 commit b3ff1cd

File tree

2 files changed

+1
-39
lines changed

2 files changed

+1
-39
lines changed

src/posit/connect/resources.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,6 @@ def _create_instance(self, path: str, /, **kwargs: Any) -> T:
103103
"""Create an instance of 'T'."""
104104
raise NotImplementedError()
105105

106-
def cached(self) -> bool:
107-
"""Returns True if the collection is cached.
108-
109-
Returns
110-
-------
111-
bool
112-
113-
See Also
114-
--------
115-
reload
116-
"""
117-
return self._cache is not None
118-
119106
def reload(self) -> Self:
120107
"""Reloads the collection from Connect.
121108
@@ -194,7 +181,7 @@ def find(self, uid) -> T:
194181
"""
195182
Find a record by its unique identifier.
196183
197-
If the cache is already populated, it is checked first for matching record. If not, a conventional GET request is made to the Connect server.
184+
Fetches the record from Connect by it's identifier.
198185
199186
Parameters
200187
----------
@@ -205,12 +192,6 @@ def find(self, uid) -> T:
205192
-------
206193
T
207194
"""
208-
if self.cached():
209-
conditions = {self._uid: uid}
210-
result = self.find_by(**conditions)
211-
if result:
212-
return result
213-
214195
endpoint = self._ctx.url + self._path + uid
215196
response = self._ctx.session.get(endpoint)
216197
result = response.json()

tests/posit/connect/test_jobs.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,6 @@ def test(self):
4646
job = content.jobs.find("tHawGvHZTosJA2Dx")
4747
assert job["key"] == "tHawGvHZTosJA2Dx"
4848

49-
@responses.activate
50-
def test_cached(self):
51-
responses.get(
52-
"https://connect.example/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066",
53-
json=load_mock("v1/content/f2f37341-e21d-3d80-c698-a935ad614066.json"),
54-
)
55-
56-
responses.get(
57-
"https://connect.example/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs",
58-
json=load_mock("v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json"),
59-
)
60-
61-
c = Client("https://connect.example", "12345")
62-
content = c.content.get("f2f37341-e21d-3d80-c698-a935ad614066")
63-
64-
assert content.jobs
65-
job = content.jobs.find("tHawGvHZTosJA2Dx")
66-
assert job["key"] == "tHawGvHZTosJA2Dx"
67-
6849
@responses.activate
6950
def test_miss(self):
7051
responses.get(

0 commit comments

Comments
 (0)