コード例 #1
0
ファイル: tests.py プロジェクト: MlsDmitry/ly_math
 def test_add_snapshot(self):
     task = TaskModel(17, 3, ['+', '-'], (10, 49))
     Log.log('d', f'Test format: {task.to_sqlite_format()}')
     name = ''.join([choice(ascii_letters) for _ in range(randint(5, 15))])
     self.hm.add_snaptshot([name, *task.to_sqlite_format()])
     # self.dbm.save()
     Log.log('d', self.hm.get_snapshot_names())
コード例 #2
0
    def save_snapshot(self):
        config = self.validate_task_config()
        if not config:
            return

        name, is_pressed = QInputDialog.getText(self.view, "Save Snapshot",
                                                "Enter name")
        if is_pressed:
            if self.history_provider.get_snapshot(name):
                dialog = ErrorDialog(self.view)
                dialog.exec_()
                return
            task = TaskModel(int(config.expressions_count),
                             int(config.columns), config.operations,
                             (int(config.min_number), int(config.max_number)))
            self.history_provider.add_snaptshot(
                [name, *task.to_sqlite_format()])
            self.view.add_snapshot_entry(name)
            self.dbm.save()
        else:
            return