Ejemplo n.º 1
0
 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"))
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 def test_process_exists(self):
     self.assertFalse(tools.process_exists('nonExistingProcess'))
     pid = self.createProcess()
     self.assertTrue(tools.process_exists('dummy_proc.sh'))
Ejemplo n.º 5
0
 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"))