Skip to content

Commit 7550b94

Browse files
committed
feat: update responses with content_guid and content_id
1 parent b61e2db commit 7550b94

File tree

7 files changed

+76
-1
lines changed

7 files changed

+76
-1
lines changed

src/posit/connect/jobs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def find_by(
9595
key: str = ...,
9696
remote_id: str | None = ...,
9797
app_id: str = ...,
98+
content_id: str = ...,
9899
variant_id: str = ...,
99100
bundle_id: str = ...,
100101
# Timestamps
@@ -129,6 +130,9 @@ def find_by(
129130
Identifier for off-host execution configurations.
130131
app_id : str, not required
131132
Identifier of the parent content associated with the job.
133+
This field is deprecated and has been renamed to content_id.
134+
content_id : str, not required
135+
Identifier of the parent content associated with the job.
132136
variant_id : str, not required
133137
Identifier of the variant responsible for the job.
134138
bundle_id : str, not required

src/posit/connect/packages.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def fetch(
9292
bundle_id: str = ...,
9393
app_id: str = ...,
9494
app_guid: str = ...,
95+
content_id: str = ...,
96+
content_guid: str = ...,
9597
) -> Iterable[Package]:
9698
"""
9799
Fetch all records matching the specified conditions.
@@ -110,8 +112,14 @@ def fetch(
110112
The unique identifier of the bundle this package is associated with.
111113
app_id: str, not required
112114
The numerical identifier of the application this package is associated with.
115+
This field is deprecated and has been renamed to content_id.
113116
app_guid: str, not required
114117
The unique identifier of the application this package is associated with.
118+
This field is deprecated and has been renamed to content_guid.
119+
content_id: str, not required
120+
The numerical identifier of the content item this package is associated with.
121+
content_guid: str, not required
122+
The unique identifier of the content item this package is associated with.
115123
116124
Returns
117125
-------
@@ -130,6 +138,8 @@ def find_by(
130138
bundle_id: str = ...,
131139
app_id: str = ...,
132140
app_guid: str = ...,
141+
content_id: str = ...,
142+
content_guid: str = ...,
133143
) -> Package | None:
134144
"""
135145
Find the first record matching the specified conditions.
@@ -150,8 +160,14 @@ def find_by(
150160
The unique identifier of the bundle this package is associated with.
151161
app_id: str, not required
152162
The numerical identifier of the application this package is associated with.
163+
This field is deprecated and has been renamed to content_id.
153164
app_guid: str, not required
154165
The unique identifier of the application this package is associated with.
166+
This field is deprecated and has been renamed to content_guid.
167+
content_id: str, not required
168+
The numerical identifier of the content item this package is associated with.
169+
content_guid: str, not required
170+
The unique identifier of the content item this package is associated with.
155171
156172
Returns
157173
-------

tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"key": "tHawGvHZTosJA2Dx",
77
"remote_id": "S3ViZXJuZXRlczpyZW5kZXItci1tYXJrZG93bi1zaXRlLWtnODJo",
88
"app_id": "54",
9+
"content_id": "54",
910
"variant_id": "54",
1011
"bundle_id": "54",
1112
"start_time": "2006-01-02T15:04:05-07:00",

tests/posit/connect/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs/tHawGvHZTosJA2Dx.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"key": "tHawGvHZTosJA2Dx",
66
"remote_id": "S3ViZXJuZXRlczpyZW5kZXItci1tYXJrZG93bi1zaXRlLWtnODJo",
77
"app_id": "54",
8+
"content_id": "54",
89
"variant_id": "54",
910
"bundle_id": "54",
1011
"start_time": "2006-01-02T15:04:05-07:00",

tests/posit/connect/__api__/v1/packages.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
{
44
"language": "python",
55
"name": "posit",
6-
"version": "0.6.0"
6+
"version": "0.6.0",
7+
"app_id": "123",
8+
"app_guid": "abcd-1234",
9+
"content_id": "123",
10+
"content_guid": "abcd-1234"
711
}
812
],
913
"current_page": 1,

tests/posit/connect/test_jobs.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,33 @@ def test(self):
9090
assert job
9191
assert job["key"] == "tHawGvHZTosJA2Dx"
9292

93+
@responses.activate
94+
def test_with_content_id(self):
95+
responses.get(
96+
"https://connect.example/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066",
97+
json=load_mock("v1/content/f2f37341-e21d-3d80-c698-a935ad614066.json"),
98+
)
99+
100+
responses.get(
101+
"https://connect.example/__api__/v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs",
102+
json=load_mock("v1/content/f2f37341-e21d-3d80-c698-a935ad614066/jobs.json"),
103+
)
104+
105+
c = Client("https://connect.example", "12345")
106+
content = c.content.get("f2f37341-e21d-3d80-c698-a935ad614066")
107+
108+
# Test with content_id (new field)
109+
job = content.jobs.find_by(content_id="54")
110+
assert job
111+
assert job["content_id"] == "54"
112+
assert job["app_id"] == "54" # Should have both fields
113+
114+
# Test with app_id (deprecated field)
115+
job = content.jobs.find_by(app_id="54")
116+
assert job
117+
assert job["app_id"] == "54"
118+
assert job["content_id"] == "54" # Should have both fields
119+
93120

94121
class TestJobDestory:
95122
@responses.activate

tests/posit/connect/test_packages.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,25 @@ def test(self):
2020
assert package
2121
assert package["name"] == "posit"
2222
assert mock_get.call_count == 1
23+
24+
@responses.activate
25+
def test_with_content_fields(self):
26+
mock_get = responses.get(
27+
"https://connect.example/__api__/v1/packages",
28+
json=load_mock("v1/packages.json"),
29+
)
30+
31+
c = Client("https://connect.example", "12345")
32+
c._ctx.version = None
33+
34+
# Test with content_id and content_guid (new fields)
35+
package = c.packages.find_by(name="posit", content_id="123", content_guid="abcd-1234")
36+
assert package
37+
assert package["name"] == "posit"
38+
assert mock_get.call_count == 1
39+
40+
# Test with app_id and app_guid (deprecated fields)
41+
package = c.packages.find_by(name="posit", app_id="123", app_guid="abcd-1234")
42+
assert package
43+
assert package["name"] == "posit"
44+
assert mock_get.call_count == 2

0 commit comments

Comments
 (0)