-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test class to implement test cases add test case to cover filestation login add test case to cover surveillance station login
- Loading branch information
Fabio Testa
committed
Mar 14, 2024
1 parent
af66dd6
commit c0c28db
Showing
4 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#### COPY THIS FILE AND NAME IT config-test.json AND REPLACE WITH YOUR VALUES | ||
{ | ||
"synology_ip": "your_dsm_ip", | ||
"synology_port": your_dsm_port_as_int, | ||
"synology_user": "your_dsm_user", | ||
"synology_password": "your_dsm_password", | ||
"synology_secure": true_if_your_dsm_http_endpoint_is_https, | ||
"dsm_version": your_dsm_version_as_int, | ||
"otp_code": "your_dsm_otp_code"_or_null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import datetime | ||
import json | ||
from unittest import TestCase | ||
|
||
from synology_api.filestation import FileStation | ||
from synology_api.surveillancestation import SurveillanceStation | ||
|
||
|
||
def parse_config(config_path) -> dict[str, str]: | ||
with open(config_path, 'r') as config_file: | ||
config_data = json.load(config_file) | ||
return config_data | ||
|
||
|
||
class TestSynoApi(TestCase): | ||
config: dict[str, str] | ||
|
||
def setUp(self): | ||
self.config = parse_config('./resources/config-test.json') | ||
|
||
def test_syno_filestation_login(self): | ||
fs = FileStation(ip_address=self.config["synology_ip"], port=self.config["synology_port"], | ||
username=self.config["synology_user"], | ||
password=self.config["synology_password"], | ||
secure=bool(self.config["synology_secure"]), cert_verify=False, | ||
dsm_version=int(self.config["dsm_version"]), debug=True, | ||
otp_code=self.config["otp_code"]) | ||
|
||
self.assertIsNotNone(fs) | ||
self.assertIsNotNone(fs.session) | ||
self.assertIsNotNone(fs.session.sid) | ||
self.assertIsNot(fs.session.sid, '') | ||
shares_list = fs.get_list_share() | ||
self.assertIsNotNone(shares_list) | ||
self.assertEqual(shares_list.__len__(), 2) | ||
|
||
def test_syno_surveillancestation_login(self): | ||
ss = SurveillanceStation(ip_address=self.config["synology_ip"], port=self.config["synology_port"], | ||
username=self.config["synology_user"], | ||
password=self.config["synology_password"], | ||
secure=bool(self.config["synology_secure"]), cert_verify=False, | ||
dsm_version=int(self.config["dsm_version"]), debug=True, | ||
otp_code=self.config["otp_code"]) | ||
|
||
self.assertIsNotNone(ss) | ||
self.assertIsNotNone(ss.session) | ||
self.assertIsNotNone(ss.session.sid) | ||
self.assertIsNot(ss.session.sid, '') | ||
ss_info = ss.surveillance_station_info() | ||
self.assertIsNotNone(ss_info) | ||
ss_info_data = ss_info['data'] | ||
self.assertIsNotNone(ss_info_data) | ||
self.assertEqual(ss_info_data['path'], '/webman/3rdparty/SurveillanceStation/') |