Skip to content

Commit

Permalink
Update response for schedule list API
Browse files Browse the repository at this point in the history
  • Loading branch information
tung-vu-td committed Jul 25, 2024
1 parent e91d849 commit a13db90
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
21 changes: 21 additions & 0 deletions tdclient/schedule_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def __init__(self, client, *args, **kwargs):
self._result = kwargs.get("result")
self._next_time = kwargs.get("next_time")
self._org_name = kwargs.get("org_name")
self._id = kwargs.get("id")
self._executing_user_id = kwargs.get("executing_user_id")
self._description = kwargs.get("description")

@property
def name(self):
Expand Down Expand Up @@ -143,6 +146,24 @@ def user_name(self):
"""
return self._user_name

@property
def id(self):
"""int: id of the query
"""
return self._id

@property
def executing_user_id(self):
"""int: executor's id of the query
"""
return self._executing_user_id

@property
def description(self):
"""str: description of the query
"""
return self._description

def run(self, time, num=None):
"""Run a scheduled job
Expand Down
15 changes: 12 additions & 3 deletions tdclient/test/schedule_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def test_list_schedules_success():
"priority": 0,
"retry_limit": 0,
"result": "",
"next_time": null
"next_time": null,
"id": 123,
"executing_user_id": 1,
"description": "query description 1"
},
{
"name": "bar",
Expand All @@ -103,7 +106,10 @@ def test_list_schedules_success():
"priority": 0,
"retry_limit": 0,
"result": "",
"next_time": "2016-09-24T00:00:00Z"
"next_time": "2016-09-24T00:00:00Z",
"id": 124,
"executing_user_id": 1,
"description": "query description 2"
},
{
"name": "baz",
Expand All @@ -118,7 +124,10 @@ def test_list_schedules_success():
"priority": 0,
"retry_limit": 0,
"result": "",
"next_time": "2016-07-06T00:00:00Z"
"next_time": "2016-07-06T00:00:00Z",
"id": 125,
"executing_user_id": 1,
"description": "query description 3"
}
]
}
Expand Down
6 changes: 6 additions & 0 deletions tdclient/test/schedule_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def test_schedule():
retry_limit="retry_limit",
org_name="org_name",
user_name="user_name",
id=123,
executing_user_id=1,
description="query description 1"
)
assert schedule.name == "name"
assert schedule.cron == "cron"
Expand All @@ -51,6 +54,9 @@ def test_schedule():
assert schedule.retry_limit == "retry_limit"
assert schedule.org_name == "org_name"
assert schedule.user_name == "user_name"
assert schedule.id == 123
assert schedule.executing_user_id == 1
assert schedule.description == "query description 1"


def test_schedule_run():
Expand Down

0 comments on commit a13db90

Please sign in to comment.