Skip to content

Commit 5460791

Browse files
committed
Add test
1 parent 501df2e commit 5460791

File tree

7 files changed

+337
-11
lines changed

7 files changed

+337
-11
lines changed

synology_dsm/api/download_station/task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def title(self):
2424

2525
@property
2626
def type(self):
27-
"""Return type of the task."""
27+
"""Return type of the task (bt, nzb, http(s), ftp, emule)."""
2828
return self._data["type"]
2929

3030
@property
@@ -45,7 +45,7 @@ def status(self):
4545
@property
4646
def status_extra(self):
4747
"""Return status_extra of the task."""
48-
return self._data["status_extra"]
48+
return self._data.get("status_extra")
4949

5050
@property
5151
def additional(self):

synology_dsm/synology_dsm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def reset(self, api):
355355

356356
@property
357357
def download_station(self):
358-
"""Gets NAS informations."""
358+
"""Gets NAS DownloadStation."""
359359
if not self._download:
360360
self._download = SynoDownloadStation(self)
361361
return self._download

tests/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from synology_dsm.api.core.utilization import SynoCoreUtilization
1111
from synology_dsm.api.dsm.information import SynoDSMInformation
1212
from synology_dsm.api.dsm.network import SynoDSMNetwork
13+
from synology_dsm.api.download_station import SynoDownloadStation
1314
from synology_dsm.api.storage.storage import SynoStorage
1415
from synology_dsm.api.surveillance_station import SynoSurveillanceStation
1516
from synology_dsm.const import API_AUTH, API_INFO
@@ -42,6 +43,7 @@
4243
DSM_6_SURVEILLANCE_STATION_CAMERA_LIST,
4344
DSM_6_SURVEILLANCE_STATION_HOME_MODE_GET_INFO,
4445
DSM_6_SURVEILLANCE_STATION_HOME_MODE_SWITCH,
46+
DSM_6_DOWNLOAD_STATION_TASK_LIST,
4547
)
4648
from .api_data.dsm_5 import (
4749
DSM_5_API_INFO,
@@ -190,12 +192,6 @@ def _execute_request(self, method, url, params, **kwargs):
190192
if not self._session_id:
191193
return ERROR_INSUFFICIENT_USER_PRIVILEGE
192194

193-
if SynoDSMInformation.API_KEY in url:
194-
return API_SWITCHER[self.dsm_version]["DSM_INFORMATION"]
195-
196-
if SynoDSMNetwork.API_KEY in url:
197-
return API_SWITCHER[self.dsm_version]["DSM_NETWORK"]
198-
199195
if SynoCoreSecurity.API_KEY in url:
200196
if self.error:
201197
return DSM_6_CORE_SECURITY_UPDATE_OUTOFDATE
@@ -206,6 +202,16 @@ def _execute_request(self, method, url, params, **kwargs):
206202
return DSM_6_CORE_UTILIZATION_ERROR_1055
207203
return API_SWITCHER[self.dsm_version]["CORE_UTILIZATION"]
208204

205+
if SynoDSMInformation.API_KEY in url:
206+
return API_SWITCHER[self.dsm_version]["DSM_INFORMATION"]
207+
208+
if SynoDSMNetwork.API_KEY in url:
209+
return API_SWITCHER[self.dsm_version]["DSM_NETWORK"]
210+
211+
if SynoDownloadStation.TASK_API_KEY in url:
212+
if "List" in url:
213+
return DSM_6_DOWNLOAD_STATION_TASK_LIST
214+
209215
if SynoStorage.API_KEY in url:
210216
return API_SWITCHER[self.dsm_version]["STORAGE_STORAGE"][
211217
self.disks_redundancy

tests/api_data/dsm_6/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
DSM_6_CORE_SECURITY,
1414
DSM_6_CORE_SECURITY_UPDATE_OUTOFDATE,
1515
)
16+
from .download_station.const_6_download_station_task import (
17+
DSM_6_DOWNLOAD_STATION_TASK_LIST,
18+
)
1619
from .dsm.const_6_dsm_info import DSM_6_DSM_INFORMATION
1720
from .dsm.const_6_dsm_network import DSM_6_DSM_NETWORK
1821
from .storage.const_6_storage_storage import (
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""DSM 6 SYNO.DownloadStation.* datas."""
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
# -*- coding: utf-8 -*-
2+
"""DSM 6 SYNO.DownloadStation.Task data."""
3+
4+
DSM_6_DOWNLOAD_STATION_TASK_LIST = {
5+
"data": {
6+
"offset": 0,
7+
"tasks": [
8+
{
9+
"additional": {
10+
"detail": {
11+
"completed_time": 0,
12+
"connected_leechers": 0,
13+
"connected_peers": 0,
14+
"connected_seeders": 0,
15+
"create_time": 1550089068,
16+
"destination": "Folder/containing/downloads",
17+
"seedelapsed": 0,
18+
"started_time": 1592549339,
19+
"total_peers": 0,
20+
"total_pieces": 1239,
21+
"unzip_password": "",
22+
"uri": "magnet:?xt=urn:btih:1234ABCD1234ABCD1234ABCD1234ABCD1234ABCD&dn=1234",
23+
"waiting_seconds": 0,
24+
},
25+
"file": [
26+
{
27+
"filename": "INFO.nfo",
28+
"index": 0,
29+
"priority": "normal",
30+
"size": 1335,
31+
"size_downloaded": 0,
32+
"wanted": True,
33+
},
34+
{
35+
"filename": "Spy Kids 2 2002.mkv",
36+
"index": 1,
37+
"priority": "normal",
38+
"size": 1591087515,
39+
"size_downloaded": 0,
40+
"wanted": True,
41+
},
42+
{
43+
"filename": "Spy Kids 2 sample.mkv",
44+
"index": 2,
45+
"priority": "normal",
46+
"size": 2754524,
47+
"size_downloaded": 0,
48+
"wanted": True,
49+
},
50+
{
51+
"filename": "Spy Kids 2001.mkv",
52+
"index": 3,
53+
"priority": "normal",
54+
"size": 1155085341,
55+
"size_downloaded": 0,
56+
"wanted": True,
57+
},
58+
{
59+
"filename": "Spy Kids 2001 sample.mkv",
60+
"index": 4,
61+
"priority": "normal",
62+
"size": 4359701,
63+
"size_downloaded": 0,
64+
"wanted": True,
65+
},
66+
{
67+
"filename": "Spy Kids 3 2003.mkv",
68+
"index": 5,
69+
"priority": "normal",
70+
"size": 1288819263,
71+
"size_downloaded": 0,
72+
"wanted": True,
73+
},
74+
{
75+
"filename": "Spy Kids 3 sample.mkv",
76+
"index": 6,
77+
"priority": "normal",
78+
"size": 3077684,
79+
"size_downloaded": 0,
80+
"wanted": True,
81+
},
82+
{
83+
"filename": "Spy Kids 4 2011.mkv",
84+
"index": 7,
85+
"priority": "normal",
86+
"size": 1149397942,
87+
"size_downloaded": 0,
88+
"wanted": True,
89+
},
90+
{
91+
"filename": "Spy Kids 4 sample.mkv",
92+
"index": 8,
93+
"priority": "normal",
94+
"size": 2003179,
95+
"size_downloaded": 0,
96+
"wanted": True,
97+
},
98+
],
99+
},
100+
"id": "dbid_86",
101+
"size": 5196586484,
102+
"status": "downloading",
103+
"title": "Spy Kids Complete Saga 2001-2011 BDRip 720p-HighCode",
104+
"type": "bt",
105+
"username": "Test_useR",
106+
},
107+
{
108+
"additional": {
109+
"detail": {
110+
"completed_time": 0,
111+
"connected_leechers": 0,
112+
"connected_peers": 0,
113+
"connected_seeders": 0,
114+
"create_time": 1551214114,
115+
"destination": "Folder/containing/downloads",
116+
"seedelapsed": 0,
117+
"started_time": 1592549348,
118+
"total_peers": 0,
119+
"total_pieces": 948,
120+
"unzip_password": "",
121+
"uri": "magnet:?xt=urn:btih:1234ABCD1234ABCD1234ABCD1234ABCD1234ABCD&dn=1234",
122+
"waiting_seconds": 0,
123+
},
124+
"file": [
125+
{
126+
"filename": "Blade Runner 1982.mkv",
127+
"index": 0,
128+
"priority": "normal",
129+
"size": 1986298376,
130+
"size_downloaded": 1602519560,
131+
"wanted": True,
132+
}
133+
],
134+
},
135+
"id": "dbid_164",
136+
"size": 1986298376,
137+
"status": "downloading",
138+
"title": "Blade Runner 1982.mkv",
139+
"type": "bt",
140+
"username": "Test_useR",
141+
},
142+
{
143+
"additional": {
144+
"detail": {
145+
"completed_time": 0,
146+
"connected_leechers": 0,
147+
"connected_peers": 50,
148+
"connected_seeders": 50,
149+
"create_time": 1585435581,
150+
"destination": "Folder/containing/downloads",
151+
"seedelapsed": 0,
152+
"started_time": 1592549349,
153+
"total_peers": 0,
154+
"total_pieces": 0,
155+
"unzip_password": "",
156+
"uri": "magnet:?xt=urn:btih:1234ABCD1234ABCD1234ABCD1234ABCD1234ABCD&dn=1234",
157+
"waiting_seconds": 0,
158+
},
159+
"file": [],
160+
},
161+
"id": "dbid_486",
162+
"size": 0,
163+
"status": "downloading",
164+
"title": "La Chute",
165+
"type": "bt",
166+
"username": "Test_useR",
167+
},
168+
{
169+
"additional": {
170+
"detail": {
171+
"completed_time": 0,
172+
"connected_leechers": 0,
173+
"connected_peers": 1,
174+
"connected_seeders": 1,
175+
"create_time": 1591562665,
176+
"destination": "Folder/containing/downloads",
177+
"seedelapsed": 0,
178+
"started_time": 1591563597,
179+
"total_peers": 0,
180+
"total_pieces": 1494,
181+
"unzip_password": "",
182+
"uri": "magnet:?xt=urn:btih:1234ABCD1234ABCD1234ABCD1234ABCD1234ABCD&dn=1234",
183+
"waiting_seconds": 0,
184+
}
185+
},
186+
"id": "dbid_518",
187+
"size": 391580448,
188+
"status": "paused",
189+
"title": "Bienvenue chez les Ch'tis.mkv",
190+
"type": "bt",
191+
"username": "Test_useR",
192+
},
193+
{
194+
"additional": {
195+
"detail": {
196+
"completed_time": 1591565351,
197+
"connected_leechers": 0,
198+
"connected_peers": 0,
199+
"connected_seeders": 0,
200+
"create_time": 1591563606,
201+
"destination": "Folder/containing/downloads",
202+
"seedelapsed": 172800,
203+
"started_time": 1592601577,
204+
"total_peers": 0,
205+
"total_pieces": 5466,
206+
"unzip_password": "",
207+
"uri": "magnet:?xt=urn:btih:1234ABCD1234ABCD1234ABCD1234ABCD1234ABCD&dn=1234",
208+
"waiting_seconds": 0,
209+
}
210+
},
211+
"id": "dbid_522",
212+
"size": 5731285821,
213+
"status": "finished",
214+
"title": "Birds of Prey.mkv",
215+
"type": "bt",
216+
"username": "Test_useR",
217+
},
218+
{
219+
"additional": {
220+
"detail": {
221+
"completed_time": 1591566799,
222+
"connected_leechers": 0,
223+
"connected_peers": 0,
224+
"connected_seeders": 0,
225+
"create_time": 1591566523,
226+
"destination": "Folder/containing/downloads",
227+
"seedelapsed": 0,
228+
"started_time": 1591566696,
229+
"total_peers": 0,
230+
"total_pieces": 0,
231+
"unzip_password": "",
232+
"uri": "https://1fichier.com/?1234ABCD1234ABCD1234&af=22123",
233+
"waiting_seconds": 0,
234+
}
235+
},
236+
"id": "dbid_531",
237+
"size": 2811892495,
238+
"status": "finished",
239+
"title": "1234ABCD1234ABCD1234",
240+
"type": "https",
241+
"username": "Test_useR",
242+
},
243+
{
244+
"additional": {
245+
"detail": {
246+
"completed_time": 0,
247+
"connected_leechers": 0,
248+
"connected_peers": 0,
249+
"connected_seeders": 0,
250+
"create_time": 1591566903,
251+
"destination": "Folder/containing/downloads",
252+
"seedelapsed": 0,
253+
"started_time": 0,
254+
"total_peers": 0,
255+
"total_pieces": 0,
256+
"unzip_password": "",
257+
"uri": "https://1fichier.com/?123ABC123ABC123ABC12",
258+
"waiting_seconds": 0,
259+
}
260+
},
261+
"id": "dbid_533",
262+
"size": 0,
263+
"status": "error",
264+
"status_extra": {"error_detail": "unknown"},
265+
"title": "?123ABC123ABC123ABC12",
266+
"type": "https",
267+
"username": "Test_useR",
268+
},
269+
{
270+
"additional": {
271+
"detail": {
272+
"completed_time": 0,
273+
"connected_leechers": 0,
274+
"connected_peers": 0,
275+
"connected_seeders": 0,
276+
"create_time": 1592605687,
277+
"destination": "Folder/containing/downloads",
278+
"seedelapsed": 0,
279+
"started_time": 1592605731,
280+
"total_peers": 0,
281+
"total_pieces": 0,
282+
"unzip_password": "",
283+
"uri": "https://1fichier.com/?123ABC123ABC123ABC12",
284+
"waiting_seconds": 0,
285+
}
286+
},
287+
"id": "dbid_549",
288+
"size": 0,
289+
"status": "error",
290+
"status_extra": {"error_detail": "broken_link"},
291+
"title": "123ABC123ABC123ABC12",
292+
"type": "https",
293+
"username": "Test_useR",
294+
},
295+
],
296+
"total": 25,
297+
},
298+
"success": True,
299+
}

0 commit comments

Comments
 (0)