Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
islean committed Dec 12, 2023
1 parent 1f5dc99 commit 4fdee1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
1 change: 1 addition & 0 deletions cg/cli/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def update_job_statuses(context: CGConfig):
@click.pass_obj
@click.argument("file_path", required=True)
def delete_file(context: CGConfig, file_path: str):
"""Delete an archived file and remove it from Housekeeper."""
spring_archive_api = SpringArchiveAPI(
status_db=context.status_db,
housekeeper_api=context.housekeeper_api,
Expand Down
25 changes: 7 additions & 18 deletions cg/meta/archive/ddn_dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
SOURCE_ATTRIBUTE: str = "source"


def get_request_log(headers: dict, body: dict):
return "Sending request with headers: \n" + f"{headers} \n" + "and body: \n" + f"{body}"


class DataflowEndpoints(StrEnum):
"""Enum containing all DDN dataflow endpoints used."""

Expand Down Expand Up @@ -156,12 +160,7 @@ def post_request(self, url: str, headers: dict) -> "TransferJob":
The job ID of the launched transfer task.
"""

LOG.info(
"Sending request with headers: \n"
+ f"{headers} \n"
+ "and body: \n"
+ f"{self.model_dump()}"
)
LOG.info(get_request_log(headers=headers, body=self.model_dump()))

response: Response = APIRequest.api_request_from_content(
api_method=APIMethods.POST,
Expand Down Expand Up @@ -223,12 +222,7 @@ def get_job_status(self, url: str, headers: dict) -> GetJobStatusResponse:
HTTPError if the response code is not ok.
"""

LOG.info(
"Sending request with headers: \n"
+ f"{headers} \n"
+ "and body: \n"
+ f"{self.model_dump()}"
)
LOG.info(get_request_log(headers=headers, body=self.model_dump()))

response: Response = APIRequest.api_request_from_content(
api_method=APIMethods.GET,
Expand All @@ -254,12 +248,7 @@ def delete_file(self, url: str, headers: dict) -> DeleteFileResponse:
Raises:
HTTPError if the response code is not ok.
"""
LOG.info(
"Sending request with headers: \n"
+ f"{headers} \n"
+ "and body: \n"
+ f"{self.model_dump()}"
)
LOG.info(get_request_log(headers=headers, body=self.model_dump()))

response: Response = APIRequest.api_request_from_content(
api_method=APIMethods.POST,
Expand Down

0 comments on commit 4fdee1a

Please sign in to comment.