""", uuid,
)
- async def create(self, upload):
+ async def create(self, upload, distro=None):
"""
Creates a new package from an uploaded file
"""
+ if not self.backend.test and distro:
+ raise RuntimeError("Cannot alter distro when not in test mode")
+
# Check if the upload has been completed
if not upload.is_completed():
raise RuntimeError("Cannot import package from incomplete upload")
log.debug("Importing package %s..." % package)
# Find a matching distribution
- distro = self.backend.distros.get_by_tag(package.distribution)
if not distro:
- log.error("Could not find distribution '%s'" % package.distribution)
+ distro = self.backend.distros.get_by_tag(package.distribution)
+ if not distro:
+ log.error("Could not find distribution '%s'" % package.distribution)
- raise NoSuchDistroError(package.distribution)
+ raise NoSuchDistroError(package.distribution)
pkg = self._get_package("""
INSERT INTO
upload = await self._create_upload(path)
# Create the package
- package = await self.backend.packages.create(upload)
+ package = await self.backend.packages.create(upload, distro=self.distro)
# Check if we received the correct type
self.assertIsInstance(package, packages.Package)