You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.4 KiB
74 lines
2.4 KiB
6 years ago
|
#!/usr/bin/python3 -OO
|
||
|
# Copyright 2007-2019 The SABnzbd-Team <team@sabnzbd.org>
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
|
||
|
"""
|
||
|
tests.test_misc - Testing mailslot communiction on Windows
|
||
|
"""
|
||
|
|
||
|
import sys
|
||
|
import subprocess
|
||
6 years ago
|
import time
|
||
6 years ago
|
import pytest
|
||
|
|
||
|
if not sys.platform.startswith("win"):
|
||
|
pytest.skip("Skipping Windows-only tests", allow_module_level=True)
|
||
|
|
||
6 years ago
|
import util.apireg as ar
|
||
|
|
||
6 years ago
|
|
||
|
class TestMailslot:
|
||
|
def test_mailslot_basic(self):
|
||
|
""" Do the basic testing provided by the module """
|
||
|
# Start async both processes
|
||
|
server_p = subprocess.Popen([sys.executable, "util/mailslot.py", "server"], stdout=subprocess.PIPE)
|
||
6 years ago
|
# Need to pause to give server time to listen
|
||
|
time.sleep(0.5)
|
||
6 years ago
|
client_p = subprocess.Popen([sys.executable, "util/mailslot.py", "client"], stdout=subprocess.PIPE)
|
||
|
|
||
|
# Server outputs basic response
|
||
|
assert server_p.stdout.readlines() == [
|
||
|
b"restart\r\n",
|
||
|
b"restart\r\n",
|
||
|
b"restart\r\n",
|
||
|
b"restart\r\n",
|
||
|
b"restart\r\n",
|
||
|
b"stop\r\n",
|
||
|
]
|
||
|
|
||
|
# Client outputs nothing
|
||
|
assert not client_p.stdout.readlines()
|
||
6 years ago
|
|
||
|
|
||
|
class TestAPIReg:
|
||
|
def test_set_get_connection_info_user(self):
|
||
|
""" Test the saving of the URL in USER-registery
|
||
|
We can't test the SYSTEM one.
|
||
|
"""
|
||
|
|
||
|
test_url = "sab_test:8080"
|
||
|
ar.set_connection_info(test_url, True)
|
||
|
assert ar.get_connection_info(True) == test_url
|
||
|
assert not ar.get_connection_info(False)
|
||
|
|
||
|
# Remove and check if gone
|
||
|
ar.del_connection_info(True)
|
||
|
assert not ar.get_connection_info(True)
|
||
|
|
||
|
def test_get_install_lng(self):
|
||
|
""" Not much to test yet.. """
|
||
|
assert ar.get_install_lng() == "en"
|