diff --git a/synology_dsm/api/download_station/__init__.py b/synology_dsm/api/download_station/__init__.py index b11c706a..af6a9d2d 100644 --- a/synology_dsm/api/download_station/__init__.py +++ b/synology_dsm/api/download_station/__init__.py @@ -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): @@ -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.""" diff --git a/tests/__init__.py b/tests/__init__.py index fc737f16..be29abf3 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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 ( @@ -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 diff --git a/tests/api_data/dsm_6/__init__.py b/tests/api_data/dsm_6/__init__.py index aacc9028..b74f9e37 100644 --- a/tests/api_data/dsm_6/__init__.py +++ b/tests/api_data/dsm_6/__init__.py @@ -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, ) diff --git a/tests/api_data/dsm_6/download_station/const_6_download_station_stat.py b/tests/api_data/dsm_6/download_station/const_6_download_station_stat.py new file mode 100644 index 00000000..b5f8c004 --- /dev/null +++ b/tests/api_data/dsm_6/download_station/const_6_download_station_stat.py @@ -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, +} diff --git a/tests/test_synology_dsm.py b/tests/test_synology_dsm.py index 4127222d..1461e49b 100644 --- a/tests/test_synology_dsm.py +++ b/tests/test_synology_dsm.py @@ -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