示例#1
0
    def test_reload_app_script_windows(self, plat, run):
        from mydevoirs.app import subprocess as sb

        sb.STARTUPINFO = MagicMock()
        app = MyDevoirsApp()
        app.stop = MagicMock()
        app._reload_app()
        assert run.call_args_list == [
            call(
                [sys.executable, "-m", "mydevoirs"],
                cwd=os.getcwd(),
            )
        ]
        assert app.stop.called
示例#2
0
def get_backup_ddb_path(app: MyDevoirsApp, state: int) -> (Path, Optional[Path]):
    path = Path(app.load_config()["ddb"]["path"])
    new_path = None
    if path.is_file() and state < 2:
        # on ne crée pas de nouvelle db  qui sera crée + tard dans load_config de app
        new_path = path.parent / "mydevoirs_sauvegarde_ancienne_version.ddb"
    return path, new_path
示例#3
0
def reapply_version(app: MyDevoirsApp) -> Tuple[int, str]:
    """
    Verifie les differents version précendentes
    :param app: L'instance en cours
    :return:
        0: le fichier n'existe pas
        1: la version a du être ajoutée
        2: la version existe == version en cours
        3: la version existe < version en cours
        4: la version existe > version en cours
    """
    cf_file = app.get_application_config()
    file = Path(cf_file)
    return_value = 0
    file_version = None
    if file.is_file():  # pragma: no branch
        config = ConfigParser()
        try:
            config.read(cf_file)
            file_version = config.get("aide", "version")
        except NoSectionError:
            return_value = 1
        except NoOptionError:
            return_value = 1
    if file_version is not None:
        if file_version < VERSION:
            return_value = 3
        elif file_version > VERSION:
            return_value = 4
        else:
            return_value = 2

    return return_value, file_version
示例#4
0
 def setUpClass(cls):
     cls.app = MyDevoirsApp()
     Path(cls.app.get_application_config()).unlink(missing_ok=True)
     if not cls.app.config:
         cls.app.config = ConfigParser()
         cls.app.build_config(cls.app.config)
     cls.app.build()
     cls.actionbar = cls.app.box.children[1]
示例#5
0
def main():  # pragma: no cover_all
    # covered in check_executable.py
    setup_kivy()
    app = MyDevoirsApp()
    state, file_version = reapply_version(app)
    old_path, backup_path = get_backup_ddb_path(app, state)
    if backup_path:
        app.avertissement = BackupAncienneDB(old_path, backup_path)
    else:
        app.init_database()

    app.run()
示例#6
0
 def test_if_avertissement(self):
     ap = MyDevoirsApp()
     w = Widget()
     ap.avertissement = w
     assert ap.build() == w
示例#7
0
 def test_reload_app_script_linux(self, plat, run):
     app = MyDevoirsApp()
     app.stop = MagicMock()
     app._reload_app()
     assert run.call_args_list == [call(["/here/it/is/appimage"])]
     assert app.stop.called
示例#8
0
    def test_init_database(self):
        app = MyDevoirsApp()
        app.load_config = lambda: {"ddb": {"path": str(Path.home())}}

        with pytest.raises(OperationalError):
            app.init_database()