Ejemplo n.º 1
0
def check_tribler():
    """
    Check whether Tribler is running and configured properly
    :return: True if tribler is running, False otherwise
    :rtype: Boolean
    """
    if tribler_controller.running():
        logger.log("Tribler is already running", log_name)
        return True
    else:
        tribler_controller.start()
        return False
Ejemplo n.º 2
0
    def test_start_False(self):
        self.true_subprocess_call = subprocess.call
        self.true_logger_error = logger.error

        subprocess.call = MagicMock(return_value=False)
        logger.error = MagicMock()
        self.assertFalse(Tribler.start())

        subprocess.call = self.true_subprocess_call
        logger.error = self.true_logger_error
Ejemplo n.º 3
0
    def test_start_exception(self):
        self.true_subprocess_call = subprocess.call
        self.true_logger_error = logger.error

        subprocess.call = MagicMock(side_effect=subprocess.CalledProcessError(
            returncode=2, cmd=['bad']))
        logger.error = MagicMock()
        self.assertFalse(Tribler.start())

        logger.error = self.true_logger_error
        subprocess.call = self.true_subprocess_call
Ejemplo n.º 4
0
    def test_start(self):
        self.true_logger_log = logger.log
        self.true_logger_success = logger.success
        self.true_subprocess_call = subprocess.call

        logger.log = MagicMock()
        logger.success = MagicMock()
        subprocess.call = MagicMock(return_value=True)
        assert (Tribler.start())

        subprocess.call = self.true_subprocess_call
        logger.log = self.true_logger_log
        logger.success = self.true_logger_success
    def test_start_False(self):
        self.true_subprocess_call = subprocess.call
        self.true_logger_error = logger.error
        self.true_setup = Settings.Init.wallets_testnet

        subprocess.call = MagicMock(return_value=1)
        Settings.Init.wallets_testnet = MagicMock(return_value=False)
        logger.error = MagicMock()
        self.assertFalse(Tribler.start())

        subprocess.call = self.true_subprocess_call
        logger.error = self.true_logger_error
        Settings.Init.wallets_testnet = self.true_setup
    def test_start_exception(self):
        self.true_subprocess_call = subprocess.call
        self.true_logger_error = logger.error
        self.true_setup = Settings.Init.wallets_testnet

        subprocess.call = MagicMock(side_effect=subprocess.CalledProcessError(
            returncode=2, cmd=['bad']))
        Settings.Init.wallets_testnet = MagicMock(return_value=True)
        logger.error = MagicMock()
        self.assertFalse(Tribler.start())

        logger.error = self.true_logger_error
        subprocess.call = self.true_subprocess_call
        Settings.Init.wallets_testnet = self.true_setup
    def test_start(self):
        self.true_logger_log = logger.log
        self.true_logger_success = logger.success
        self.true_subprocess_call = subprocess.call
        self.true_setup = Settings.Init.wallets_testnet

        logger.log = MagicMock()
        logger.success = MagicMock()
        Settings.Init.wallets_testnet = MagicMock(return_value=True)
        subprocess.call = MagicMock(return_value=0)
        assert (Tribler.start())

        Settings.Init.wallets_testnet = self.true_setup
        subprocess.call = self.true_subprocess_call
        logger.log = self.true_logger_log
        logger.success = self.true_logger_success