From: Michael Tremer Date: Wed, 12 Oct 2022 14:46:14 +0000 (+0000) Subject: tests: Create some basic objects during setup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85bc287b2727ed298ca935c57fbf2683ff6401f2;p=pbs.git tests: Create some basic objects during setup This is easier than the on-demand initialization for async objects Signed-off-by: Michael Tremer --- diff --git a/tests/test.py b/tests/test.py index 6436572d..c7359215 100644 --- a/tests/test.py +++ b/tests/test.py @@ -61,7 +61,7 @@ class TestCase(unittest.IsolatedAsyncioTestCase): "password" : password, } - def setUp(self): + async def asyncSetUp(self): # Create a configuration file conf = configparser.ConfigParser() @@ -81,12 +81,16 @@ class TestCase(unittest.IsolatedAsyncioTestCase): # Create handle to the database self.db = self.backend.db - # Some random objects that are created on-demand so that we won't have to - # start from scratch each time... + # Create some default objects + await self._create_default_objects() - @functools.cached_property - def distro(self): + async def _create_default_objects(self): """ - Creates a distribution + Creates some random objects that are created by default so + that we won't have to start from scratch each time... """ - return self.backend.distros.create("Test Distribution 1", "test1") + # Create a distribution + self.distro = self.backend.distros.create("Default Test Distribution", "test1") + + # Create a repository + self.repo = await self.backend.repos.create(self.distro, "Default Test Repository")