def _patch_update(self, name, version): # Updates the binary by patching # # Args: # name (str): Name of file to update # # version (str): Current version number of file to update # # Returns: # (bool) Meanings:: # # True - Either already up to date or patched successful # # False - Either failed to patch or no base binary to patch log.debug(u'Starting patch update') filename = self._get_filename(name, version) latest = self._get_highest_version(name) # 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(u'{} got deleted. No base binary to start patching ' 'form'.format(filename)) return False p = Patcher(name=name, json_data=self.json_data, current_version=version, highest_version=latest, update_folder=self.update_folder, update_urls=self.update_urls, verify=self.verify) # Returns True if everything went well # If False is returned then we will just do the full # update. return p.start()
def test_missing_version(): bad_data = update_data.copy() bad_data[u'highest_version'] = u'0.0.4' p = Patcher(**bad_data) assert p.start() is False
def test_no_base_to_patch(): os.mkdir(UPDATE_DIR) p = Patcher(**update_data) assert p.start() is False
def test_bad_hash_current_version(): bad_data = update_data.copy() bad_data['current_file_hash'] = u'Thisisabadhash' p = Patcher(**bad_data) assert p.start() is False
def test_execution(): p = Patcher(**update_data) assert p.start() is True