]> git.ipfire.org Git - pbs.git/commitdiff
tests: Test build comments
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Oct 2022 13:02:39 +0000 (13:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Oct 2022 13:02:39 +0000 (13:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/build.py

index dbe6368583b9d97c80ebd4c44d325552c821b537..daac2c61d97d97fedc26389974384abeee015898 100755 (executable)
@@ -63,6 +63,37 @@ class BuildTestCase(test.TestCase):
                # Check if the watcher has been removed
                self.assertNotIn(self.user, build.watchers)
 
+       async def test_comments(self):
+               """
+                       Tests creating comments
+               """
+               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)
+
+               # Create a new comment
+               comment = build.comment(self.user, "This is a test comment")
+
+               # Check if the type is correct
+               self.assertIsInstance(comment, builds.Comment)
+
+               # Check if the comment is correctly cached
+               self.assertIn(comment, build.comments)
+
+               # Create another comment with some score
+               build.comment(self.user, "This is a negative comment", score=-1)
+
+               # The score should now be -1
+               self.assertEqual(build.score, -1)
+
+               # Create another comment with a larger, positive score
+               build.comment(self.user, "This is a positive comment", score=2)
+
+               # The score should now be 1
+               self.assertEqual(build.score, 1)
+
 
 if __name__ == "__main__":
        unittest.main()