def setup_method(self): os.environ['BOOKLIB_DB_PATH'] = ':memory:' session = database.Session() database.init(session) self.connection = session.engine.connect() self.tx = self.connection.begin() self.session = session.value
def test_account_focus_on_first_name(qtbot): os.environ['BOOKLIB_DB_PATH'] = ':memory:' database.init(database.Session()) window = admin.AdminWindow(config.MenuConfig()) qtbot.addWidget(window) qtbot.mouseClick(window.account_btn, QtCore.Qt.LeftButton) dialog = window.account_window assert dialog.isVisible() if not os.getenv('TRAVIS'): assert dialog.account.first_name_qt.hasFocus()
def test_account_no_first_name(qtbot): os.environ['BOOKLIB_DB_PATH'] = ':memory:' database.init(database.Session()) window = admin.AdminWindow(config.MenuConfig()) qtbot.addWidget(window) qtbot.mouseClick(window.account_btn, QtCore.Qt.LeftButton) dialog = window.account_window insert_test_data(dialog.account) dialog.account.first_name_qt.setText('') qtbot.mouseClick(dialog.button_box.buttons()[0], QtCore.Qt.LeftButton) assert dialog.error_dialog.isVisible()
def main(argv: typing.Iterable[typing.Text] = None) -> None: if not argv: argv = sys.argv[1:] # Create database if it doesn't exist yet if not os.path.exists(config.get_db_path()): session = database.Session() database.init(session) # Get config cfg = config.MenuConfig() # Start the main window app = ui.main.create_app(argv) _ = booklib.ui.window.admin.AdminWindow(cfg) app.exec_()
def test_account_clear_button(qtbot): os.environ['BOOKLIB_DB_PATH'] = ':memory:' database.init(database.Session()) window = admin.AdminWindow(config.MenuConfig()) qtbot.addWidget(window) qtbot.mouseClick(window.account_btn, QtCore.Qt.LeftButton) dialog = window.account_window # Move focus to another line dialog.account.family_name_qt.setFocus() dialog.account.family_name_qt.setText('random') if not os.getenv('TRAVIS'): qtbot.waitUntil(lambda: dialog.account.family_name_qt.hasFocus()) qtbot.mouseClick(dialog.button_box.buttons()[2], QtCore.Qt.LeftButton) assert dialog.isVisible() assert not str(dialog.account.family_name_qt.text()) if not os.getenv('TRAVIS'): assert dialog.account.first_name_qt.hasFocus()