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
5 changes: 5 additions & 0 deletions synology_dsm/api/download_station/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SynoDownloadStation(object):

API_KEY = "SYNO.DownloadStation.*"
INFO_API_KEY = "SYNO.DownloadStation.Info"
STAT_API_KEY = "SYNO.DownloadStation.Statistic"
TASK_API_KEY = "SYNO.DownloadStation.Task"

def __init__(self, dsm):
Expand Down Expand Up @@ -38,6 +39,10 @@ def get_config(self):
"""Return configuration about the Download Station instance."""
return self._dsm.get(self.INFO_API_KEY, "GetConfig")

def get_stat(self):
"""Return statistic about the Download Station instance."""
return self._dsm.get(self.STAT_API_KEY, "GetInfo")

# Downloads
def get_all_tasks(self):
"""Return a list of tasks."""
Expand Down
7 changes: 6 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
DSM_6_SURVEILLANCE_STATION_HOME_MODE_SWITCH,
DSM_6_DOWNLOAD_STATION_INFO_INFO,
DSM_6_DOWNLOAD_STATION_INFO_CONFIG,
DSM_6_DOWNLOAD_STATION_STAT_INFO,
DSM_6_DOWNLOAD_STATION_TASK_LIST,
)
from .api_data.dsm_5 import (
Expand Down Expand Up @@ -216,11 +217,15 @@ def _execute_request(self, method, url, params, **kwargs):
if SynoDSMNetwork.API_KEY in url:
return API_SWITCHER[self.dsm_version]["DSM_NETWORK"]

if SynoDownloadStation.TASK_API_KEY in url:
if SynoDownloadStation.INFO_API_KEY in url:
if "GetInfo" in url:
return DSM_6_DOWNLOAD_STATION_INFO_INFO
if "GetConfig" in url:
return DSM_6_DOWNLOAD_STATION_INFO_CONFIG
if SynoDownloadStation.STAT_API_KEY in url:
if "GetInfo" in url:
return DSM_6_DOWNLOAD_STATION_STAT_INFO
if SynoDownloadStation.TASK_API_KEY in url:
if "List" in url:
return DSM_6_DOWNLOAD_STATION_TASK_LIST

Expand Down
3 changes: 3 additions & 0 deletions tests/api_data/dsm_6/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
DSM_6_DOWNLOAD_STATION_INFO_INFO,
DSM_6_DOWNLOAD_STATION_INFO_CONFIG,
)
from .download_station.const_6_download_station_stat import (
DSM_6_DOWNLOAD_STATION_STAT_INFO,
)
from .download_station.const_6_download_station_task import (
DSM_6_DOWNLOAD_STATION_TASK_LIST,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
"""DSM 6 SYNO.DownloadStation.Statistic data."""

DSM_6_DOWNLOAD_STATION_STAT_INFO = {
"data": {"speed_download": 89950232, "speed_upload": 0},
"success": True,
}
5 changes: 3 additions & 2 deletions tests/test_synology_dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,9 @@ def test_download_station(self):
assert self.api.download_station
assert not self.api.download_station.get_all_tasks()

assert self.api.download_station.get_info()
assert self.api.download_station.get_config()
assert self.api.download_station.get_info()["data"]["version"]
assert self.api.download_station.get_config()["data"]["default_destination"]
assert self.api.download_station.get_stat()["data"]["speed_download"]
self.api.download_station.update()
assert self.api.download_station.get_all_tasks()
assert len(self.api.download_station.get_all_tasks()) == 8
Expand Down