def test_package_bad_extension(self, datadir): test_file_2 = 'pyu-win-0.0.2.bzip2' p2 = Package(datadir[test_file_2]) assert p2.filename == test_file_2 assert p2.name is None assert p2.version is None assert p2.info['status'] is False assert p2.info['reason'] == ('Not a supported archive format: ' '{}'.format(test_file_2))
def test_package_1(self, datadir): test_file = 'Acme-mac-4.1.tar.gz' p1 = Package(datadir[test_file]) assert p1.name == 'Acme' assert p1.version == '4.1.0.2.0' assert p1.filename == test_file assert p1.platform == 'mac' assert p1.channel == 'stable' assert p1.info['status'] is True
def test_package_alpha(self, datadir): test_file = 'with spaces-win-0.0.1a2.zip' p1 = Package(datadir[test_file]) assert p1.name == 'with spaces' assert p1.version == '0.0.1.0.2' assert p1.filename == test_file assert p1.platform == 'win' assert p1.channel == 'alpha' assert p1.info['status'] is True
def test_package_name_with_spaces(self, datadir): test_file = 'with spaces-nix-0.0.1b1.zip' p1 = Package(datadir[test_file]) assert p1.name == 'with spaces' assert p1.version == '0.0.1.1.1' assert p1.filename == test_file assert p1.platform == 'nix' assert p1.channel == 'beta' assert p1.info['status'] is True
def test_package_1(self): test_file = 'Acme-mac-4.1.tar.gz' with ChDir(TEST_DATA_DIR): p1 = Package(test_file) assert p1.name == 'Acme' assert p1.version == '4.1.0.2.0' assert p1.filename == test_file assert p1.platform == 'mac' assert p1.channel == 'stable' assert p1.info['status'] is True
def test_package_name_with_spaces(self): test_file = 'with spaces-nix-0.0.1b1.zip' with ChDir(TEST_DATA_DIR): p1 = Package(test_file) assert p1.name == 'with spaces' assert p1.version == '0.0.1.1.1' assert p1.filename == test_file assert p1.platform == 'nix' assert p1.channel == 'beta' assert p1.info['status'] is True
def test_package_bad_extension(self): test_file_2 = 'pyu-win-0.0.2.bzip2' with ChDir(TEST_DATA_DIR): p2 = Package(test_file_2) assert p2.filename == test_file_2 assert p2.name is None assert p2.version is None assert p2.info['status'] is False assert p2.info['reason'] == ('Not a supported archive format: ' '{}'.format(test_file_2))
def test_package_alpha(self): test_file = 'with spaces-win-0.0.1a2.zip' with ChDir(TEST_DATA_DIR): p1 = Package(test_file) assert p1.name == 'with spaces' assert p1.version == '0.0.1.0.2' assert p1.filename == test_file assert p1.platform == 'win' assert p1.channel == 'alpha' assert p1.info['status'] is True
def _get_package_list(self, report_errors): # Adds compatible packages to internal package manifest # for futher processing # Process all packages in new folder and gets # url, hash and some outer info. log.info('Getting package list') # Clears manifest if sign updates runs more the once without # app being restarted package_manifest = [] patch_manifest = [] bad_packages = [] with ChDir(self.new_dir): # Getting a list of all files in the new dir packages = os.listdir(os.getcwd()) for p in packages: # On package initialization we do the following # 1. Check for a supported archive # 2. get required info: version, platform, hash # If any check fails package.info['status'] will be False # You can query package.info['reason'] for the reason package = Package(p) if package.info['status'] is False: # Package failed at something # package.info['reason'] will tell why bad_packages.append(package) continue # Add package hash package.file_hash = gph(package.filename) package.file_size = in_bytes(package.filename) self.json_data = self._update_file_list( self.json_data, package) package_manifest.append(package) self.config = self._add_package_to_config(package, self.config) if self.patch_support: # If channel is not stable skip patch creation if package.channel != 'stable': log.debug( 'Package %s not on stable channel: ' 'Skipping', p) continue # Will check if source file for patch exists # if so will return the path and number of patch # to create. If missing source file None returned path = self._check_make_patch( self.json_data, package.name, package.platform, ) if path is not None: log.info('Found source file to create patch') patch_name = package.name + '-' + package.platform src_path = path[0] patch_number = path[1] patch_info = dict(src=src_path, dst=os.path.abspath(p), patch_name=os.path.join( self.new_dir, patch_name), patch_num=patch_number, package=package.filename) # ready for patching patch_manifest.append(patch_info) else: log.warning('No source file to patch from') # ToDo: Expose this & remove "pragma: no cover" once done if report_errors is True: # pragma: no cover log.warning('Bad package & reason for being naughty:') for b in bad_packages: log.warning(b.name, b.info['reason']) # End ToDo return package_manifest, patch_manifest
def test_package_bad_platform(self, datadir): p = Package(datadir['pyu-wi-1.1.tar.gz']) assert p.info['reason'] == 'Package platform not formatted correctly'
def test_package_bad_version(self, datadir): p = Package(datadir['pyu-win-1.tar.gz']) assert p.info['reason'] == 'Package version not formatted correctly'
def test_package_ignored_file(self): with io.open('.DS_Store', 'w', encoding='utf-8') as f: f.write('') p = Package('.DS_Store') assert p.info['status'] is False
def _get_package_list(self, report_errors): # Adds compatible packages to internal package manifest # for futher processing # Process all packages in new folder and gets # url, hash and some outer info. log.info('Generating package list') # Clears manifest if sign updates runs more the once without # app being restarted package_manifest = [] patch_manifest = [] bad_packages = [] with ChDir(self.new_dir): # Getting a list of all files in the new dir packages = os.listdir(os.getcwd()) for p in packages: # On package initialization we do the following # 1. Check for a supported archive # 2. get required info: version, platform, hash # If any check fails package.info['status'] will be False # You can query package.info['reason'] for the reason package = Package(p) if package.info['status'] is False: # Package failed at something # package.info['reason'] will tell why bad_packages.append(package) continue # Add package hash package.file_hash = gph(package.filename) package.file_size = in_bytes(package.filename) self.version_data = PackageHandler._update_file_list(self.version_data, package) package_manifest.append(package) self.config = PackageHandler._add_package_to_config(package, self.config) if self.patch_support: # If channel is not stable skip patch creation if package.channel != 'stable': log.debug('Package %s not on stable channel: ' 'Skipping', p) continue # Will check if source file for patch exists # if so will return the path and number of patch # to create. If missing source file None returned path = self._check_make_patch(self.version_data, package.name, package.platform, ) if path is not None: log.debug('Found source file to create patch') patch_name = package.name + '-' + package.platform src_path = path[0] patch_number = path[1] patch_info = dict(src=src_path, dst=os.path.abspath(p), patch_name=os.path.join(self.new_dir, patch_name), patch_num=patch_number, package=package.filename) # ready for patching patch_manifest.append(patch_info) else: log.warning('No source file to patch from') if report_errors is True: # pragma: no cover log.warning('Bad package & reason for being naughty:') for b in bad_packages: log.warning(b.name, b.info['reason']) return package_manifest, patch_manifest
def test_package_missing(self): test_file_4 = 'jms-nix-0.0.3.tar.gz' with ChDir(TEST_DATA_DIR): Package(test_file_4)
def test_package_bad_platform(self): with ChDir(TEST_DATA_DIR): p = Package('pyu-wi-1.1.tar.gz') assert p.info['reason'] == 'Package platform not formatted correctly'
def test_package_bad_version(self): with ChDir(TEST_DATA_DIR): p = Package('pyu-win-1.tar.gz') assert p.info['reason'] == 'Package version not formatted correctly'