def test_connstring(self) -> None: """Test to provide a connstring.""" # format: "user:passwd:driver_alias@host:port/database" options = parse_options(["pineboo", "--connect", "user:[email protected]:5433/mydb"]) cfg1 = config_dbconn(options) cfg2 = ProjectConfig( database="mydb", username="******", password="******", host="127.0.0.1", port=5433, type="PostgreSQL (PSYCOPG2)", ) self.assertEqual(cfg1, cfg2) options = parse_options(["pineboo", "--connect", "mydb"]) cfg1 = config_dbconn(options) cfg2 = ProjectConfig( database="mydb", username="******", password="", host="127.0.0.1", port=5432, type="PostgreSQL (PSYCOPG2)", ) self.assertEqual(cfg1, cfg2)
def test_startup(self, mock_parse_options: Mock, mock_exec_main: Mock, mock_sys_exit: Mock) -> None: """Test bug where logging tries to get incorrect options.""" options = parse_options(custom_argv=[]) mock_parse_options.return_value = options main.startup() mock_parse_options.assert_called_once() mock_exec_main.assert_called_once() mock_sys_exit.assert_called_once()
def test_project_passwd(self, mock_get_pass: Mock) -> None: """Test to provide a project template with password.""" mock_get_pass.return_value = "myhardtoguesspassword" options = parse_options(["pineboo", "--load", fixture_path("project_test2")]) cfg1 = config_dbconn(options) cfg2 = ProjectConfig( database="postgres_testdb", type="PostgreSQL (PSYCOPG2)", host="192.168.1.101", port=5432, username="******", password="******", description="Postgres Test DB", project_password="******", ) self.assertEqual(cfg1, cfg2)
def startup(enable_gui: bool = None) -> None: """Start up pineboo.""" # FIXME: No hemos cargado pineboo aún. No se pueden usar métodos internos. from pineboolib.core.utils.check_dependencies import check_dependencies_cli if not check_dependencies_cli({ "ply": "python3-ply", "PyQt5.QtCore": "python3-pyqt5", "Python": "Python" }): sys.exit(32) min_python = (3, 6) if sys.version_info < min_python: sys.exit("Python %s.%s or later is required.\n" % min_python) options = parse_options() if enable_gui is not None: options.enable_gui = enable_gui trace_loggers: List[str] = [] if options.trace_loggers: trace_loggers = options.trace_loggers.split(",") init_logging(logtime=options.log_time, loglevel=options.loglevel, trace_loggers=trace_loggers) if options.enable_profiler: ret = exec_main_with_profiler(options) else: ret = exec_main(options) # setup() # exec_() gc.collect() print("Closing Pineboo...") if ret: sys.exit(ret) else: sys.exit(0)
def test_project(self) -> None: """Test to provide a project template.""" options = parse_options(["pineboo", "--load", fixture_path("project_test1")]) cfg1 = config_dbconn(options) cfg2 = ProjectConfig(database="mydb", type="SQLite3 (SQLITE3)") self.assertEqual(cfg1, cfg2)