diff --git a/AUTHORS.rst b/AUTHORS.rst index e91a5f2cfc..129c109ee1 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -48,4 +48,5 @@ Source Contributors - vaclav-2012 `@vaclav-2012 `_ - kungming2 `@kungming2 `_ - Jack Steel `@jackodsteel `_ +- David Mirch `@fwump38 `_ - Add "Name and github profile link" above this line. diff --git a/CHANGES.rst b/CHANGES.rst index 0dfaf2f8ec..7046e55774 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,14 @@ Unreleased * :meth:`.Reddit.redditor` supports ``fullname`` param to fetch a Redditor by the fullname instead of name. :class:`.Redditor` constructor now also has ``fullname`` param. +* Add :class:`.Reason` and :class:`.SubredditReasons` to work with removal + reasons +* Attribute ``reasons`` to :class:`.Subreddit` to interact with new removal + reason classes +* Add :meth:`.ThingModerationMixin.add_removal_reason` to add a removal + reason to a removed submission/comment +* Parameters ``reason_id`` and ``mod_note`` to + :meth:`.ThingModerationMixin.remove` to optionally apply a removal reason 6.4.0 (2019/09/21) ------------------ diff --git a/docs/code_overview/other.rst b/docs/code_overview/other.rst index 47c28c9488..2a3e229c51 100644 --- a/docs/code_overview/other.rst +++ b/docs/code_overview/other.rst @@ -97,12 +97,14 @@ instances of them bound to an attribute of one of the PRAW models. other/modmail other/modmailmessage other/preferences + other/reason other/redditbase other/redditorlist other/sublisting other/submenu other/subredditemoji other/subredditmessage + other/subredditreasons other/redditorstream other/trophy other/util diff --git a/docs/code_overview/other/reason.rst b/docs/code_overview/other/reason.rst new file mode 100644 index 0000000000..2ef340956a --- /dev/null +++ b/docs/code_overview/other/reason.rst @@ -0,0 +1,5 @@ +Reason +====== + +.. autoclass:: praw.models.reddit.reasons.Reason + :inherited-members: \ No newline at end of file diff --git a/docs/code_overview/other/subredditreasons.rst b/docs/code_overview/other/subredditreasons.rst new file mode 100644 index 0000000000..4e3f10c1b5 --- /dev/null +++ b/docs/code_overview/other/subredditreasons.rst @@ -0,0 +1,5 @@ +SubredditReasons +================ + +.. autoclass:: praw.models.reddit.reasons.SubredditReasons + :inherited-members: diff --git a/praw/endpoints.py b/praw/endpoints.py index 7f7c6f3d9a..f2c5b45cbd 100644 --- a/praw/endpoints.py +++ b/praw/endpoints.py @@ -134,6 +134,9 @@ "read_message": "api/read_message/", "removal_comment_message": "api/v1/modactions/removal_comment_message", "removal_link_message": "api/v1/modactions/removal_link_message", + "removal_reasons": "api/v1/modactions/removal_reasons", + "removal_reason": "api/v1/{subreddit}/removal_reasons/{id}", + "removal_reasons_list": "api/v1/{subreddit}/removal_reasons", "remove": "api/remove/", "report": "api/report/", "rules": "r/{subreddit}/about/rules", diff --git a/praw/models/__init__.py b/praw/models/__init__.py index 79f02f5f34..f994988fbf 100644 --- a/praw/models/__init__.py +++ b/praw/models/__init__.py @@ -18,6 +18,7 @@ from .reddit.modmail import ModmailAction, ModmailConversation, ModmailMessage from .reddit.more import MoreComments from .reddit.multi import Multireddit +from .reddit.reasons import Reason from .reddit.redditor import Redditor from .reddit.submission import Submission from .reddit.subreddit import Subreddit diff --git a/praw/models/reddit/mixins/__init__.py b/praw/models/reddit/mixins/__init__.py index edb6432d5f..3103800dd4 100644 --- a/praw/models/reddit/mixins/__init__.py +++ b/praw/models/reddit/mixins/__init__.py @@ -118,11 +118,16 @@ def lock(self): API_PATH["lock"], data={"id": self.thing.fullname} ) - def remove(self, spam=False): + def remove(self, spam=False, reason_id=None, mod_note=""): """Remove a :class:`~.Comment` or :class:`~.Submission`. :param spam: When True, use the removal to help train the Subreddit's spam filter (default: False). + :param reason_id: The removal reason ID. + :param mod_note: A message for the other moderators. + + If either reason_id or mod_note are provided, a second API call is made + using :meth:`~.add_removal_reason` Example usage: @@ -134,10 +139,52 @@ def remove(self, spam=False): # remove a submission submission = reddit.submission(id='5or86n') submission.mod.remove() + # remove a submission with a removal reason + reason = reddit.subreddit.reasons["110ni21zo23ql"] + submission = reddit.submission(id="5or86n") + submission.mod.remove(reason_id=reason.id) """ data = {"id": self.thing.fullname, "spam": bool(spam)} self.thing._reddit.post(API_PATH["remove"], data=data) + if any([reason_id, mod_note]): + self.add_removal_reason(reason_id, mod_note) + + def add_removal_reason(self, reason_id=None, mod_note=""): + """Add a removal reason for a Comment or Submission. + + :param reason_id: The removal reason ID. + :param mod_note: A message for the other moderators. + + It is necessary to first call :meth:`~.remove` on the + :class:`~.Comment` or :class:`~.Submission`. + + If reason_id is not specified, mod_note cannot be blank. + + Example usage: + + .. code:: python + + comment = reddit.comment("dkk4qjd") + comment.mod.add_removal_reason(reason_id="110ni21zo23ql") + # remove a submission and add a mod note + submission = reddit.submission(id="5or86n") + submission.mod.remove(reason_id="110ni21zo23ql", mod_note="foo") + + """ + if not reason_id and not mod_note: + raise ValueError( + "mod_note cannot be blank if reason_id is not specified" + ) + # Only the first element of the item_id list is used. + data = { + "item_ids": [self.thing.fullname], + "mod_note": mod_note, + "reason_id": reason_id, + } + self.thing._reddit.post( + API_PATH["removal_reasons"], data={"json": dumps(data)} + ) def send_removal_message( self, diff --git a/praw/models/reddit/reasons.py b/praw/models/reddit/reasons.py new file mode 100644 index 0000000000..dd6ca5b264 --- /dev/null +++ b/praw/models/reddit/reasons.py @@ -0,0 +1,170 @@ +"""Provide the Reason class.""" +from ...const import API_PATH +from ...exceptions import ClientException +from .base import RedditBase + + +class Reason(RedditBase): + """An individual Reason object. + + **Typical Attributes** + + This table describes attributes that typically belong to objects of this + class. Since attributes are dynamically provided (see + :ref:`determine-available-attributes-of-an-object`), there is not a + guarantee that these attributes will always be present, nor is this list + necessarily comprehensive. + + ======================= =================================================== + Attribute Description + ======================= =================================================== + ``id`` The id of the removal reason. + ``title`` The title of the removal reason. + ``message`` The message of the removal reason. + ======================= =================================================== + """ + + STR_FIELD = "id" + + def __eq__(self, other): + """Return whether the other instance equals the current.""" + if isinstance(other, str): + return other == str(self) + return ( + isinstance(other, self.__class__) + and str(self) == str(other) + and other.subreddit == self.subreddit + ) + + def __hash__(self): + """Return the hash of the current instance.""" + return ( + hash(self.__class__.__name__) + ^ hash(str(self)) + ^ hash(self.subreddit) + ) + + def __init__(self, reddit, subreddit, reason_id, _data=None): + """Construct an instance of the Reason object.""" + self.id = reason_id + self.subreddit = subreddit + super(Reason, self).__init__(reddit, _data=_data) + + def _fetch(self): + for reason in self.subreddit.reasons: + if reason.id == self.id: + self.__dict__.update(reason.__dict__) + self._fetched = True + return + raise ClientException( + "/r/{} does not have the reason {}".format(self.subreddit, self.id) + ) + + +class SubredditReasons: + """Provide a set of functions to a Subreddit's removal reasons.""" + + def __getitem__(self, reason_id): + """Lazily return the Reason for the subreddit with id ``reason_id``. + + :param reason_id: The id of the removal reason + + This method is to be used to fetch a specific removal reason, like so: + + .. code:: python + + reason = reddit.subreddit('praw_test').reasons['141vv5c16py7d'] + print(reason) + + """ + return Reason(self._reddit, self.subreddit, reason_id) + + def __init__(self, subreddit): + """Create a SubredditReasons instance. + + :param subreddit: The subreddit whose removal reasons to work with. + + """ + self.subreddit = subreddit + self._reddit = subreddit._reddit + + def __iter__(self): + """Return a list of Removal Reasons for the subreddit. + + This method is used to discover all removal reasons for a + subreddit: + + .. code-block:: python + + for reason in reddit.subreddit('NAME').reasons: + print(reason) + + """ + response = self.subreddit._reddit.get( + API_PATH["removal_reasons_list"].format(subreddit=self.subreddit) + ) + for reason_id, reason_data in response["data"].items(): + yield Reason( + self._reddit, self.subreddit, reason_id, _data=reason_data + ) + + def add(self, title, message): + """Add a removal reason to this subreddit. + + :param title: The title of the removal reason + :param message: The message to send the user. + :returns: The Reason added. + + The message will be prepended with `Hi u/username,` automatically. + + To add ``'test'`` to the subreddit ``'praw_test'`` try: + + .. code:: python + + reddit.subreddit('praw_test').reason.add('test','This is a test') + + """ + data = {"title": title, "message": message} + url = API_PATH["removal_reasons_list"].format(subreddit=self.subreddit) + reason_id = self.subreddit._reddit.post(url, data=data) + return Reason(self._reddit, self.subreddit, reason_id) + + def update(self, reason_id, title, message): + """Update the removal reason from this subreddit by ``reason_id``. + + :param reason_id: The id of the removal reason + :param title: The removal reason's new title (required). + :param message: The removal reason's new message (required). + + To update ``'141vv5c16py7d'`` from the subreddit ``'praw_test'`` try: + + .. code:: python + + reddit.subreddit('praw_test').reason.update( + '141vv5c16py7d', + 'New Title', + 'New message') + + """ + url = API_PATH["removal_reason"].format( + subreddit=self.subreddit, id=reason_id + ) + data = {"title": title, "message": message} + self.subreddit._reddit.put(url, data=data) + + def delete(self, reason_id): + """Delete a removal reason from this subreddit. + + :param reason_id: The id of the removal reason to remove + + To delete ``'141vv5c16py7d'`` from the subreddit ``'praw_test'`` try: + + .. code:: python + + reddit.subreddit('praw_test').reason.delete('141vv5c16py7d') + + """ + url = API_PATH["removal_reason"].format( + subreddit=self.subreddit, id=reason_id + ) + self.subreddit._reddit.request("DELETE", url) diff --git a/praw/models/reddit/subreddit.py b/praw/models/reddit/subreddit.py index a87ff29c28..c23ddda97f 100644 --- a/praw/models/reddit/subreddit.py +++ b/praw/models/reddit/subreddit.py @@ -18,6 +18,7 @@ from .emoji import SubredditEmoji from .mixins import FullnameMixin, MessageableMixin from .modmail import ModmailConversation +from .reasons import SubredditReasons from .widgets import SubredditWidgets, WidgetEncoder from .wikipage import WikiPage @@ -349,6 +350,31 @@ def quaran(self): """ return SubredditQuarantine(self) + @cachedproperty + def reasons(self): + """Provide an instance of :class:`.SubredditReasons`. + + Use this attribute for interacting with a subreddit's removal reasons. + For example to list all the removal reaons for a subreddit which you + have the ``posts`` moderator permission on try: + + .. code-block:: python + + for reason in reddit.subreddit('NAME').reasons: + print(reason) + + A single removal reason can be lazily retrieved via: + + .. code:: python + + reddit.subreddit('NAME').reasons['title'] + + .. note:: Attempting to access attributes of an nonexistent removal + reason will result in a :class:`.ClientException`. + + """ + return SubredditReasons(self) + @cachedproperty def stream(self): """Provide an instance of :class:`.SubredditStream`. diff --git a/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason.json b/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason.json new file mode 100644 index 0000000000..ca078d95a1 --- /dev/null +++ b/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason.json @@ -0,0 +1,342 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:28:24", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:24 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=Xqm0uwYJnP3fAb9H7N; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21928-LGA" + ], + "X-Timer": [ + "S1575188904.920610,VS0,VE393" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:28:24", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t1_f98ukt5&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "38" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=Xqm0uwYJnP3fAb9H7N" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:24 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21924-LGA" + ], + "X-Timer": [ + "S1575188904.400567,VS0,VE207" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M21vVHBpbUJKcnRheGFscUtxeFU5LWRRYjluUUtxcG43eGxIRmxHTFJXZUJwNTNSYzlZdWE4UlFoa1VFN19JUE9KRVZXQUtwT3JUUjJyOWNfSHEwenVMM1FSN1ViU3BHODM0V245cDlidnhVd2dNZzdPalMxNnBOUHZVQktrbW1QeUc; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:28:24 GMT; secure", + "session_tracker=SJBU46e3T7GDWFQiNO.0.1575188904429.Z0FBQUFBQmQ0M21vZGNkNlVKNGN0ZHRhYTQ4Z2NsejVheEh1MFQzSTFEbjBTUjVNUjJUTEhRTFhTQ3FfMjVJWmlaa0tEYTVCLUpLNHN6Vi1sQWI0V1JXUnV5d3hMcVVTOGtBNjhhU3FwdWNkUWI3WnVhRnRvdE1KbWs1RzR5clZqNGd3YXdENFpOVWw; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:24 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "96" + ], + "x-ratelimit-used": [ + "1" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + }, + { + "recorded_at": "2019-12-01T08:28:24", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&json=%7B%22item_ids%22%3A+%5B%22t1_f98ukt5%22%5D%2C+%22mod_note%22%3A+%22Blah%22%2C+%22reason_id%22%3A+%22110nhral8vygf%22%7D" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "139" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=Xqm0uwYJnP3fAb9H7N; loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M21vVHBpbUJKcnRheGFscUtxeFU5LWRRYjluUUtxcG43eGxIRmxHTFJXZUJwNTNSYzlZdWE4UlFoa1VFN19JUE9KRVZXQUtwT3JUUjJyOWNfSHEwenVMM1FSN1ViU3BHODM0V245cDlidnhVd2dNZzdPalMxNnBOUHZVQktrbW1QeUc; session_tracker=SJBU46e3T7GDWFQiNO.0.1575188904429.Z0FBQUFBQmQ0M21vZGNkNlVKNGN0ZHRhYTQ4Z2NsejVheEh1MFQzSTFEbjBTUjVNUjJUTEhRTFhTQ3FfMjVJWmlaa0tEYTVCLUpLNHN6Vi1sQWI0V1JXUnV5d3hMcVVTOGtBNjhhU3FwdWNkUWI3WnVhRnRvdE1KbWs1RzR5clZqNGd3YXdENFpOVWw" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:24 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21924-LGA" + ], + "X-Timer": [ + "S1575188905.638592,VS0,VE53" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=SJBU46e3T7GDWFQiNO.0.1575188904663.Z0FBQUFBQmQ0M21vNVFFdzNXeERRYjIyN0tqWkd4NmVTeVhqbmNuQ25PWi1nV0ZjX2l4QXZWZ3VjaWVsVUlZZ1h4VUdzVmpuRjZ5WEh2SDlMdFl2dV9iQVdDOXBQbFJsaUl0dnpGb2tzMnFLeHNPejZuaVdZNHFQWTdXc04yVFJpWDJMRnVSOTNoOUU; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:24 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "96" + ], + "x-ratelimit-used": [ + "2" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason_invalid.json b/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason_invalid.json new file mode 100644 index 0000000000..a0fe338bb0 --- /dev/null +++ b/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason_invalid.json @@ -0,0 +1,226 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:28:25", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:25 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=pUoMaLJgObdrGgzC4P; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21944-LGA" + ], + "X-Timer": [ + "S1575188906.571465,VS0,VE391" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:28:26", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t1_f9974ce&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "38" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=pUoMaLJgObdrGgzC4P" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:26 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21921-LGA" + ], + "X-Timer": [ + "S1575188906.044564,VS0,VE238" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M21xVFFkbnA5TDdwc0dPa0hSaEd1SHMxdXJORjQ3U0tyY1NSMXlfQk9hRk5SZWQ5Z1F2MldWZlZlWmxWSU5HYWs2Wk95XzdZNDJDQnBCMGVTZTZtNlJ6cUdLVm5SNXZNRFhOaThlM2R4R0ZOTGJLR2VKM3lsNG1CamFkbFB5VlZUTTY; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:28:26 GMT; secure", + "session_tracker=FcFWrsy3D6UBR21XKI.0.1575188906070.Z0FBQUFBQmQ0M21xaXNfQlpfUXZQTGprLVprNFhPZDNyVC12d1BVRFpwb3BFc1ZsdXJzVnhBdlB6X0ZmYmh2bm1TbTJ6Rm5UOGJCWU96TXIxQkV3NHdGUS1UbTNRaGNlN1Njd2I1c0pLUEp3a3NQc0VrTlBtd3VPUU9Mak4wZ2NSVmwtU2lJZU5qOFc; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:26 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "595.0" + ], + "x-ratelimit-reset": [ + "94" + ], + "x-ratelimit-used": [ + "5" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason_without_id.json b/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason_without_id.json new file mode 100644 index 0000000000..cc97788155 --- /dev/null +++ b/tests/integration/cassettes/TestCommentModeration.test_add_removal_reason_without_id.json @@ -0,0 +1,342 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:28:25", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:25 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=P3bBx6N2ebfHFppD0V; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21945-LGA" + ], + "X-Timer": [ + "S1575188905.774964,VS0,VE390" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:28:25", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t1_f98ugot&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "38" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=P3bBx6N2ebfHFppD0V" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:25 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21928-LGA" + ], + "X-Timer": [ + "S1575188905.240622,VS0,VE165" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M21wcGlOVmxnT0VXQkhQWXJ2VVAzUTY2d1dsbVFfbG5BVXFyTVRteWR0SnhqT2FkOVBlVHkxRG9Nc3d0UC1lT041YUlPMi11aEh6aHA3bGttOHZDYXFkSVhUSlI4NXo2NHpaMVpFdi1DV1lXVXVUbXk1VUV4RkhJdzRGXy0wT2x5N28; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:28:25 GMT; secure", + "session_tracker=28SGjwavxUQXSn5Oro.0.1575188905275.Z0FBQUFBQmQ0M21wYzdvVVBtc1NqTlZnSFlROG5RLW9CR2hWbmVRaEQ2Uk92Y0RfZkJ6a2ZxOGZtX0lqNmpDb3QzckVMMDZVRWZDNnJycEZqTG5YdGVsVkZaXzNGQ1p2TmZTVndMY0ZtaWtvbjliZzVmcUJuaUtZNlU0dkNucHVCd2JUTVd1RWFkUGk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:25 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "597.0" + ], + "x-ratelimit-reset": [ + "95" + ], + "x-ratelimit-used": [ + "3" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + }, + { + "recorded_at": "2019-12-01T08:28:25", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&json=%7B%22item_ids%22%3A+%5B%22t1_f98ugot%22%5D%2C+%22mod_note%22%3A+%22Test%22%2C+%22reason_id%22%3A+null%7D" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "124" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=P3bBx6N2ebfHFppD0V; loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M21wcGlOVmxnT0VXQkhQWXJ2VVAzUTY2d1dsbVFfbG5BVXFyTVRteWR0SnhqT2FkOVBlVHkxRG9Nc3d0UC1lT041YUlPMi11aEh6aHA3bGttOHZDYXFkSVhUSlI4NXo2NHpaMVpFdi1DV1lXVXVUbXk1VUV4RkhJdzRGXy0wT2x5N28; session_tracker=28SGjwavxUQXSn5Oro.0.1575188905275.Z0FBQUFBQmQ0M21wYzdvVVBtc1NqTlZnSFlROG5RLW9CR2hWbmVRaEQ2Uk92Y0RfZkJ6a2ZxOGZtX0lqNmpDb3QzckVMMDZVRWZDNnJycEZqTG5YdGVsVkZaXzNGQ1p2TmZTVndMY0ZtaWtvbjliZzVmcUJuaUtZNlU0dkNucHVCd2JUTVd1RWFkUGk" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:25 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21928-LGA" + ], + "X-Timer": [ + "S1575188905.419679,VS0,VE51" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=28SGjwavxUQXSn5Oro.0.1575188905445.Z0FBQUFBQmQ0M21wWHhHS3lFQWpIQ1NCSDZCeVVvR0FtaXlOQk11eUJoN3FWSUlIUWhqNGhOUVRHRUpDZ0FaTXhyQ3FvZ0tQbTAwclNfOF9TaFhTNDVBWlZVRldTTW9uYi1yaE5DQ2RYdUdfUVBydW1oMUh5RF9obDBKZXJ2TmNjMlEya2RfcXRDMmg; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:25 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "95" + ], + "x-ratelimit-used": [ + "4" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestCommentModeration.test_remove_with_reason_id.json b/tests/integration/cassettes/TestCommentModeration.test_remove_with_reason_id.json new file mode 100644 index 0000000000..1c43e8142d --- /dev/null +++ b/tests/integration/cassettes/TestCommentModeration.test_remove_with_reason_id.json @@ -0,0 +1,342 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T07:22:05", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:22:05 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=lV7TAYpEVhMiFOIgpB; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21946-LGA" + ], + "X-Timer": [ + "S1575184925.766977,VS0,VE405" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T07:22:05", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t1_f3dm3b7&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "38" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=lV7TAYpEVhMiFOIgpB" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:22:01 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21951-LGA" + ], + "X-Timer": [ + "S1575184922.658226,VS0,VE176" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0Mm9kbTE2d3FFQjFkQjZhM211NEtPR3UxQWlLNW9jMU1ZcVIxQlVWSU1UaDFybHprb0FteXdGZ05SMDFDMEVDWUp6Vk5KM3VMeGNCTk01LTBXUEJJYjFGNUlCaHlVd3BzdGtQRjFZTW8yMlItVWJDZjFMT3pPTU1tbjlWVVg0U3VjU3I; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 07:22:05 GMT; secure", + "session_tracker=HNfvaPCW1LEnpLzOXC.0.1575184925286.Z0FBQUFBQmQ0Mm9kaGlxbUpyekZ0VklLSzFmeEMwQlJPNkZPYVBReGYta0J0ekhKUVhyU2xNTkFOVk1KNTRJUllrRUVVWi1qYkI0V0xUOXBYWVkyOV9Gb0dFdlUzd21lVVQzemVGYWZhMTlrWllqd2h4a2tCbWVER2xtTmh6Rk9LcHhuZW9neFZCNHg; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:22:05 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "475" + ], + "x-ratelimit-used": [ + "1" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + }, + { + "recorded_at": "2019-12-01T07:22:05", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&json=%7B%22item_ids%22%3A+%5B%22t1_f3dm3b7%22%5D%2C+%22mod_note%22%3A+%22%22%2C+%22reason_id%22%3A+%22110nhral8vygf%22%7D" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "135" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=lV7TAYpEVhMiFOIgpB; loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0Mm9kbTE2d3FFQjFkQjZhM211NEtPR3UxQWlLNW9jMU1ZcVIxQlVWSU1UaDFybHprb0FteXdGZ05SMDFDMEVDWUp6Vk5KM3VMeGNCTk01LTBXUEJJYjFGNUlCaHlVd3BzdGtQRjFZTW8yMlItVWJDZjFMT3pPTU1tbjlWVVg0U3VjU3I; session_tracker=HNfvaPCW1LEnpLzOXC.0.1575184925286.Z0FBQUFBQmQ0Mm9kaGlxbUpyekZ0VklLSzFmeEMwQlJPNkZPYVBReGYta0J0ekhKUVhyU2xNTkFOVk1KNTRJUllrRUVVWi1qYkI0V0xUOXBYWVkyOV9Gb0dFdlUzd21lVVQzemVGYWZhMTlrWllqd2h4a2tCbWVER2xtTmh6Rk9LcHhuZW9neFZCNHg" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:22:01 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21951-LGA" + ], + "X-Timer": [ + "S1575184922.857410,VS0,VE56" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=HNfvaPCW1LEnpLzOXC.0.1575184925481.Z0FBQUFBQmQ0Mm9kYXRsMDBVRFBoWndycld0OEFVNW1adFlwZmJ2dDJUb1h5Rkx4MklxUmQ4LU9XVWREX3B6eGtZdm1aMDNXSG1xV1dfNy1UeVZwdVNYUHY4b0FxcVVveWsxWUlmQmN2TWw3OVAtOG9mX0JvWThqV3cwdjAxLWFzN1cxay1yQlhaZFk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:22:05 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "475" + ], + "x-ratelimit-used": [ + "2" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestReason.test__fetch.json b/tests/integration/cassettes/TestReason.test__fetch.json new file mode 100644 index 0000000000..2c0b899011 --- /dev/null +++ b/tests/integration/cassettes/TestReason.test__fetch.json @@ -0,0 +1,220 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T07:11:55", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:55 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=uEu4NBIGa7r8E67Xzw; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21944-LGA" + ], + "X-Timer": [ + "S1575184315.967222,VS0,VE374" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T07:11:55", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=uEu4NBIGa7r8E67Xzw" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"data\": {\"110nit79o5h3j\": {\"message\": \"It looks like you're looking for a ride to the forest, or looking to give someone a ride! Check out our [rideshare thread](https://www.reddit.com/r/ElectricForest/comments/8d65e7/the_relectricforest_2018_rideshare_thread/)\", \"id\": \"110nit79o5h3j\", \"title\": \"Rideshare\"}, \"12w9jt703c54s\": {\"message\": \"Please review our sidebar for the complete list of rules.\", \"id\": \"12w9jt703c54s\", \"title\": \"Generic\"}, \"110nhk2cgmaxy\": {\"message\": \"Rule 1 - Please use the search function as well as check out our [2018 Mega Post](https://www.reddit.com/r/ElectricForest/comments/7l599k/list_of_useful_posts/)\", \"id\": \"110nhk2cgmaxy\", \"title\": \"Search\"}, \"110nihwu2yodi\": {\"message\": \"Please do not post about sneaking in drugs, any illegal items, or any items against HQ's Guidelines.\", \"id\": \"110nihwu2yodi\", \"title\": \"Follow HQ Rules\"}, \"110niezjjw156\": {\"message\": \"This subreddit is not the place, please visit the [Knowledge Base Wiki](https://www.reddit.com/r/Drugs/wiki/knowledgebase) in /r/drugs. Some other helpful subreddits:\\n\\n* /r/reagenttesting\\n\\n* /r/psychonaut\", \"id\": \"110niezjjw156\", \"title\": \"Drugs\"}, \"110nhyk34m01d\": {\"message\": \"Rule 3 - No buying/selling/trading is allowed on our subreddit. If you are trying to give something away, please message the moderators first\\n\\nIf you are looking to buy or sell a ticket, please head on over to the [Official EF Ticket Exchange](https://www.electricforestfestival.com/tickets/wristband-exchange/)!\", \"id\": \"110nhyk34m01d\", \"title\": \"Buy/Sell\"}, \"110nil6tchrhg\": {\"message\": \"Rule 7 - Please follow general reddiquette.\\n\\nFor information regarding this and similar issues please see the sidebar. If you have any questions, [please feel free to message the mods](https://www.reddit.com/message/compose?to=%2Fr%2FElectricForest). Thank you!\", \"id\": \"110nil6tchrhg\", \"title\": \"Reddiquette\"}, \"110nib8nlsz79\": {\"message\": \"That\\u2019s not forest vibes, [fam.](https://media.giphy.com/media/12ClTeBg4yvkiI/200.gif)\", \"id\": \"110nib8nlsz79\", \"title\": \"Forest Vibes\"}, \"110niqgkuz8ab\": {\"message\": \"Welcome to attending the forest for the first time! Before you have quetions, here are two threads that will be of much help to you. \\n\\n* [Our Guide to EF](https://drive.google.com/file/d/0B0rIiDle2lgpOXFmZnJPTWVTeDQ/view)\\n* [List of Useful Posts](https://www.reddit.com/r/ElectricForest/comments/7l599k/list_of_useful_posts/)\\n\\nIf you still have questions, try using our search function or asking in our daily \\\"no dumb question\\\" thread and you will more than likely find the answer you're looking for!\", \"id\": \"110niqgkuz8ab\", \"title\": \"New to Forest\"}, \"110nhral8vygf\": {\"message\": \"Rule 2 - Be kind and respectful to others.\", \"id\": \"110nhral8vygf\", \"title\": \"Be Kind\"}}, \"order\": [\"110nhk2cgmaxy\", \"110nhral8vygf\", \"110nhyk34m01d\", \"110nib8nlsz79\", \"110niezjjw156\", \"110nihwu2yodi\", \"110nil6tchrhg\", \"110niqgkuz8ab\", \"110nit79o5h3j\", \"12w9jt703c54s\"]}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2947" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:55 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21946-LGA" + ], + "X-Timer": [ + "S1575184315.431870,VS0,VE48" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0MmU3dDR1WFViUERPeGxqbXRaQlByZmllUTFFRVZTS1hsdTRkYWtyY0pncmRCQ19hRWFYNkpXaHNsODA0MlhibXV6QldzWk54YUwya3pZYlhpXzJzMmVaVlJQTHkyZWZoazFaSi1ZWWQ0ZC1ROG5aWUFNZ2JaS0p4VHRBLVRaVGt3OEk; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 07:11:55 GMT; secure", + "session_tracker=NiY5bsfBQF0IcS35bJ.0.1575184315455.Z0FBQUFBQmQ0MmU3czc5aUVDMFFxRjBmYXM0Vk9jZDE0bHZ2WnluV29wSnp2cEF3R18wX19RVl9wNFdraWpCUXI2RWlEMjR1UUhSYkxmWHBzSzJDLThpUFcxbUM4MEhqdXRXWEhPTkt1d05zZU5fd2FOS294WEVSNmFXUllPSG9BYTd6b3FFVmtJbF8; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:11:55 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "485" + ], + "x-ratelimit-used": [ + "4" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestReason.test__fetch__invalid_reason.json b/tests/integration/cassettes/TestReason.test__fetch__invalid_reason.json new file mode 100644 index 0000000000..b61cfb9751 --- /dev/null +++ b/tests/integration/cassettes/TestReason.test__fetch__invalid_reason.json @@ -0,0 +1,220 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T07:11:55", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:55 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=KxT96xz8jNbPlkOVKQ; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21943-LGA" + ], + "X-Timer": [ + "S1575184316.557454,VS0,VE364" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T07:11:56", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=KxT96xz8jNbPlkOVKQ" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"data\": {\"110nit79o5h3j\": {\"message\": \"It looks like you're looking for a ride to the forest, or looking to give someone a ride! Check out our [rideshare thread](https://www.reddit.com/r/ElectricForest/comments/8d65e7/the_relectricforest_2018_rideshare_thread/)\", \"id\": \"110nit79o5h3j\", \"title\": \"Rideshare\"}, \"12w9jt703c54s\": {\"message\": \"Please review our sidebar for the complete list of rules.\", \"id\": \"12w9jt703c54s\", \"title\": \"Generic\"}, \"110nhk2cgmaxy\": {\"message\": \"Rule 1 - Please use the search function as well as check out our [2018 Mega Post](https://www.reddit.com/r/ElectricForest/comments/7l599k/list_of_useful_posts/)\", \"id\": \"110nhk2cgmaxy\", \"title\": \"Search\"}, \"110nihwu2yodi\": {\"message\": \"Please do not post about sneaking in drugs, any illegal items, or any items against HQ's Guidelines.\", \"id\": \"110nihwu2yodi\", \"title\": \"Follow HQ Rules\"}, \"110niezjjw156\": {\"message\": \"This subreddit is not the place, please visit the [Knowledge Base Wiki](https://www.reddit.com/r/Drugs/wiki/knowledgebase) in /r/drugs. Some other helpful subreddits:\\n\\n* /r/reagenttesting\\n\\n* /r/psychonaut\", \"id\": \"110niezjjw156\", \"title\": \"Drugs\"}, \"110nhyk34m01d\": {\"message\": \"Rule 3 - No buying/selling/trading is allowed on our subreddit. If you are trying to give something away, please message the moderators first\\n\\nIf you are looking to buy or sell a ticket, please head on over to the [Official EF Ticket Exchange](https://www.electricforestfestival.com/tickets/wristband-exchange/)!\", \"id\": \"110nhyk34m01d\", \"title\": \"Buy/Sell\"}, \"110nil6tchrhg\": {\"message\": \"Rule 7 - Please follow general reddiquette.\\n\\nFor information regarding this and similar issues please see the sidebar. If you have any questions, [please feel free to message the mods](https://www.reddit.com/message/compose?to=%2Fr%2FElectricForest). Thank you!\", \"id\": \"110nil6tchrhg\", \"title\": \"Reddiquette\"}, \"110nib8nlsz79\": {\"message\": \"That\\u2019s not forest vibes, [fam.](https://media.giphy.com/media/12ClTeBg4yvkiI/200.gif)\", \"id\": \"110nib8nlsz79\", \"title\": \"Forest Vibes\"}, \"110niqgkuz8ab\": {\"message\": \"Welcome to attending the forest for the first time! Before you have quetions, here are two threads that will be of much help to you. \\n\\n* [Our Guide to EF](https://drive.google.com/file/d/0B0rIiDle2lgpOXFmZnJPTWVTeDQ/view)\\n* [List of Useful Posts](https://www.reddit.com/r/ElectricForest/comments/7l599k/list_of_useful_posts/)\\n\\nIf you still have questions, try using our search function or asking in our daily \\\"no dumb question\\\" thread and you will more than likely find the answer you're looking for!\", \"id\": \"110niqgkuz8ab\", \"title\": \"New to Forest\"}, \"110nhral8vygf\": {\"message\": \"Rule 2 - Be kind and respectful to others.\", \"id\": \"110nhral8vygf\", \"title\": \"Be Kind\"}}, \"order\": [\"110nhk2cgmaxy\", \"110nhral8vygf\", \"110nhyk34m01d\", \"110nib8nlsz79\", \"110niezjjw156\", \"110nihwu2yodi\", \"110nil6tchrhg\", \"110niqgkuz8ab\", \"110nit79o5h3j\", \"12w9jt703c54s\"]}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2947" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:56 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21927-LGA" + ], + "X-Timer": [ + "S1575184316.002356,VS0,VE49" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0MmU4ZTNfVlVwZW84Rlh1YXZmcUMzdUp6R3FhalRORHMyWnBJbTRBdWxIcU9kY002WkV2TDUxRFIwX2E5Xzl2UTJMN2haLWF2Vm5zc1RPblhNSzdYX29aRlA3MjR5bHB5LWRIX3QxN0ZCVndTQkFyX05HbFNnMlZEN09neGZndUpNNDA; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 07:11:56 GMT; secure", + "session_tracker=uiAMNWwFLcjNZQu7Sz.0.1575184316025.Z0FBQUFBQmQ0MmU4WHlzVzJqRGJsLWdoNjJnVklsaWkyTzVycllhR0hmSUkyR041QnoyZ0hLV2NRN09Edjc0WXdldUlDOXd0N1Q1Mkc0VXN4UkdCYjUtcUpES2M1YzZKQ0hqSlpnOVNUX0dSMks0NHhOc1h3S3BxT1U2ejd4NWhfbDdVWmQzSjQ1SS0; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:11:56 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "595.0" + ], + "x-ratelimit-reset": [ + "484" + ], + "x-ratelimit-used": [ + "5" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason.json b/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason.json new file mode 100644 index 0000000000..399bdadd1d --- /dev/null +++ b/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason.json @@ -0,0 +1,342 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:28:35", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:35 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=frDZMQ6YIwpdGp7kUJ; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21950-LGA" + ], + "X-Timer": [ + "S1575188915.124623,VS0,VE389" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:28:35", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t3_e3oo6a&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "37" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=frDZMQ6YIwpdGp7kUJ" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:35 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21931-LGA" + ], + "X-Timer": [ + "S1575188916.600528,VS0,VE313" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M216cHF4X2dZcDNXalJLVkt5cnI3MnJJeUR0eGNtcUcxNXpjdW9NdGRQa29Xbm1IMEFRcF82Qk5XcFEyX1U2bUwyWWFmM0FHMDN5NHNCaUtyTm4wWmkwOWF2THMxeWpWSl9sNmdEelBXUWFwQndadGx3ZlBNTmVlMEVkVFpVTTZDVjY; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:28:35 GMT; secure", + "session_tracker=i1i84Y5BBA3jLyV9pc.0.1575188915625.Z0FBQUFBQmQ0M216ck05bkx6WlBST2FoUFVXQVNPYm5QVWRGUENXNzVOakMtcUF1ak4xYmN6ZndJdlpCYVNLcmJfTDNKMUs2N254T2hrdFJaNVlERFJ1MV9JbGNPV1BMNzAtNkpTX2h3N1ZtSWdDQlNqRUw1T0NDNVlXYzNNa1ZPSGVFYlJrZEVnQmI; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:35 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "594.0" + ], + "x-ratelimit-reset": [ + "85" + ], + "x-ratelimit-used": [ + "6" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + }, + { + "recorded_at": "2019-12-01T08:28:35", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&json=%7B%22item_ids%22%3A+%5B%22t3_e3oo6a%22%5D%2C+%22mod_note%22%3A+%22Foobar%22%2C+%22reason_id%22%3A+%22110nhral8vygf%22%7D" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "140" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=frDZMQ6YIwpdGp7kUJ; loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M216cHF4X2dZcDNXalJLVkt5cnI3MnJJeUR0eGNtcUcxNXpjdW9NdGRQa29Xbm1IMEFRcF82Qk5XcFEyX1U2bUwyWWFmM0FHMDN5NHNCaUtyTm4wWmkwOWF2THMxeWpWSl9sNmdEelBXUWFwQndadGx3ZlBNTmVlMEVkVFpVTTZDVjY; session_tracker=i1i84Y5BBA3jLyV9pc.0.1575188915625.Z0FBQUFBQmQ0M216ck05bkx6WlBST2FoUFVXQVNPYm5QVWRGUENXNzVOakMtcUF1ak4xYmN6ZndJdlpCYVNLcmJfTDNKMUs2N254T2hrdFJaNVlERFJ1MV9JbGNPV1BMNzAtNkpTX2h3N1ZtSWdDQlNqRUw1T0NDNVlXYzNNa1ZPSGVFYlJrZEVnQmI" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:35 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21931-LGA" + ], + "X-Timer": [ + "S1575188916.935972,VS0,VE59" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=i1i84Y5BBA3jLyV9pc.0.1575188915964.Z0FBQUFBQmQ0M216SGgtVk13S00zSHhSM1pBOWlWLXlCZHNIRGlOQms1Tk9wTDhSMmh2amRLS2MyelJLU1habGljc3lRUTFKeWRlR0MzbndpSkJhendXS1NobXJSYkY4YWdfdEFYYm5JZ2FJd2tZdUdFdXNxeEZpTFI3Y1ZFR0ZKSFJnOGdjemFEVDY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:35 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "593.0" + ], + "x-ratelimit-reset": [ + "85" + ], + "x-ratelimit-used": [ + "7" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason_invalid.json b/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason_invalid.json new file mode 100644 index 0000000000..f361471e0c --- /dev/null +++ b/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason_invalid.json @@ -0,0 +1,226 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:28:37", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:37 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=fkIj3GtESrMJQ23N82; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21947-LGA" + ], + "X-Timer": [ + "S1575188917.001314,VS0,VE369" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:28:37", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t3_e4ds11&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "37" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=fkIj3GtESrMJQ23N82" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:37 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21949-LGA" + ], + "X-Timer": [ + "S1575188917.454246,VS0,VE259" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M20xaC1OUVNTVnE5UEJkcHBncXlTdzZQYmlFTTJCdnFYRWQyLUptc2RfRW9Ja2lSeHVKNE5FQmF5UG43QXRlRmo2WVNlRURmWWtpbTNEd0VFMjNBS0VUQktBdHdZVkp5cGR0TUxpOEhuUnBRZ2RjRWlCSndGOTdSSDFXaGo0eFpxS0g; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:28:37 GMT; secure", + "session_tracker=LZt0xbOkj1Ql89qOjz.0.1575188917496.Z0FBQUFBQmQ0M20xdWUzbVBBZk5NNThqOFozeGlhdTlnQzNrbzJmaU9NTkZDV2Zicl9QN2J3dU9wck5WQ08yRm5mdkJxb0ZNNlhfOUllN2dlWGdFQzRxalRmMUtoNzk1S0NvQzUxTzVjdUxxbERySE9nOVFhQk5heVhXY29JWm9qWE9iSEpWc1VSNEM; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:37 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "590.0" + ], + "x-ratelimit-reset": [ + "83" + ], + "x-ratelimit-used": [ + "10" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason_without_id.json b/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason_without_id.json new file mode 100644 index 0000000000..a7ad902878 --- /dev/null +++ b/tests/integration/cassettes/TestSubmissionModeration.test_add_removal_reason_without_id.json @@ -0,0 +1,342 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:28:36", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:36 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=mTqIrvXE3jftXgmR7I; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21939-LGA" + ], + "X-Timer": [ + "S1575188916.101573,VS0,VE428" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:28:36", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t3_e3om6k&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "37" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=mTqIrvXE3jftXgmR7I" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:36 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21922-LGA" + ], + "X-Timer": [ + "S1575188917.601404,VS0,VE226" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M20wR2hLeEg5bDdCZTVMRy1nckp1Qi1oOWoyWlBycmZxdndkV1RtaUJIWWNXY0dTSndqdGlZN3gyRVNuUVJpRjZKZFVxZy1aNTEwQTF6dEFBM3dCOXN1N0s2SWU2aEpTbmR6VUZ4bnVwYjdNVk9pcGlXSk1uLWdwZ2t4TnhKOWhtTkY; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:28:36 GMT; secure", + "session_tracker=YIWezvZht7zK0Zn2Ui.0.1575188916624.Z0FBQUFBQmQ0M20wUl83MEYtbm1TMWY0ZXB0YlloMFN4VUhuVlAwck45cGpxeE1jeWhScE8yb3kxcWRZQkdfMmhKZ3F4Q3FFT3ZHaFVQc1RMQ21JWWtGT2NpTGc3bkhyT1RUckE0ZnBNUWNOcTgyM3FCSDh5QWhpSnlZTTZ4RWdtRExhWmJXS2ZCOF8; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:36 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "592.0" + ], + "x-ratelimit-reset": [ + "84" + ], + "x-ratelimit-used": [ + "8" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + }, + { + "recorded_at": "2019-12-01T08:28:36", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&json=%7B%22item_ids%22%3A+%5B%22t3_e3om6k%22%5D%2C+%22mod_note%22%3A+%22Foobar%22%2C+%22reason_id%22%3A+null%7D" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "125" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=mTqIrvXE3jftXgmR7I; loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0M20wR2hLeEg5bDdCZTVMRy1nckp1Qi1oOWoyWlBycmZxdndkV1RtaUJIWWNXY0dTSndqdGlZN3gyRVNuUVJpRjZKZFVxZy1aNTEwQTF6dEFBM3dCOXN1N0s2SWU2aEpTbmR6VUZ4bnVwYjdNVk9pcGlXSk1uLWdwZ2t4TnhKOWhtTkY; session_tracker=YIWezvZht7zK0Zn2Ui.0.1575188916624.Z0FBQUFBQmQ0M20wUl83MEYtbm1TMWY0ZXB0YlloMFN4VUhuVlAwck45cGpxeE1jeWhScE8yb3kxcWRZQkdfMmhKZ3F4Q3FFT3ZHaFVQc1RMQ21JWWtGT2NpTGc3bkhyT1RUckE0ZnBNUWNOcTgyM3FCSDh5QWhpSnlZTTZ4RWdtRExhWmJXS2ZCOF8" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:28:36 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21922-LGA" + ], + "X-Timer": [ + "S1575188917.861403,VS0,VE55" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=YIWezvZht7zK0Zn2Ui.0.1575188916892.Z0FBQUFBQmQ0M20wR19OS0N2ZHJORGprVjNaQkpHdXVSYWVqOG1GWG9sdENJU3JCZDRXS1M4dS1FUXhyci1UQTRrc2h6THh0VmVOWDg2bjlWOW5pdFZsb3JSVFROcEJkSTdHMnVlZDZCeGNvVFVXNFN5dElJRmhLdHc5cS1RR1NRekw1UmpTSXY1WTU; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:28:36 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "591.0" + ], + "x-ratelimit-reset": [ + "84" + ], + "x-ratelimit-used": [ + "9" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubmissionModeration.test_remove_with_reason_id.json b/tests/integration/cassettes/TestSubmissionModeration.test_remove_with_reason_id.json new file mode 100644 index 0000000000..38d4b3afb9 --- /dev/null +++ b/tests/integration/cassettes/TestSubmissionModeration.test_remove_with_reason_id.json @@ -0,0 +1,342 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T07:22:15", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:22:15 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=olwmM9qAPHKIUFHpBd; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21937-LGA" + ], + "X-Timer": [ + "S1575184935.793196,VS0,VE377" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T07:22:15", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t3_e3op46&spam=False" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "37" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=olwmM9qAPHKIUFHpBd" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/remove/?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:22:15 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21933-LGA" + ], + "X-Timer": [ + "S1575184935.278342,VS0,VE193" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0Mm9uRmxPV1A3NF9WMmcyYXA1ODZHQ0p4cjRFckR6QzBVbzROR0FEa29wQzBQc3JtenRQS3pxWXowSkJUQjZkb18tZF9qS2lSMVJCZlphamN4Nl9HZ1BTdDFmdjVTaTJzbHp0TlNsSjFJOGNEc2pVdHVJczN3OGJkYjhFcTdQYThaVWk; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 07:22:15 GMT; secure", + "session_tracker=PrjNjFucRwO4fIQz6C.0.1575184935306.Z0FBQUFBQmQ0Mm9uZzBPY29xUFVUd1AzSmNiWmpNUHpHRmM2RXlxNjc1djJsUnFFZGpRZmdCdU5mT2gyQjY3ejBRcV9Iekc5MXlscno3UWtNT2lLbGRibXZrOGlleHE3SmxuRHRrS041ZnVWZWdybG02YmEzeThDSklPX1puYnB3X25FckI3YXJ4Vzk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:22:15 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "597.0" + ], + "x-ratelimit-reset": [ + "465" + ], + "x-ratelimit-used": [ + "3" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/remove/?raw_json=1" + } + }, + { + "recorded_at": "2019-12-01T07:22:15", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&json=%7B%22item_ids%22%3A+%5B%22t3_e3op46%22%5D%2C+%22mod_note%22%3A+%22%22%2C+%22reason_id%22%3A+%22110nhral8vygf%22%7D" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "134" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=olwmM9qAPHKIUFHpBd; loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0Mm9uRmxPV1A3NF9WMmcyYXA1ODZHQ0p4cjRFckR6QzBVbzROR0FEa29wQzBQc3JtenRQS3pxWXowSkJUQjZkb18tZF9qS2lSMVJCZlphamN4Nl9HZ1BTdDFmdjVTaTJzbHp0TlNsSjFJOGNEc2pVdHVJczN3OGJkYjhFcTdQYThaVWk; session_tracker=PrjNjFucRwO4fIQz6C.0.1575184935306.Z0FBQUFBQmQ0Mm9uZzBPY29xUFVUd1AzSmNiWmpNUHpHRmM2RXlxNjc1djJsUnFFZGpRZmdCdU5mT2gyQjY3ejBRcV9Iekc5MXlscno3UWtNT2lLbGRibXZrOGlleHE3SmxuRHRrS041ZnVWZWdybG02YmEzeThDSklPX1puYnB3X25FckI3YXJ4Vzk" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:22:15 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21933-LGA" + ], + "X-Timer": [ + "S1575184936.501954,VS0,VE69" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=PrjNjFucRwO4fIQz6C.0.1575184935543.Z0FBQUFBQmQ0Mm9uelhKRHM3eFJaQm9VZlRxWXRkSE9xTTRmQldJbEVZdjZqeHBBdXVVUUp6X0dlVnV0eF9JLXNyX0YwbDBqVUF2cm9UUUthRmd0ekhyZmN6SHd1RzZ2YWRXVGZpd2thbnN2Z0lLNzVTdzRSYzR2WWRxT1hERHpza0J1NzV6NzFIb0c; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:22:15 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "465" + ], + "x-ratelimit-used": [ + "4" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/modactions/removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditReasons.test__iter.json b/tests/integration/cassettes/TestSubredditReasons.test__iter.json new file mode 100644 index 0000000000..037d5bc2e2 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditReasons.test__iter.json @@ -0,0 +1,220 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T07:11:56", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:56 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=KWCKkWnTUR9IKoTpal; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21926-LGA" + ], + "X-Timer": [ + "S1575184316.132471,VS0,VE369" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T07:11:56", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=KWCKkWnTUR9IKoTpal" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"data\": {\"110nit79o5h3j\": {\"message\": \"It looks like you're looking for a ride to the forest, or looking to give someone a ride! Check out our [rideshare thread](https://www.reddit.com/r/ElectricForest/comments/8d65e7/the_relectricforest_2018_rideshare_thread/)\", \"id\": \"110nit79o5h3j\", \"title\": \"Rideshare\"}, \"12w9jt703c54s\": {\"message\": \"Please review our sidebar for the complete list of rules.\", \"id\": \"12w9jt703c54s\", \"title\": \"Generic\"}, \"110nhk2cgmaxy\": {\"message\": \"Rule 1 - Please use the search function as well as check out our [2018 Mega Post](https://www.reddit.com/r/ElectricForest/comments/7l599k/list_of_useful_posts/)\", \"id\": \"110nhk2cgmaxy\", \"title\": \"Search\"}, \"110nihwu2yodi\": {\"message\": \"Please do not post about sneaking in drugs, any illegal items, or any items against HQ's Guidelines.\", \"id\": \"110nihwu2yodi\", \"title\": \"Follow HQ Rules\"}, \"110niezjjw156\": {\"message\": \"This subreddit is not the place, please visit the [Knowledge Base Wiki](https://www.reddit.com/r/Drugs/wiki/knowledgebase) in /r/drugs. Some other helpful subreddits:\\n\\n* /r/reagenttesting\\n\\n* /r/psychonaut\", \"id\": \"110niezjjw156\", \"title\": \"Drugs\"}, \"110nhyk34m01d\": {\"message\": \"Rule 3 - No buying/selling/trading is allowed on our subreddit. If you are trying to give something away, please message the moderators first\\n\\nIf you are looking to buy or sell a ticket, please head on over to the [Official EF Ticket Exchange](https://www.electricforestfestival.com/tickets/wristband-exchange/)!\", \"id\": \"110nhyk34m01d\", \"title\": \"Buy/Sell\"}, \"110nil6tchrhg\": {\"message\": \"Rule 7 - Please follow general reddiquette.\\n\\nFor information regarding this and similar issues please see the sidebar. If you have any questions, [please feel free to message the mods](https://www.reddit.com/message/compose?to=%2Fr%2FElectricForest). Thank you!\", \"id\": \"110nil6tchrhg\", \"title\": \"Reddiquette\"}, \"110nib8nlsz79\": {\"message\": \"That\\u2019s not forest vibes, [fam.](https://media.giphy.com/media/12ClTeBg4yvkiI/200.gif)\", \"id\": \"110nib8nlsz79\", \"title\": \"Forest Vibes\"}, \"110niqgkuz8ab\": {\"message\": \"Welcome to attending the forest for the first time! Before you have quetions, here are two threads that will be of much help to you. \\n\\n* [Our Guide to EF](https://drive.google.com/file/d/0B0rIiDle2lgpOXFmZnJPTWVTeDQ/view)\\n* [List of Useful Posts](https://www.reddit.com/r/ElectricForest/comments/7l599k/list_of_useful_posts/)\\n\\nIf you still have questions, try using our search function or asking in our daily \\\"no dumb question\\\" thread and you will more than likely find the answer you're looking for!\", \"id\": \"110niqgkuz8ab\", \"title\": \"New to Forest\"}, \"110nhral8vygf\": {\"message\": \"Rule 2 - Be kind and respectful to others.\", \"id\": \"110nhral8vygf\", \"title\": \"Be Kind\"}}, \"order\": [\"110nhk2cgmaxy\", \"110nhral8vygf\", \"110nhyk34m01d\", \"110nib8nlsz79\", \"110niezjjw156\", \"110nihwu2yodi\", \"110nil6tchrhg\", \"110niqgkuz8ab\", \"110nit79o5h3j\", \"12w9jt703c54s\"]}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "2947" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:56 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21934-LGA" + ], + "X-Timer": [ + "S1575184317.577176,VS0,VE51" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0MmU4SVQzT0s0azVjU1hOZVZBcjl4OUo3aTRwLWJtVXFmZXdOd0dBZ0Itd1U1UEFFU3FwQjZJdzRSRFhaVGJPV2JDTkhvOTRxenptem9FV3dUNzhkbmZuSFRIaWFFc3cwQkxMRWFTM2pXelAzWkhVSnFzN0RDTmZIY2Y1SzNLOFVsTHI; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 07:11:56 GMT; secure", + "session_tracker=OXNi7dgfQk9MzdRiy7.0.1575184316604.Z0FBQUFBQmQ0MmU4N2ZuZWVxSEpLVE9QbEdoNEZaLWtJQTVkdlAzYl9DRmN4c3FXME0zVmxRel9MZGtCZkFyaFFMLWhWZkZUak5NdVBPSnJrd1ZQcWw0Ty1oUVRITFNMTjg1VVBsLUJXeGZwbEMtYVl2WGJSMzlBTE8wZkJ4LWNQbjZPMllTZDFKbWc; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:11:56 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "594.0" + ], + "x-ratelimit-reset": [ + "484" + ], + "x-ratelimit-used": [ + "6" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditReasons.test_add.json b/tests/integration/cassettes/TestSubredditReasons.test_add.json new file mode 100644 index 0000000000..eda26cdc6c --- /dev/null +++ b/tests/integration/cassettes/TestSubredditReasons.test_add.json @@ -0,0 +1,223 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T07:11:57", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:57 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=tgehSgdAdc6mLShs97; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21923-LGA" + ], + "X-Timer": [ + "S1575184317.718331,VS0,VE368" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T07:11:57", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&message=Test&title=test" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "37" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=tgehSgdAdc6mLShs97" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"id\": \"141z26rkjp1oa\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "23" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 07:11:57 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21947-LGA" + ], + "X-Timer": [ + "S1575184317.167050,VS0,VE56" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0MmU5X3RpbmFfeXN4NXZuejF2RDV5U0lIRkw3RXdJbDdaNjBTYi1lRWt4UE1KMlY1LUYwZWdQWjhXX0d6dDRXejEyaFRvdGRLMWZYTEVPbVpXX0E2emc5Wk5lSXlvNjFDXzYtOEc5c01Kdnd0aGNscm9nZlVfR082MzR6TkxWci1NRGg; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 07:11:57 GMT; secure", + "session_tracker=FU5xAtQsaGc8IBbmQp.0.1575184317193.Z0FBQUFBQmQ0MmU5TmlvRlMxRlh0NS1tNXBiOGh3X21JdDRpQ0NUM1IwUTBwMG5qOWh2YW5Wb2Y4X2RSam5kSmhFT1dHSl9kbjVqXzNLTWJ5c2hqMkp0Um9VaEcwS2RHQVp2TTdyM3JkLXRaSHpKN0dkYS1mZGNZSVNrNmlULXQ3cVpEZk5oYnFXMWQ; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 09:11:57 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "593.0" + ], + "x-ratelimit-reset": [ + "483" + ], + "x-ratelimit-used": [ + "7" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1//removal_reasons?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditReasons.test_delete.json b/tests/integration/cassettes/TestSubredditReasons.test_delete.json new file mode 100644 index 0000000000..5dae11447e --- /dev/null +++ b/tests/integration/cassettes/TestSubredditReasons.test_delete.json @@ -0,0 +1,220 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:54:23", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:54:23 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=BuYajQYukj5FfweQEo; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21933-LGA" + ], + "X-Timer": [ + "S1575190463.036720,VS0,VE435" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:54:23", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Cookie": [ + "edgebucket=BuYajQYukj5FfweQEo" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "DELETE", + "uri": "https://oauth.reddit.com/api/v1//removal_reasons/110ni21zo23ql?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:54:23 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21937-LGA" + ], + "X-Timer": [ + "S1575190464.560237,VS0,VE75" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0My1fcnlKTjN4d2lRWVhqQnd0bXJtS2FJc2hwWndFbHJiR2VKZ29zZlZFYi1JQ3JGUHlaVHYxUmVhbGRTelpTaGhyX29WNm1uT3RxdTMtQXB2bGlHLWJKT3NVZ191aXczMlZSWTZwTjE1eXpkOHJ5VDdJY3lwb1FhcGpoWUZWaGd6ZVY; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:54:23 GMT; secure", + "session_tracker=Bf9gP9w17IYSgMbDHU.0.1575190463584.Z0FBQUFBQmQ0My1fN0ptenE5UE5QYXMxa05FMm9OYnJfMzc5VmNDMDNpbXdCbjZtcktNNE1JM3pIQkpmV3RrRk9oZ0o3WjVFdWs3cFo0VUdQd3pLUkc2NkdJZjlQR1p3Wm1CQWExdEY0SGY1VFBXM3J0NUZMT1JOMUVIWFBEcFJHZkhYVEg4LTJKRFk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:54:23 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "337" + ], + "x-ratelimit-used": [ + "2" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1//removal_reasons/110ni21zo23ql?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/cassettes/TestSubredditReasons.test_update.json b/tests/integration/cassettes/TestSubredditReasons.test_update.json new file mode 100644 index 0000000000..7b67b85e5d --- /dev/null +++ b/tests/integration/cassettes/TestSubredditReasons.test_update.json @@ -0,0 +1,223 @@ +{ + "http_interactions": [ + { + "recorded_at": "2019-12-01T08:54:22", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "80" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"*\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "118" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:54:22 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=kzqm1Zpu3lp1sy2uc7; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21936-LGA" + ], + "X-Timer": [ + "S1575190462.340156,VS0,VE413" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2019-12-01T08:54:22", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&message=New+Message&title=PRAW+updated" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "52" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "edgebucket=kzqm1Zpu3lp1sy2uc7" + ], + "User-Agent": [ + " PRAW/6.4.1.dev0 prawcore/1.0.1" + ] + }, + "method": "PUT", + "uri": "https://oauth.reddit.com/api/v1//removal_reasons/110nhk2cgmaxy?raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sun, 01 Dec 2019 08:54:22 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Cache": [ + "MISS" + ], + "X-Cache-Hits": [ + "0" + ], + "X-Moose": [ + "majestic" + ], + "X-Served-By": [ + "cache-lga21938-LGA" + ], + "X-Timer": [ + "S1575190463.864550,VS0,VE77" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "loid=0000000000364wflpm.2.1549507701753.Z0FBQUFBQmQ0My0tRktMT1JSWTRVWmZrd1V3Y0VVM1Rmay1MZ3hWNnFqTlFjV1c4bDUzTDc5OU8wbmxXTThJMHVEX2RBWGVrT3c2RmRYcmdTa1Q1djBycFJxdWNQcVEzTk9yaGxYcHVLeVhUbENPMHlyNG9nU3dzSVpjWGVuMktyUnFiY1ZoYUJ1QTY; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Tue, 30-Nov-2021 08:54:22 GMT; secure", + "session_tracker=pLJazBmLugdGLHba0h.0.1575190462903.Z0FBQUFBQmQ0My0tdllSWWhQTk9mVHJGT0k2enFBbmNYR2U0d2lQUl9ndkc3ekxKekdDUjhVaHhvMnFxY3RfcEVoT01HLXBUY0V6aWlBSmtmVXNWWS1EWElESERrR1pBbHRRVVlYaHhFZkx4REtsc2ZkY3JZbTJZdDIwU3BxVG96UTJ0NHJQQXZBZ24; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sun, 01-Dec-2019 10:54:22 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "338" + ], + "x-ratelimit-used": [ + "1" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1//removal_reasons/110nhk2cgmaxy?raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} \ No newline at end of file diff --git a/tests/integration/models/reddit/test_comment.py b/tests/integration/models/reddit/test_comment.py index 1d94dcea42..0eed4b898e 100644 --- a/tests/integration/models/reddit/test_comment.py +++ b/tests/integration/models/reddit/test_comment.py @@ -286,11 +286,53 @@ def test_remove(self): with self.recorder.use_cassette("TestCommentModeration.test_remove"): self.reddit.comment("da2g5y6").mod.remove(spam=True) + @mock.patch("time.sleep", return_value=None) + def test_remove_with_reason_id(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestCommentModeration.test_remove_with_reason_id" + ): + self.reddit.comment("f3dm3b7").mod.remove( + reason_id="110nhral8vygf" + ) + 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_add_removal_reason(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestCommentModeration.test_add_removal_reason" + ): + comment = self.reddit.comment("f98ukt5") + comment.mod.remove() + comment.mod.add_removal_reason("110nhral8vygf", "Blah") + + @mock.patch("time.sleep", return_value=None) + def test_add_removal_reason_without_id(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestCommentModeration.test_add_removal_reason_without_id" + ): + comment = self.reddit.comment("f98ugot") + comment.mod.remove() + comment.mod.add_removal_reason(mod_note="Test") + + @mock.patch("time.sleep", return_value=None) + def test_add_removal_reason_without_id_or_note(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestCommentModeration.test_add_removal_reason_invalid" + ): + with pytest.raises(ValueError) as excinfo: + comment = self.reddit.comment("f9974ce") + comment.mod.remove() + comment.mod.add_removal_reason() + assert excinfo.value.args[0].startswith("mod_note cannot be blank") + @mock.patch("time.sleep", return_value=None) def test_send_removal_message(self, _): self.reddit.read_only = False diff --git a/tests/integration/models/reddit/test_reasons.py b/tests/integration/models/reddit/test_reasons.py new file mode 100644 index 0000000000..3ee379cbb7 --- /dev/null +++ b/tests/integration/models/reddit/test_reasons.py @@ -0,0 +1,71 @@ +from praw.exceptions import ClientException +from praw.models import Reason +import mock +import pytest + +from ... import IntegrationTest + + +class TestReason(IntegrationTest): + @property + def subreddit(self): + return self.reddit.subreddit(pytest.placeholders.test_subreddit) + + @mock.patch("time.sleep", return_value=None) + def test__fetch(self, _): + self.reddit.read_only = False + reason = self.subreddit.reasons["110nhral8vygf"] + with self.recorder.use_cassette("TestReason.test__fetch"): + assert reason.title.startswith("Be Kind") + + @mock.patch("time.sleep", return_value=None) + def test__fetch__invalid_reason(self, _): + self.reddit.read_only = False + reason = self.subreddit.reasons["invalid"] + with self.recorder.use_cassette( + "TestReason.test__fetch__invalid_reason" + ): + with pytest.raises(ClientException) as excinfo: + reason.title + assert str(excinfo.value) == ( + "/r/{} does not have the reason {}".format( + self.subreddit, "invalid" + ) + ) + + +class TestSubredditReasons(IntegrationTest): + @property + def subreddit(self): + return self.reddit.subreddit(pytest.placeholders.test_subreddit) + + @mock.patch("time.sleep", return_value=None) + def test__iter(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette("TestSubredditReasons.test__iter"): + count = 0 + for reason in self.subreddit.reasons: + assert isinstance(reason, Reason) + count += 1 + assert count > 0 + + @mock.patch("time.sleep", return_value=None) + def test_add(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette("TestSubredditReasons.test_add"): + reason = self.subreddit.reasons.add("test", "Test") + assert isinstance(reason, Reason) + + @mock.patch("time.sleep", return_value=None) + def test_update(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette("TestSubredditReasons.test_update"): + self.subreddit.reasons.update( + "110nhk2cgmaxy", "PRAW updated", "New Message" + ) + + @mock.patch("time.sleep", return_value=None) + def test_delete(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette("TestSubredditReasons.test_delete"): + self.subreddit.reasons.delete("110ni21zo23ql") diff --git a/tests/integration/models/reddit/test_submission.py b/tests/integration/models/reddit/test_submission.py index 40f870486f..f5049954d1 100644 --- a/tests/integration/models/reddit/test_submission.py +++ b/tests/integration/models/reddit/test_submission.py @@ -359,6 +359,50 @@ def test_remove(self): ): self.reddit.submission("4b536h").mod.remove(spam=True) + @mock.patch("time.sleep", return_value=None) + def test_remove_with_reason_id(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubmissionModeration.test_remove_with_reason_id" + ): + self.reddit.submission("e3op46").mod.remove( + reason_id="110nhral8vygf" + ) + + @mock.patch("time.sleep", return_value=None) + def test_add_removal_reason(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubmissionModeration.test_add_removal_reason" + ): + submission = Submission(self.reddit, "e3oo6a") + submission.mod.remove() + submission.mod.add_removal_reason( + "110nhral8vygf", mod_note="Foobar" + ) + + @mock.patch("time.sleep", return_value=None) + def test_add_removal_reason_without_id(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubmissionModeration.test_add_removal_reason_without_id" + ): + submission = Submission(self.reddit, "e3om6k") + submission.mod.remove() + submission.mod.add_removal_reason(mod_note="Foobar") + + @mock.patch("time.sleep", return_value=None) + def test_add_removal_reason_without_id_or_note(self, _): + self.reddit.read_only = False + with self.recorder.use_cassette( + "TestSubmissionModeration.test_add_removal_reason_invalid" + ): + with pytest.raises(ValueError) as excinfo: + submission = Submission(self.reddit, "e4ds11") + submission.mod.remove() + submission.mod.add_removal_reason() + assert excinfo.value.args[0].startswith("mod_note cannot be blank") + @mock.patch("time.sleep", return_value=None) def test_send_removal_message(self, _): self.reddit.read_only = False diff --git a/tests/unit/models/reddit/test_reasons.py b/tests/unit/models/reddit/test_reasons.py new file mode 100644 index 0000000000..248db2905c --- /dev/null +++ b/tests/unit/models/reddit/test_reasons.py @@ -0,0 +1,96 @@ +import pickle + +from praw.models import Subreddit, Reason +from praw.models.reddit.reasons import SubredditReasons + +from ... import UnitTest + + +class TestReason(UnitTest): + def test_equality(self): + reason1 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="x" + ) + reason2 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="2" + ) + reason3 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "b"), reason_id="1" + ) + reason4 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "A"), reason_id="x" + ) + reason5 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="X" + ) + reason6 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "b"), reason_id="x" + ) + assert reason1 == reason1 + assert reason1 == "x" + assert reason2 == reason2 + assert reason3 == reason3 + assert reason1 != reason2 + assert reason1 != reason3 + assert reason1 == reason4 + assert reason1 != reason5 + assert reason1 != reason6 + + def test__get(self): + subreddit = self.reddit.subreddit("a") + reason = subreddit.reasons["a"] + assert isinstance(reason, Reason) + + def test_hash(self): + reason1 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="x" + ) + reason2 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="2" + ) + reason3 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "b"), reason_id="1" + ) + reason4 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "A"), reason_id="x" + ) + reason5 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="X" + ) + reason6 = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "b"), reason_id="x" + ) + assert hash(reason1) == hash(reason1) + assert hash(reason2) == hash(reason2) + assert hash(reason3) == hash(reason3) + assert hash(reason1) != hash(reason2) + assert hash(reason1) != hash(reason3) + assert hash(reason1) == hash(reason4) + assert hash(reason1) != hash(reason5) + assert hash(reason1) != hash(reason6) + + def test_pickle(self): + reason = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="x" + ) + for level in range(pickle.HIGHEST_PROTOCOL + 1): + other = pickle.loads(pickle.dumps(reason, protocol=level)) + assert reason == other + + def test_repr(self): + reason = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="x" + ) + assert repr(reason) == ("Reason(id='x')") + + def test_str(self): + reason = Reason( + self.reddit, subreddit=Subreddit(self.reddit, "a"), reason_id="x" + ) + assert str(reason) == "x" + + +class TestSubredditReasons(UnitTest): + def test_repr(self): + sr = SubredditReasons(subreddit=Subreddit(self.reddit, "a")) + assert repr(sr) # assert it has some repr