Ejemplo n.º 1
0
 def test_missing_version(self, shared_datadir, json_data):
     data = update_data.copy()
     data['update_folder'] = str(shared_datadir)
     data['json_data'] = json_data
     data['latest_version'] = '0.0.4.2.0'
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 2
0
 def test_execution(self, shared_datadir, json_data):
     data = update_data.copy()
     data["update_folder"] = str(shared_datadir)
     data["json_data"] = json_data
     data["channel"] = "stable"
     p = Patcher(**data)
     assert p.start() is True
Ejemplo n.º 3
0
 def test_bad_hash_current_version(self, shared_datadir, json_data):
     data = update_data.copy()
     data['update_folder'] = str(shared_datadir)
     data['json_data'] = json_data
     data['current_file_hash'] = 'Thisisabadhash'
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 4
0
    def _patch_update(self, name, version):  # pragma: no cover
        log.info('Starting patch update')
        filename = get_filename(name, version, self.platform, self.easy_data)
        log.debug('Archive filename: %s', filename)
        if filename is None:
            log.warning('Make sure version numbers are correct. '
                        'Possible TRAP!')
            return False
        latest = get_highest_version(name, self.platform, self.channel,
                                     self.easy_data)
        # Just checking to see if the zip for the current version is
        # available to patch If not we'll just do a full binary download
        if not os.path.exists(os.path.join(self.update_folder, filename)):
            log.warning(
                '%s got deleted. No base binary to start patching '
                'form', filename)
            return False

        # Initilize Patch object with all required information
        p = Patcher(name=name,
                    json_data=self.json_data,
                    current_version=version,
                    latest_version=latest,
                    update_folder=self.update_folder,
                    update_urls=self.update_urls,
                    verify=self.verify,
                    progress_hooks=self.progress_hooks)

        # Returns True if everything went well
        # If False is returned then we will just do the full
        # update.
        return p.start()
Ejemplo n.º 5
0
 def test_no_base_binary(self, json_data):
     assert os.listdir(os.getcwd()) == []
     data = update_data.copy()
     data["update_folder"] = os.getcwd()
     data["json_data"] = json_data
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 6
0
 def test_bad_hash_current_version(self, shared_datadir, json_data):
     data = update_data.copy()
     data["update_folder"] = str(shared_datadir)
     data["json_data"] = json_data
     data["current_file_hash"] = "Thisisabadhash"
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 7
0
 def test_missing_version(self, shared_datadir, json_data):
     data = update_data.copy()
     data["update_folder"] = str(shared_datadir)
     data["json_data"] = json_data
     data["latest_version"] = "0.0.4.2.0"
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 8
0
    def _patch_update(self):  # pragma: no cover
        log.debug('Starting patch update')
        # The current version is not in the version manifest
        if self.current_archive_filename is None:
            return False

        # Just checking to see if the zip for the current version is
        # available to patch If not we'll fall back to a full binary download
        if not os.path.exists(os.path.join(self.update_folder,
                                           self.current_archive_filename)):
            log.debug('%s got deleted. No base binary to start patching '
                      'form', self.current_archive_filename)
            return False

        # Initilize Patch object with all required information
        p = Patcher(name=self.name, json_data=self.json_data,
                    current_version=self.current_version,
                    latest_version=self.latest,
                    update_folder=self.update_folder,
                    update_urls=self.update_urls, verify=self.verify,
                    progress_hooks=self.progress_hooks)

        # Returns True if everything went well
        # If False, fall back to a full update
        return p.start()
Ejemplo n.º 9
0
    def _patch_update(self, name, version):  # pragma: no cover
        log.debug('Starting patch update')
        filename = get_filename(name, version, self.platform, self.easy_data)
        log.debug('Archive filename: %s', filename)
        if filename is None:
            log.debug('Make sure version numbers are correct. '
                        'Possible TRAP!')
            return False
        latest = get_highest_version(name, self.platform,
                                     self.channel, self.easy_data)
        # Just checking to see if the zip for the current version is
        # available to patch If not we'll just do a full binary download
        if not os.path.exists(os.path.join(self.update_folder, filename)):
            log.debug('%s got deleted. No base binary to start patching '
                        'form', filename)
            return False

        # Initilize Patch object with all required information
        p = Patcher(name=name, json_data=self.json_data,
                    current_version=version, latest_version=latest,
                    update_folder=self.update_folder,
                    update_urls=self.update_urls, verify=self.verify,
                    progress_hooks=self.progress_hooks)

        # Returns True if everything went well
        # If False is returned then we will just do the full
        # update.
        return p.start()
Ejemplo n.º 10
0
    def _patch_update(self):  # pragma: no cover
        log.debug("Starting patch update")
        # The current version is not in the version manifest
        if self._current_archive_name is None:
            return False

        # Just checking to see if the zip for the current version is
        # available to patch If not we'll fall back to a full binary download
        if not os.path.exists(
            os.path.join(self.update_folder, self._current_archive_name)
        ):
            log.debug(
                "%s got deleted. No base binary to start patching " "form",
                self._current_archive_name,
            )
            return False

        # Initialize Patch object with all required information
        p = Patcher(
            current_version=self.current_version,
            latest_version=self.latest,
            update_folder=self.update_folder,
            **self.init_data
        )

        # Returns True if everything went well
        # If False, fall back to a full update
        try:
            rv = p.start()
        except Exception as err:
            log.debug(err, exc_info=True)
            rv = False

        return rv
