mirror of
https://github.com/N4S4/synology-api.git
synced 2025-07-21 10:44:01 +00:00
add test resources to gitignore
add test class to implement test cases add test case to cover filestation login add test case to cover surveillance station login
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@ -398,4 +398,7 @@ FodyWeavers.xsd
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
*.sln.iml
|
||||
|
||||
# Test resources
|
||||
tests/resources/config-test.json
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
10
tests/resources/config-test-sample.json
Normal file
10
tests/resources/config-test-sample.json
Normal file
@ -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
|
||||
}
|
53
tests/test_syno_api.py
Normal file
53
tests/test_syno_api.py
Normal file
@ -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/')
|
Reference in New Issue
Block a user