Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tdclient/schedule_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create_schedule(self, name, params=None):
if code != 200:
self.raise_error("Create schedule failed", res, body)
js = self.checked_json(body, ["start"])
return self._parsedate(js["start"], "%Y-%m-%d %H:%M:%S %Z")
return self._parsedate(self.get_or_else(js, "start", "1970-01-01T00:00:00Z"), "%Y-%m-%d %H:%M:%S %Z")

def delete_schedule(self, name):
"""
Expand Down
19 changes: 19 additions & 0 deletions tdclient/test/schedule_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ def test_create_schedule_success():
assert start.second == 51
assert start.utcoffset().seconds == 0 # UTC

def test_create_schedule_without_cron_success():
td = api.API("APIKEY")
# TODO: should be replaced by wire dump
body = b"""
{
"start": null
}
"""
td.post = mock.MagicMock(return_value=make_response(200, body))
start = td.create_schedule("bar", {"type": "presto", "cron": ""})
td.post.assert_called_with("/v3/schedule/create/bar", {"type": "presto", "cron": ""})
assert start.year == 1970
assert start.month == 1
assert start.day == 1
assert start.hour == 0
assert start.minute == 0
assert start.second == 0
assert start.utcoffset().seconds == 0 # UTC

def test_delete_schedule_success():
td = api.API("APIKEY")
# TODO: should be replaced by wire dump
Expand Down