# 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()