From 1a494cbf14bc044dd2adf27e5021ee01e175cf0e Mon Sep 17 00:00:00 2001 From: Safihre Date: Wed, 26 Feb 2020 11:27:38 +0100 Subject: [PATCH] Move sleepless-test to the right directory --- tests/test_macos_utils.py | 60 -------------------------------------- tests/test_utils/test_sleepless.py | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 60 deletions(-) delete mode 100644 tests/test_macos_utils.py create mode 100644 tests/test_utils/test_sleepless.py diff --git a/tests/test_macos_utils.py b/tests/test_macos_utils.py deleted file mode 100644 index c1f628a..0000000 --- a/tests/test_macos_utils.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python3 -OO -# Copyright 2007-2019 The SABnzbd-Team -# -# 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_osx_utils - Testing OSX specific utils -""" - -import sys -import pytest -import time -import subprocess - -if not sys.platform.startswith("darwin"): - pytest.skip("Skipping macOS-only tests", allow_module_level=True) - -import sabnzbd.utils.sleepless as sleepless - - -class TestSleepless: - sleep_msg = "SABnzbd is running, don't you stop us now!" - - def check_msg_in_assertions(self): - return self.sleep_msg in subprocess.check_output(["pmset", "-g", "assertions"], universal_newlines=True) - - def test_sleepless(self): - # Run twice to see if it keeps going well - for _ in range(2): - # Keep it awake - sleepless.keep_awake(self.sleep_msg) - time.sleep(2) - - # Check if it's still in the assertions list - assert self.check_msg_in_assertions() - - # Remove and see if it's still there - sleepless.allow_sleep() - assert not self.check_msg_in_assertions() - assert sleepless.assertion_id is None - - def test_sleepless_not_there(self): - assert not self.check_msg_in_assertions() - assert sleepless.assertion_id is None - - sleepless.allow_sleep() - assert not self.check_msg_in_assertions() - assert sleepless.assertion_id is None diff --git a/tests/test_utils/test_sleepless.py b/tests/test_utils/test_sleepless.py new file mode 100644 index 0000000..4a5a131 --- /dev/null +++ b/tests/test_utils/test_sleepless.py @@ -0,0 +1,60 @@ +#!/usr/bin/python3 -OO +# Copyright 2007-2019 The SABnzbd-Team +# +# 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_sleepless - Test sleepless for macOS +""" + +import sys +import pytest +import time +import subprocess + +if not sys.platform.startswith("darwin"): + pytest.skip("Skipping macOS-only tests", allow_module_level=True) + +import sabnzbd.utils.sleepless as sleepless + + +class TestSleepless: + sleep_msg = "SABnzbd is running, don't you stop us now!" + + def check_msg_in_assertions(self): + return self.sleep_msg in subprocess.check_output(["pmset", "-g", "assertions"], universal_newlines=True) + + def test_sleepless(self): + # Run twice to see if it keeps going well + for _ in range(2): + # Keep it awake + sleepless.keep_awake(self.sleep_msg) + time.sleep(2) + + # Check if it's still in the assertions list + assert self.check_msg_in_assertions() + + # Remove and see if it's still there + sleepless.allow_sleep() + assert not self.check_msg_in_assertions() + assert sleepless.assertion_id is None + + def test_sleepless_not_there(self): + assert not self.check_msg_in_assertions() + assert sleepless.assertion_id is None + + sleepless.allow_sleep() + assert not self.check_msg_in_assertions() + assert sleepless.assertion_id is None