]> git.ipfire.org Git - pbs.git/commitdiff
tests: Add some basic repo tests
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 14:41:12 +0000 (14:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 14:41:12 +0000 (14:41 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
tests/repo.py [new file with mode: 0755]

index ef46339bb4e9d48245e5bc834086e7e63be386e3..1bba8dadaf8262d5f3eb5b053d5f92b4aebe96ef 100644 (file)
@@ -486,7 +486,8 @@ TESTS_ENVIRONMENT = \
 
 dist_check_SCRIPTS = \
        tests/setup.py \
-       tests/distro.py
+       tests/distro.py \
+       tests/repo.py
 
 EXTRA_DIST += \
        tests/test.py
diff --git a/tests/repo.py b/tests/repo.py
new file mode 100755 (executable)
index 0000000..5dfa24b
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/python3
+
+import unittest
+
+import test
+
+from buildservice import keys
+from buildservice import repository
+
+class RepoTestCase(test.TestCase):
+       """
+               Tests everything around the Repo object
+       """
+       async def test_create(self):
+               """
+                       Tests whether we can create a repository
+               """
+               with self.db.transaction():
+                       repo = await self.backend.repos.create(self.distro, "Random Test Repository")
+
+               # Check that we got the correct type back
+               self.assertIsInstance(repo, repository.Repository)
+
+               # Check if the values got set correct
+               self.assertEqual(repo.name, "Random Test Repository")
+               #self.assertEqual(repo.slug, "random-test-repository")
+
+               # Check if a key was generated
+               self.assertIsInstance(repo.key, keys.Key)
+
+
+if __name__ == "__main__":
+       unittest.main()