Skip to content

Commit d71bd3c

Browse files
author
Paweł Mudlaff
committed
Update code to pass tests
1 parent 586a296 commit d71bd3c

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

gradient/api_sdk/repositories/jobs.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from gradient import config
22
from gradient.api_sdk import serializers
3+
from gradient.api_sdk.clients import http_client
34
from .common import ListResources, CreateResource, BaseRepository, GetResource, DeleteResource, StopResource
45
from ..serializers import JobSchema, LogRowSchema
56

@@ -150,20 +151,22 @@ def _get_request_params(self, kwargs):
150151
return params
151152

152153

153-
class DeleteJobArtifacts(GetBaseJobApiUrlMixin, BaseRepository):
154+
class DeleteJobArtifacts(GetBaseJobApiUrlMixin, DeleteResource):
154155
VALIDATION_ERROR_MESSAGE = "Failed to delete resource"
155156

156157
def get_request_url(self, **kwargs):
157158
return "/jobs/{}/artifactsDestroy".format(kwargs.get("id"))
158159

159-
# def delete(self, id_, **kwargs):
160-
# url = self.get_request_url(id_=id_)
161-
#
162-
# params = self._get_request_params(kwargs)
163-
#
164-
# client = self._get_client()
165-
# response = client.post(url, json=kwargs.get("json"), params=params)
166-
# self._validate_response(response)
160+
def _send(self, url, use_vpc=False, **kwargs):
161+
client = self._get_client(use_vpc=use_vpc)
162+
params_data = self._get_request_params(kwargs)
163+
response = self._send_request(client, url, params_data=params_data)
164+
gradient_response = http_client.GradientResponse.interpret_response(response)
165+
return gradient_response
166+
167+
def _send_request(self, client, url, params_data=None):
168+
response = client.post(url, params=params_data)
169+
return response
167170

168171
def _get_request_params(self, kwargs):
169172
filters = dict()

tests/functional/test_jobs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def test_should_send_valid_post_request_when_destroying_artifacts_with_files_spe
311311
"some_key"])
312312

313313
assert result.exit_code == 0, result.exc_info
314-
post_patched.assert_called_with("{}/jobs/{}/artifactsDestroy/".format(self.URL, job_id),
314+
post_patched.assert_called_with("{}/jobs/{}/artifactsDestroy".format(self.URL, job_id),
315315
files=None,
316316
headers=self.EXPECTED_HEADERS_WITH_CHANGED_API_KEY,
317317
json=None,
@@ -324,7 +324,7 @@ def test_should_send_valid_post_request_when_destroying_artifacts_without_files_
324324
job_id = "some_job_id"
325325
result = self.runner.invoke(cli.cli, ["jobs", "artifacts", "destroy", job_id, "--apiKey", "some_key"])
326326

327-
post_patched.assert_called_with("{}/jobs/{}/artifactsDestroy/".format(self.URL, job_id),
327+
post_patched.assert_called_with("{}/jobs/{}/artifactsDestroy".format(self.URL, job_id),
328328
files=None,
329329
headers=self.EXPECTED_HEADERS_WITH_CHANGED_API_KEY,
330330
json=None,
@@ -340,7 +340,7 @@ def test_should_read_options_from_yaml_file(self, post_patched, jobs_artifacts_d
340340
result = self.runner.invoke(cli.cli, command)
341341

342342
assert result.exit_code == 0, result.exc_info
343-
post_patched.assert_called_with("{}/jobs/some_id/artifactsDestroy/".format(self.URL),
343+
post_patched.assert_called_with("{}/jobs/some_id/artifactsDestroy".format(self.URL),
344344
files=None,
345345
headers=self.EXPECTED_HEADERS_WITH_CHANGED_API_KEY,
346346
json=None,

0 commit comments

Comments
 (0)