Ejemplo n.º 11
0
    def test_execution(self, datadir, json_data):
        # pytest-datadir copies the file on access
        datadir[self.base_binary]

        data = update_data.copy()
        data['update_folder'] = datadir.tmpdir
        data['json_data'] = json_data
        p = Patcher(**data)
        assert p.start() is True
Ejemplo n.º 12
0
    def test_missing_version(self, datadir, json_data):
        # pytest-datadir copies the file on access
        datadir[self.base_binary]

        data = update_data.copy()
        data['update_folder'] = datadir.tmpdir
        data['json_data'] = json_data
        data['latest_version'] = '0.0.4.2.0'
        p = Patcher(**data)
        assert p.start() is False
Ejemplo n.º 13
0
    def test_bad_hash_current_version(self, datadir, json_data):
        # pytest-datadir copies the file on access
        datadir[self.base_binary]

        data = update_data.copy()
        data['update_folder'] = datadir.tmpdir
        data['json_data'] = json_data
        data['current_file_hash'] = 'Thisisabadhash'
        p = Patcher(**data)
        assert p.start() is False
Ejemplo n.º 14
0
    def test_execution_callback(self, setup):

        def cb(status):
            assert 'downloaded' in status.keys()
            assert 'total' in status.keys()
            assert 'status' in status.keys()
            assert 'percent_complete' in status.keys()

        data = update_data.copy()
        data['update_folder'] = setup
        data['progress_hooks'] = [cb]
        p = Patcher(**data)
        assert p.start() is True
Ejemplo n.º 15
0
    def test_execution_callback(self, shared_datadir, json_data):

        def cb(status):
            assert 'downloaded' in status.keys()
            assert 'total' in status.keys()
            assert 'status' in status.keys()
            assert 'percent_complete' in status.keys()

        data = update_data.copy()
        data['update_folder'] = str(shared_datadir)
        data['json_data'] = json_data
        data['progress_hooks'] = [cb]
        p = Patcher(**data)
        assert p.start() is True
Ejemplo n.º 16
0
    def test_execution_callback(self, shared_datadir, json_data):
        def cb(status):
            assert "downloaded" in status.keys()
            assert "total" in status.keys()
            assert "status" in status.keys()
            assert "percent_complete" in status.keys()

        data = update_data.copy()
        data["update_folder"] = str(shared_datadir)
        data["json_data"] = json_data
        data["channel"] = "stable"
        data["progress_hooks"] = [cb]
        p = Patcher(**data)
        assert p.start() is True
Ejemplo n.º 17
0
    def test_execution_callback(self, datadir, json_data):
        def cb(status):
            assert 'downloaded' in status.keys()
            assert 'total' in status.keys()
            assert 'status' in status.keys()
            assert 'percent_complete' in status.keys()

        # pytest-datadir copies the file on access
        datadir[self.base_binary]

        data = update_data.copy()
        data['update_folder'] = datadir.tmpdir
        data['json_data'] = json_data
        data['progress_hooks'] = [cb]
        p = Patcher(**data)
        assert p.start() is True
Ejemplo n.º 18
0
 def test_execution(self, shared_datadir, json_data):
     data = update_data.copy()
     data['update_folder'] = str(shared_datadir)
     data['json_data'] = json_data
     p = Patcher(**data)
     assert p.start() is True
Ejemplo n.º 19
0
 def test_missing_version(self, setup):
     data = update_data.copy()
     data['update_folder'] = setup
     data['highest_version'] = '0.0.4'
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 20
0
 def test_bad_hash_current_version(self, setup):
     data = update_data.copy()
     data['update_folder'] = setup
     data['current_file_hash'] = 'Thisisabadhash'
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 21
0
 def test_execution(self, setup):
     data = update_data.copy()
     data['update_folder'] = setup
     p = Patcher(**data)
     assert p.start() is True
Ejemplo n.º 22
0
 def test_no_base_binary(self):
     assert os.listdir(os.getcwd()) == []
     data = update_data.copy()
     data['update_folder'] = os.getcwd()
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 23
0
 def test_bad_hash_current_version(self, setup):
     data = update_data.copy()
     data['update_folder'] = setup
     data['current_file_hash'] = 'Thisisabadhash'
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 24
0
 def test_missing_version(self, setup):
     data = update_data.copy()
     data['update_folder'] = setup
     data['latest_version'] = '0.0.4.2.0'
     p = Patcher(**data)
     assert p.start() is False
Ejemplo n.º 25
0
 def test_no_base_binary(self):
     assert os.listdir(os.getcwd()) == []
     data = update_data.copy()
     data['update_folder'] = os.getcwd()
     p = Patcher(**data)
     assert p.start() is False