@@ -1476,6 +1476,83 @@ def test_reaction_add_child(self):
14761476 )
14771477 self .c .reactions .add_child ("like" , response ["id" ], "rob" )
14781478
1479+ def test_reaction_add_with_moderation_template (self ):
1480+ """Test adding a reaction with moderation template"""
1481+ try :
1482+ response = self .c .reactions .add (
1483+ "like" ,
1484+ "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" ,
1485+ "mike" ,
1486+ moderation_template = "test_moderation_template" ,
1487+ )
1488+ # If moderation is enabled, verify the reaction was created
1489+ self .assertTrue ("id" in response )
1490+ reaction = self .c .reactions .get (response ["id" ])
1491+ self .assertEqual (reaction ["kind" ], "like" )
1492+ self .assertEqual (reaction ["user_id" ], "mike" )
1493+ except Exception as e :
1494+ # If moderation is not enabled, we expect a specific error
1495+ # The important thing is that the moderation_template parameter
1496+ # was accepted and passed to the API without causing a client-side error
1497+ error_message = str (e )
1498+ self .assertTrue (
1499+ "moderation not enabled" in error_message ,
1500+ f"Expected moderation error, but got: { error_message } " ,
1501+ )
1502+
1503+ def test_reaction_add_child_with_moderation_template (self ):
1504+ """Test adding a child reaction with moderation template"""
1505+ # First create a parent reaction
1506+ parent_response = self .c .reactions .add (
1507+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1508+ )
1509+
1510+ try :
1511+ # Add child with moderation template
1512+ child_response = self .c .reactions .add_child (
1513+ "reply" ,
1514+ parent_response ["id" ],
1515+ "rob" ,
1516+ data = {"text" : "Great post!" },
1517+ moderation_template = "child_moderation_template" ,
1518+ )
1519+ # If moderation is enabled, verify the child reaction was created
1520+ self .assertTrue ("id" in child_response )
1521+ child_reaction = self .c .reactions .get (child_response ["id" ])
1522+ self .assertEqual (child_reaction ["kind" ], "reply" )
1523+ self .assertEqual (child_reaction ["user_id" ], "rob" )
1524+ self .assertEqual (child_reaction ["parent" ], parent_response ["id" ])
1525+ except Exception as e :
1526+ # If moderation is not enabled, we expect a specific error
1527+ # The important thing is that the moderation_template parameter
1528+ # was accepted and passed to the API without causing a client-side error
1529+ error_message = str (e )
1530+ self .assertTrue (
1531+ "moderation not enabled" in error_message ,
1532+ f"Expected moderation error, but got: { error_message } " ,
1533+ )
1534+
1535+ def test_reaction_add_without_moderation_template (self ):
1536+ """Test that existing functionality still works without moderation template"""
1537+ response = self .c .reactions .add (
1538+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1539+ )
1540+ self .assertTrue ("id" in response )
1541+ reaction = self .c .reactions .get (response ["id" ])
1542+ self .assertEqual (reaction ["kind" ], "like" )
1543+
1544+ def test_reaction_add_child_without_moderation_template (self ):
1545+ """Test that existing child functionality still works without moderation template"""
1546+ parent_response = self .c .reactions .add (
1547+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1548+ )
1549+ child_response = self .c .reactions .add_child (
1550+ "reply" , parent_response ["id" ], "rob"
1551+ )
1552+ self .assertTrue ("id" in child_response )
1553+ child_reaction = self .c .reactions .get (child_response ["id" ])
1554+ self .assertEqual (child_reaction ["parent" ], parent_response ["id" ])
1555+
14791556 def test_reaction_filter_random (self ):
14801557 self .c .reactions .filter (
14811558 kind = "like" ,
0 commit comments