def _full_update(self, name): # Updates the binary by downloading full update # # Args: # name (str): Name of file to update # # version (str): Current version number of file to update # # Returns: # (bool) Meanings:: # # True - Update Successful # # False - Update Failed log.debug(u'Starting full update') latest = self._get_highest_version(name) filename = self._get_filename(name, latest) hash_key = u'{}*{}*{}*{}*{}'.format(self.updates_key, name, latest, self.platform, u'file_hash') _hash = self.star_access_update_data.get(hash_key) with ChDir(self.update_folder): log.debug(u'Downloading update...') fd = FileDownloader(filename, self.update_urls, _hash, self.verify) result = fd.download_verify_write() if result: log.debug(u'Update Complete') return True else: log.error(u'Failed To Updated To Latest Version') return False
def test_good_conent_length(): with ChDir(u'tests'): fd = FileDownloader(FILENAME, URL, FILE_HASH) fd.download_verify_write() assert fd.content_length == 60000
def test_download_write_bad_hash(): with ChDir(u'tests'): fd = FileDownloader(FILENAME, URL, u'38839didkdkflrlrkdfa') success = fd.download_verify_write() assert success is False
def test_download_write(): with ChDir(u'tests'): fd = FileDownloader(FILENAME, URL, FILE_HASH) success = fd.download_verify_write() assert success is True