Skip to content

Commit 1d8d8a5

Browse files
committed
Add test to verify that workspace is included in query string on FullScanParams
Signed-off-by: lelia <lelia@socket.dev>
1 parent 76ef739 commit 1d8d8a5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/unit/test_working_endpoints_unit.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,38 @@ def test_fullscans_post_unit(self):
203203
finally:
204204
os.unlink(f.name)
205205

206+
def test_fullscans_post_with_workspace_unit(self):
207+
"""Test that workspace is included in the query string when set on FullScanParams."""
208+
expected_data = {"id": "new-scan"}
209+
self._mock_response(expected_data, 201)
210+
211+
params = FullScanParams(
212+
repo="assembly",
213+
org_slug="test-org",
214+
branch="main",
215+
workspace="grofers",
216+
)
217+
218+
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
219+
json.dump({"name": "test", "version": "1.0.0"}, f)
220+
f.flush()
221+
222+
try:
223+
with open(f.name, "rb") as file_obj:
224+
files = [("file", ("package.json", file_obj))]
225+
result = self.sdk.fullscans.post(files, params)
226+
227+
self.assertEqual(result, expected_data)
228+
call_args = self.mock_requests.request.call_args
229+
self.assertEqual(call_args[0][0], "POST")
230+
# Confirm workspace landed in the request URL query string
231+
request_url = call_args[0][1]
232+
self.assertIn("workspace=grofers", request_url)
233+
self.assertIn("repo=assembly", request_url)
234+
235+
finally:
236+
os.unlink(f.name)
237+
206238
def test_triage_list_alert_triage_unit(self):
207239
"""Test triage list alerts - WORKING."""
208240
expected_data = {"alerts": []}

0 commit comments

Comments
 (0)