Example #1
0
# mock notifyplugin to suppress notifications
tools.registerBackintimePath('qt', 'plugins')

TMP_FLOCK = NamedTemporaryFile()
PRIV_KEY_FILE = os.path.expanduser(os.path.join("~",".ssh","id_rsa"))
AUTHORIZED_KEYS_FILE = os.path.expanduser(os.path.join("~",".ssh","authorized_keys"))
DUMMY = 'dummy_test_process.sh'

if os.path.exists(PRIV_KEY_FILE + '.pub') and os.path.exists(AUTHORIZED_KEYS_FILE):
    with open(PRIV_KEY_FILE + '.pub', 'rb') as pub:
        with open(AUTHORIZED_KEYS_FILE, 'rb') as auth:
            KEY_IN_AUTH = pub.read() in auth.readlines()
else:
    KEY_IN_AUTH = False

LOCAL_SSH = all((tools.processExists('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, methodName):
        os.environ['LANGUAGE'] = 'en_US.UTF-8'
        self.cfgFile = os.path.abspath(os.path.join(__file__, os.pardir, 'config'))
        logger.APP_NAME = 'BIT_unittest'
        logger.openlog()
        super(TestCase, self).__init__(methodName)

    def setUp(self):
Example #2
0
 def test_processExists(self):
     self.assertFalse(tools.processExists('nonExistingProcess'))
     pid = self.createProcess()
     self.assertTrue(tools.processExists(generic.DUMMY))
Example #3
0
                  '.pub') and os.path.exists(AUTHORIZED_KEYS_FILE):
    with open(PRIV_KEY_FILE + '.pub', 'rb') as pub:
        with open(AUTHORIZED_KEYS_FILE, 'rb') as auth:
            KEY_IN_AUTH = pub.read() in auth.readlines()
else:
    KEY_IN_AUTH = False

# check if port 22 on localhost is available
# sshd should be there...
try:
    with socket.create_connection(('localhost', '22'), 2.0) as s:
        sshdPortAvailable = not bool(s.connect_ex(s.getpeername()))
except:
    sshdPortAvailable = False

LOCAL_SSH = all((tools.processExists('sshd'), os.path.isfile(PRIV_KEY_FILE),
                 KEY_IN_AUTH, sshdPortAvailable))

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, methodName):
        os.environ['LANGUAGE'] = 'en_US.UTF-8'
        self.cfgFile = os.path.abspath(
            os.path.join(__file__, os.pardir, 'config'))
        logger.APP_NAME = 'BIT_unittest'
        logger.openlog()
        super(TestCase, self).__init__(methodName)
Example #4
0
TMP_FLOCK = NamedTemporaryFile()
PRIV_KEY_FILE = os.path.expanduser(os.path.join("~", ".ssh", "id_rsa"))
AUTHORIZED_KEYS_FILE = os.path.expanduser(
    os.path.join("~", ".ssh", "authorized_keys"))
DUMMY = 'dummy_test_process.sh'

if os.path.exists(PRIV_KEY_FILE +
                  '.pub') and os.path.exists(AUTHORIZED_KEYS_FILE):
    with open(PRIV_KEY_FILE + '.pub', 'rb') as pub:
        with open(AUTHORIZED_KEYS_FILE, 'rb') as auth:
            KEY_IN_AUTH = pub.read() in auth.readlines()
else:
    KEY_IN_AUTH = False

LOCAL_SSH = all(
    (tools.processExists('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, methodName):
        os.environ['LANGUAGE'] = 'en_US.UTF-8'
        self.cfgFile = os.path.abspath(
            os.path.join(__file__, os.pardir, 'config'))
        logger.APP_NAME = 'BIT_unittest'
        logger.openlog()
        super(TestCase, self).__init__(methodName)

    def setUp(self):
Example #5
0
 def test_powerStatusAvailable(self):
     if tools.processExists('upowerd') and not generic.ON_TRAVIS:
         self.assertTrue(tools.powerStatusAvailable())
     else:
         self.assertFalse(tools.powerStatusAvailable())
     self.assertIsInstance(tools.onBattery(), bool)
Example #6
0
 def test_processExists(self):
     self.assertFalse(tools.processExists('nonExistingProcess'))
     pid = self.createProcess()
     self.assertTrue(tools.processExists(generic.DUMMY))