From: Michael Tremer Date: Thu, 13 Oct 2022 13:02:39 +0000 (+0000) Subject: tests: Test build comments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dce30757f953b80c51c2d8a9bbf97a048528a4f3;p=pbs.git tests: Test build comments Signed-off-by: Michael Tremer --- diff --git a/tests/build.py b/tests/build.py index dbe63685..daac2c61 100755 --- a/tests/build.py +++ b/tests/build.py @@ -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()