Esempio n. 1
0
 def test1(self):
     data = EasyAccessDict(self.version_data)
     assert (get_highest_version("Acme", "mac", "alpha", data,
                                 strict=True) == "4.4.2.0.5")
     assert (get_highest_version("Acme", "mac", "beta", data,
                                 strict=True) == "4.4.1.1.0")
     assert (get_highest_version("Acme", "mac", "stable", data,
                                 strict=True) == "4.4.3.2.0")
Esempio n. 2
0
 def test1(self):
     data = EasyAccessDict(self.version_data)
     assert get_highest_version('Acme', 'mac', 'alpha', data,
                                strict=True) == '4.4.2.0.5'
     assert get_highest_version('Acme', 'mac', 'beta', data,
                                strict=True) == '4.4.1.1.0'
     assert get_highest_version('Acme', 'mac', 'stable', data,
                                strict=True) == '4.4.3.2.0'
Esempio n. 3
0
    def __init__(self, **kwargs):
        self.name = kwargs.get("name")
        self.channel = kwargs.get("channel")
        self.json_data = kwargs.get("json_data")
        self.star_access_update_data = EasyAccessDict(self.json_data)
        self.current_version = Version(kwargs.get("current_version"))
        self.latest_version = kwargs.get("latest_version")
        self.update_folder = kwargs.get("update_folder")
        self.update_urls = kwargs.get("update_urls", [])
        self.verify = kwargs.get("verify", True)
        self.max_download_retries = kwargs.get("max_download_retries")
        self.headers = kwargs.get("headers")
        self.downloader = kwargs.get("downloader")
        self.http_timeout = kwargs.get("http_timeout")

        # Progress hooks to be called
        self.progress_hooks = kwargs.get("progress_hooks", [])

        # List of dicts with urls, filename & hash of each patch
        self.patch_data = []

        # List of binary blobs of patch data
        self.patch_binary_data = []

        # binary blob of original archive to patch
        self.og_binary = None

        # Used for testing.
        self.platform = kwargs.get("platform", _PLATFORM)

        self.current_filename = kwargs.get("current_filename")

        self.current_file_hash = kwargs.get("current_file_hash")

        file_info = self._get_info(self.name,
                                   self.current_version,
                                   option="file")
        if self.current_filename is None:
            self.current_filename = file_info["filename"]
        if self.current_file_hash is None:
            self.current_file_hash = file_info["file_hash"]
Esempio n. 4
0
    def __init__(self, **kwargs):
        self.name = kwargs.get('name')
        self.json_data = kwargs.get('json_data')
        self.star_access_update_data = EasyAccessDict(self.json_data)
        self.current_version = Version(kwargs.get('current_version'))
        self.latest_version = kwargs.get('latest_version')
        self.update_folder = kwargs.get('update_folder')
        self.update_urls = kwargs.get('update_urls', [])
        self.verify = kwargs.get('verify', True)
        self.max_download_retries = kwargs.get('max_download_retries')
        self.urllib3_headers = kwargs.get('urllib3_headers')

        # Progress hooks to be called
        self.progress_hooks = kwargs.get('progress_hooks', [])

        # List of dicts with urls, filename & hash of each patch
        self.patch_data = []

        # List of binary blobs of patch data
        self.patch_binary_data = []

        # binary blob of original archive to patch
        self.og_binary = None

        # ToDo: Update tests with linux archives.
        # Used for testing.
        self.platform = kwargs.get('platform', _PLATFORM)

        self.current_filename = kwargs.get('current_filename')

        self.current_file_hash = kwargs.get('current_file_hash')

        file_info = self._get_info(self.name,
                                   self.current_version,
                                   option='file')
        if self.current_filename is None:
            self.current_filename = file_info['filename']
        if self.current_file_hash is None:
            self.current_file_hash = file_info['file_hash']
Esempio n. 5
0
    def _update_version_file(self, json_data, package_manifest):
        # Adding version metadata from scanned packages to our
        # version manifest
        log.info('Adding package meta-data to version manifest')
        easy_dict = EasyAccessDict(json_data)
        for p in package_manifest:
            info = self._manifest_to_version_file_compat(p)

            version_key = '{}*{}*{}'.format(settings.UPDATES_KEY, p.name,
                                            p.version)
            version = easy_dict.get(version_key)
            log.debug('Package Info: %s', version)

            # If we cannot get a version number this must be the first version
            # of its kind.
            if version is None:
                log.debug('Adding new version to file')

                # First version with this package name
                json_data[settings.UPDATES_KEY][p.name][p.version] = {}
                platform_key = '{}*{}*{}*{}'.format(settings.UPDATES_KEY,
                                                    p.name, p.version,
                                                    'platform')

                platform = easy_dict.get(platform_key)
                if platform is None:
                    _name = json_data[settings.UPDATES_KEY][p.name]
                    _name[p.version][p.platform] = info

            else:
                # package already present, adding another version to it
                log.debug('Appending info data to version file')
                _updates = json_data[settings.UPDATES_KEY]
                _updates[p.name][p.version][p.platform] = info

            # Add each package to latests section separated by release channel
            json_data['latest'][p.name][p.channel][p.platform] = p.version
        return json_data
Esempio n. 6
0
 def test1(self):
     data = EasyAccessDict(self.version_data)
     assert get_highest_version('Acme', 'mac', 'stable', data,
                                strict=True) is None
Esempio n. 7
0
 def test1(self):
     data = EasyAccessDict(self.version_data)
     assert get_highest_version('Acme', 'mac', 'alpha', data,
                                strict=False) == '4.4.3.2.0'
Esempio n. 8
0
 def test1(self):
     data = EasyAccessDict(self.version_data)
     assert get_highest_version("Acme", "mac", "stable", data,
                                strict=True) is None
Esempio n. 9
0
 def test1(self):
     data = EasyAccessDict(self.version_data)
     assert (get_highest_version("Acme", "mac", "alpha", data,
                                 strict=False) == "4.4.3.2.0")