def test_success(self, mock_initialized): mock_initialized.return_value = False self.mock_runner.run.return_value = ("initialized", "", 0) lib.qdevice_setup(self.mock_runner) mock_initialized.assert_called_once_with() self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])
def test_success(self, mock_is_dir_nonempty): mock_is_dir_nonempty.return_value = False self.mock_runner.run.return_value = ("initialized", 0) lib.qdevice_setup(self.mock_runner) mock_is_dir_nonempty.assert_called_once_with(_qnetd_cert_dir) self.mock_runner.run.assert_called_once_with([_qnetd_tool, "-i"])
def qdevice_setup(lib_env: LibraryEnvironment, model, enable, start): """ Initialize qdevice on local host with specified model string model qdevice model to initialize bool enable make qdevice service start on boot bool start start qdevice now """ _check_model(model) qdevice_net.qdevice_setup(lib_env.cmd_runner()) lib_env.report_processor.report( ReportItem.info(reports.messages.QdeviceInitializationSuccess(model))) if enable: _service_enable(lib_env, qdevice_net.qdevice_enable) if start: _service_start(lib_env, qdevice_net.qdevice_start)
def qdevice_setup(lib_env, model, enable, start): """ Initialize qdevice on local host with specified model string model qdevice model to initialize bool enable make qdevice service start on boot bool start start qdevice now """ _check_model(model) qdevice_net.qdevice_setup(lib_env.cmd_runner()) lib_env.report_processor.process( reports.qdevice_initialization_success(model)) if enable: _service_enable(lib_env, qdevice_net.qdevice_enable) if start: _service_start(lib_env, qdevice_net.qdevice_start)
def qdevice_setup(lib_env, model, enable, start): """ Initialize qdevice on local host with specified model string model qdevice model to initialize bool enable make qdevice service start on boot bool start start qdevice now """ _check_model(model) qdevice_net.qdevice_setup(lib_env.cmd_runner()) lib_env.report_processor.process( reports.qdevice_initialization_success(model) ) if enable: _service_enable(lib_env, qdevice_net.qdevice_enable) if start: _service_start(lib_env, qdevice_net.qdevice_start)
def test_cert_db_exists(self, mock_initialized): mock_initialized.return_value = True assert_raise_library_error( lambda: lib.qdevice_setup(self.mock_runner), (severity.ERROR, report_codes.QDEVICE_ALREADY_INITIALIZED, { "model": "net" })) mock_initialized.assert_called_once_with() self.mock_runner.run.assert_not_called()
def test_init_tool_fail(self, mock_initialized): mock_initialized.return_value = False self.mock_runner.run.return_value = ("stdout", "test error", 1) assert_raise_library_error( lambda: lib.qdevice_setup(self.mock_runner), (severity.ERROR, report_codes.QDEVICE_INITIALIZATION_ERROR, { "model": "net", "reason": "test error\nstdout", })) mock_initialized.assert_called_once_with() self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])
def test_cert_db_exists(self, mock_initialized): mock_initialized.return_value = True assert_raise_library_error( lambda: lib.qdevice_setup(self.mock_runner), ( severity.ERROR, report_codes.QDEVICE_ALREADY_INITIALIZED, {"model": "net"} ) ) mock_initialized.assert_called_once_with() self.mock_runner.run.assert_not_called()
def test_init_tool_fail(self, mock_initialized): mock_initialized.return_value = False self.mock_runner.run.return_value = ("stdout", "test error", 1) assert_raise_library_error( lambda: lib.qdevice_setup(self.mock_runner), ( severity.ERROR, report_codes.QDEVICE_INITIALIZATION_ERROR, { "model": "net", "reason": "test error\nstdout", } ) ) mock_initialized.assert_called_once_with() self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])