Repository: praw-dev/praw

Issue:
Add support for mod.comment.lock
## Feature Request

Reddit has recently added a way for mods to lock individual comments. PRAW should support this feature, ideally under comment.mod.lock

https://www.reddit.com/r/modnews/comments/brgr8i/moderators_you_may_now_lock_individual_comments/eodrqq5/

https://www.reddit.com/dev/api#POST_api_lock
Add support for mod.comment.lock
## Feature Request

Reddit has recently added a way for mods to lock individual comments. PRAW should support this feature, ideally under comment.mod.lock

https://www.reddit.com/r/modnews/comments/brgr8i/moderators_you_may_now_lock_individual_comments/eodrqq5/

https://www.reddit.com/dev/api#POST_api_lock


Discussion:

Resolving patch:
diff --git a/praw/models/reddit/mixins/__init__.py b/praw/models/reddit/mixins/__init__.py
--- a/praw/models/reddit/mixins/__init__.py
+++ b/praw/models/reddit/mixins/__init__.py
@@ -97,6 +97,25 @@ def ignore_reports(self):
             API_PATH["ignore_reports"], data={"id": self.thing.fullname}
         )
 
+    def lock(self):
+        """Lock the a :class:`~.Comment` or :class:`~.Submission`.
+
+        Example usage:
+
+           # lock a comment:
+           comment = reddit.comment('dkk4qjd')
+           comment.mod.lock()
+           # lock a submission:
+           submission = reddit.submission(id='5or86n')
+           submission.mod.lock()
+
+        See also :meth:`~.unlock`
+
+        """
+        self.thing._reddit.post(
+            API_PATH["lock"], data={"id": self.thing.fullname}
+        )
+
     def remove(self, spam=False):
         """Remove a :class:`~.Comment` or :class:`~.Submission`.
 
@@ -199,6 +218,25 @@ def unignore_reports(self):
             API_PATH["unignore_reports"], data={"id": self.thing.fullname}
         )
 
+    def unlock(self):
+        """Unlock the a :class:`~.Comment` or :class:`~.Submission`.
+
+        Example usage:
+
+           # unlock a comment:
+           comment = reddit.comment('dkk4qjd')
+           comment.mod.unlock()
+           # unlock a submission:
+           submission = reddit.submission(id='5or86n')
+           submission.mod.unlock()
+
+        See also :meth:`~.lock`
+
+        """
+        self.thing._reddit.post(
+            API_PATH["unlock"], data={"id": self.thing.fullname}
+        )
+
 
 class UserContentMixin(
     EditableMixin,
diff --git a/praw/models/reddit/submission.py b/praw/models/reddit/submission.py
--- a/praw/models/reddit/submission.py
+++ b/praw/models/reddit/submission.py
@@ -465,23 +465,6 @@ def flair(self, text="", css_class=""):
         url = API_PATH["flair"].format(subreddit=self.thing.subreddit)
         self.thing._reddit.post(url, data=data)
 
-    def lock(self):
-        """Lock the submission.
-
-        Example usage:
-
-        .. code:: python
-
-           submission = reddit.submission(id='5or86n')
-           submission.mod.lock()
-
-        See also :meth:`~.unlock`
-
-        """
-        self.thing._reddit.post(
-            API_PATH["lock"], data={"id": self.thing.fullname}
-        )
-
     def nsfw(self):
         """Mark as not safe for work.
 
@@ -582,23 +565,6 @@ def suggested_sort(self, sort="blank"):
             data={"id": self.thing.fullname, "sort": sort},
         )
 
-    def unlock(self):
-        """Unlock the submission.
-
-        Example:
-
-        .. code:: python
-
-           submission = reddit.submission(id='5or86n')
-           submission.mod.unlock()
-
-        See also :meth:`~.lock`
-
-        """
-        self.thing._reddit.post(
-            API_PATH["unlock"], data={"id": self.thing.fullname}
-        )
-
     def unspoiler(self):
         """Indicate that the submission does not contain spoilers.
 


Test patch:
diff --git a/tests/integration/models/reddit/test_comment.py b/tests/integration/models/reddit/test_comment.py
--- a/tests/integration/models/reddit/test_comment.py
+++ b/tests/integration/models/reddit/test_comment.py
@@ -267,11 +267,21 @@ def test_ignore_reports(self):
         ):
             self.reddit.comment("da2g5y6").mod.ignore_reports()
 
+    def test_lock(self):
+        self.reddit.read_only = False
+        with self.recorder.use_cassette("TestCommentModeration.test_lock"):
+            Comment(self.reddit, "da2g6ne").mod.lock()
+
     def test_remove(self):
         self.reddit.read_only = False
         with self.recorder.use_cassette("TestCommentModeration.test_remove"):
             self.reddit.comment("da2g5y6").mod.remove(spam=True)
 
+    def test_unlock(self):
+        self.reddit.read_only = False
+        with self.recorder.use_cassette("TestCommentModeration.test_unlock"):
+            Comment(self.reddit, "da2g6ne").mod.unlock()
+
     @mock.patch("time.sleep", return_value=None)
     def test_send_removal_message(self, _):
         self.reddit.read_only = False