]> git.ipfire.org Git - pbs.git/commitdiff
tests: Create some basic objects during setup
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 14:46:14 +0000 (14:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 14:48:40 +0000 (14:48 +0000)
This is easier than the on-demand initialization for async objects

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/test.py

index 6436572de8446ab06d1fa96332b9b52337bd50f4..c7359215a887c1987646e25f40da94c54ea26c37 100644 (file)
@@ -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")