Exemplo n.º 1
0
    def test_app_startup3(self, tmpdir, windows):
        """Test app start-up when a preference file already exists.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        # Create a trash app_directory.ini file. The global fixture ensure
        # that it cannot be a user file. Don't use app_dir fixture as I need to
        # test directory creation.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        app_dir = str(tmpdir.join('ecpy'))
        conf = ConfigObj()
        conf.filename = app_pref
        conf['app_path'] = app_dir
        conf.write()

        assert not os.path.isdir(app_dir)

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        app.run_app_startup(object())

        assert os.path.isdir(app_dir)
Exemplo n.º 2
0
    def test_app_startup4(self, tmpdir, windows):
        """Test app start-up when user request to reset app folder.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        app_dir = str(tmpdir.join('ecpy'))

        # Add a app_directory.ini file.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        if not os.path.isfile(app_pref):
            conf = ConfigObj()
            conf.filename = app_pref
            conf['app_path'] = app_dir
            conf.write()

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        class DummyArgs(object):

            reset_app_folder = True

        with handle_dialog(custom=lambda x: setattr(x, 'path', app_dir)):
            app.run_app_startup(DummyArgs)

        assert os.path.isfile(app_pref)
        assert ConfigObj(app_pref)['app_path'] == app_dir
        assert os.path.isdir(app_dir)
Exemplo n.º 3
0
    def test_app_startup3(self, tmpdir, windows):
        """Test app start-up when a preference file already exists.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        # Create a trash app_directory.ini file. The global fixture ensure
        # that it cannot be a user file. Don't use app_dir fixture as I need to
        # test directory creation.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        app_dir = str(tmpdir.join('ecpy'))
        conf = ConfigObj()
        conf.filename = app_pref
        conf['app_path'] = app_dir
        conf.write()

        assert not os.path.isdir(app_dir)

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        app.run_app_startup(object())

        assert os.path.isdir(app_dir)
Exemplo n.º 4
0
    def test_app_startup4(self, tmpdir, windows):
        """Test app start-up when user request to reset app folder.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        app_dir = str(tmpdir.join('ecpy'))

        # Add a app_directory.ini file.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        if not os.path.isfile(app_pref):
            conf = ConfigObj()
            conf.filename = app_pref
            conf['app_path'] = app_dir
            conf.write()

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        class DummyArgs(object):

            reset_app_folder = True

        with handle_dialog(custom=lambda x: setattr(x, 'path', app_dir)):
            app.run_app_startup(DummyArgs)

        assert os.path.isfile(app_pref)
        assert ConfigObj(app_pref)['app_path'] == app_dir
        assert os.path.isdir(app_dir)
Exemplo n.º 5
0
    def test_app_startup2(self, tmpdir, windows):
        """Test app start-up when user quit app.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        # Remove any trash app_directory.ini file. The global fixture ensure
        # that it cannot be a user file.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        if os.path.isfile(app_pref):
            os.remove(app_pref)

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        with pytest.raises(SystemExit):
            with handle_dialog('reject'):
                app.run_app_startup(object())
Exemplo n.º 6
0
    def test_app_startup2(self, tmpdir, windows):
        """Test app start-up when user quit app.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        # Remove any trash app_directory.ini file. The global fixture ensure
        # that it cannot be a user file.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        if os.path.isfile(app_pref):
            os.remove(app_pref)

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        with pytest.raises(SystemExit):
            with handle_dialog('reject'):
                app.run_app_startup(object())
Exemplo n.º 7
0
    def test_app_startup1(self, tmpdir, windows):
        """Test app start-up when no app_directory.ini exists.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        # Remove any trash app_directory.ini file. The global fixture ensure
        # that it cannot be a user file.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        if os.path.isfile(app_pref):
            os.remove(app_pref)

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        app_dir = str(tmpdir.join('ecpy'))

        with handle_dialog(custom=lambda x: setattr(x, 'path', app_dir)):
            app.run_app_startup(object())

        assert os.path.isfile(app_pref)
        assert ConfigObj(app_pref)['app_path'] == app_dir
        assert os.path.isdir(app_dir)
Exemplo n.º 8
0
    def test_app_startup1(self, tmpdir, windows):
        """Test app start-up when no app_directory.ini exists.

        """
        manifest = PreferencesManifest()
        self.workbench.register(manifest)

        # Remove any trash app_directory.ini file. The global fixture ensure
        # that it cannot be a user file.
        app_pref = os.path.join(ecpy_path(), APP_PREFERENCES, APP_DIR_CONFIG)
        if os.path.isfile(app_pref):
            os.remove(app_pref)

        # Start the app and fake a user answer.
        app = self.workbench.get_plugin('ecpy.app')

        app_dir = str(tmpdir.join('ecpy'))

        with handle_dialog(custom=lambda x: setattr(x, 'path', app_dir)):
            app.run_app_startup(object())

        assert os.path.isfile(app_pref)
        assert ConfigObj(app_pref)['app_path'] == app_dir
        assert os.path.isdir(app_dir)