From: Michael Tremer Date: Wed, 12 Oct 2022 17:51:00 +0000 (+0000) Subject: tests: Create build from source package X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3f32d18b285f7ddd55282c7f8f09ff9bf063c7f;p=pbs.git tests: Create build from source package Signed-off-by: Michael Tremer --- diff --git a/tests/build.py b/tests/build.py index 96610894..4c1c0b58 100755 --- a/tests/build.py +++ b/tests/build.py @@ -4,10 +4,28 @@ import unittest import test +from buildservice import builds + class BuildTestCase(test.TestCase): """ Tests everything around builds """ + async def test_create_from_source(self): + """ + Tests whether we can create a build from a source package + """ + path = self.source_path("tests/data/beep-1.3-2.ip3.src.pfm") + + # Create the build + with self.db.transaction(): + build = await self._create_build(path) + + # Check if any jobs have been created + self.assertTrue(build.jobs) + + # Check if a job for each architecture has been generated + self.assertEqual([j.arch for j in build.jobs], self.distro.arches) + async def test_create_from_binary(self): """ Tests whether we can create a build from a binary package diff --git a/tests/test.py b/tests/test.py index b7109760..cd832777 100644 --- a/tests/test.py +++ b/tests/test.py @@ -10,6 +10,7 @@ import unittest from pakfire._pakfire import Archive from buildservice import Backend +from buildservice import builds from buildservice import database from buildservice import misc from buildservice import packages @@ -145,3 +146,22 @@ class TestCase(unittest.IsolatedAsyncioTestCase): self.assertIsInstance(package, packages.Package) return package + + async def _create_build(self, path, repo=None, owner=None): + """ + Helper function to import a build from path + """ + # Use the default repository if none set + if repo is None: + repo = self.repo + + # Import the package first + package = await self._create_package(path) + + # Create the build + build = self.backend.builds.create(repo, package, owner=owner) + + # Check if we received the correct type + self.assertIsInstance(build, builds.Build) + + return build