def test_sets_release_version(self): client = (fudge.Fake('client') .expects('release_urls').with_args('belt', '0.5') .returns(belt_pkg_data) .expects('package_releases').with_args('belt', True) .returns(['0.5'])) release, = package_releases('belt', location='/', client=client) assert u'0.5' == release.version
def test_returns_list_of_releases_to_add_to_package(self, db_session): client = (fudge.Fake('client') .expects('release_urls').returns(belt_pkg_data) .expects('package_releases').returns(['0.1'])) pkg = models.Package(name=u'belt') db_session.add(pkg) releases = package_releases('belt', location='/', client=client) pkg.releases.update(list(releases)) pkg = db_session.query(models.Package).filter_by(name='belt').one() assert 1 == len(pkg.releases)
def test_sets_release_file_md5(self): client = (fudge.Fake('client') .expects('release_urls').with_args('belt', '0.3') .returns(belt_pkg_data) .expects('package_releases').with_args('belt', True) .returns(['0.3'])) release, = package_releases('belt', location='/', client=client) # NOTE releases.files is a set object and so order cannot be # determined which mean we have to iterate to ensure the md5 is set to # one of the relations assert 'f7429b4f1ca327102e001f91928b23be' in [f.md5 for f in release.files]
def refresh_packages(session, last_modified_at, location): packages = {} for release in outdated_releases(session, last_modified_at): release.modified = Delorean().datetime package = release.package if package.name in packages: continue packages[package.name] = package versions = [r.version for r in package.releases] package_location = os.path.join(location, package.name) for rel in package_releases(package.name, package_location, versions): if rel.version not in versions: package.releases.add(rel) yield package
def test_release_list_does_not_guarantee_uniqueness(self, db_session): client = (fudge.Fake('client') .expects('release_urls').returns(belt_pkg_data) .expects('package_releases').returns(['0.1'])) # add a package named belt with a 0.1 release pkg = models.Package(name=u'belt') pkg.releases.add(models.Release(version=u'0.1')) db_session.add(pkg) releases = package_releases('belt', location='/', client=client) # add the returned packages and flushing should cause an # IntegrityError because of two releases of the same name pkg.releases.update(list(releases)) with py.test.raises(exc.IntegrityError): db_session.flush()