def test_process_exists(self): """ Test the function process_exists """ self.assertTrue( tools.process_exists("init") or tools.process_exists("systemd")) self.assertFalse(tools.process_exists("notExistedProcess"))
def test_power_status_available(self): if tools.process_exists('upowerd') and not generic.ON_TRAVIS: self.assertTrue(tools.power_status_available()) else: self.assertFalse(tools.power_status_available()) self.assertIsInstance(tools.on_battery(), bool)
import logger import config import snapshots import tools TMP_FLOCK = NamedTemporaryFile() PRIV_KEY_FILE = os.path.expanduser(os.path.join("~",".ssh","id_rsa")) if os.path.exists(PRIV_KEY_FILE): with open(PRIV_KEY_FILE + '.pub', 'rb') as pub: with open(os.path.expanduser(os.path.join("~",".ssh","authorized_keys")), 'rb') as auth: KEY_IN_AUTH = pub.read() in auth.readlines() else: KEY_IN_AUTH = False LOCAL_SSH = all((tools.process_exists('sshd'), os.path.isfile(PRIV_KEY_FILE), KEY_IN_AUTH)) ON_TRAVIS = os.environ.get('TRAVIS', 'None').lower() == 'true' ON_RTD = os.environ.get('READTHEDOCS', 'None').lower() == 'true' class TestCase(unittest.TestCase): def __init__(self, *args, **kwargs): os.environ['LANGUAGE'] = 'en_US.UTF-8' self.cfgFile = os.path.abspath(os.path.join(__file__, os.pardir, 'config')) self.sharePath = '/tmp/bit' logger.APP_NAME = 'BIT_unittest' logger.openlog() super(TestCase, self).__init__(*args, **kwargs)
def test_process_exists(self): self.assertFalse(tools.process_exists('nonExistingProcess')) pid = self.createProcess() self.assertTrue(tools.process_exists('dummy_proc.sh'))
def test_process_exists(self): """ Test the function process_exists """ self.assertTrue(tools.process_exists("init") or tools.process_exists("systemd")) self.assertFalse(tools.process_exists("notExistedProcess"))