From 8e3d77798aa928e12c129681b4e4b8434298407a Mon Sep 17 00:00:00 2001 From: MaybeNetwork Date: Thu, 17 Jun 2021 20:02:09 -0400 Subject: [PATCH] Add read_all_messages and unblock_subreddit --- CHANGES.rst | 5 + docs/code_overview/other.rst | 3 +- docs/code_overview/other/inboxablemixin.rst | 5 + praw/endpoints.py | 2 + praw/models/inbox.py | 17 + praw/models/reddit/mixins/inboxable.py | 29 +- .../TestInbox.test_mark_all_read.json | 538 +++++++++++++++ .../TestMessage.test_unblock_subreddit.json | 648 ++++++++++++++++++ .../integration/models/reddit/test_message.py | 16 + tests/integration/models/test_inbox.py | 8 + 10 files changed, 1269 insertions(+), 2 deletions(-) create mode 100644 docs/code_overview/other/inboxablemixin.rst create mode 100644 tests/integration/cassettes/TestInbox.test_mark_all_read.json create mode 100644 tests/integration/cassettes/TestMessage.test_unblock_subreddit.json diff --git a/CHANGES.rst b/CHANGES.rst index 5d8eb2c354..4bee036570 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,11 @@ PRAW follows `semantic versioning `_. Unreleased ---------- +**Added** + +- :meth:`.Inbox.mark_all_read` to mark all messages as read with one API call. +- :meth:`.InboxableMixin.unblock_subreddit` to unblock a subreddit. + 7.3.0 (2021/06/17) ------------------ diff --git a/docs/code_overview/other.rst b/docs/code_overview/other.rst index 16ef47f1fb..65a97cfecc 100644 --- a/docs/code_overview/other.rst +++ b/docs/code_overview/other.rst @@ -39,8 +39,9 @@ them bound to an attribute of one of the PRAW models. other/commentmoderation other/fullnamemixin - other/submissionmoderation + other/inboxablemixin other/rulemoderation + other/submissionmoderation other/subredditmoderation other/subredditrulesmoderation other/subredditwidgetsmoderation diff --git a/docs/code_overview/other/inboxablemixin.rst b/docs/code_overview/other/inboxablemixin.rst new file mode 100644 index 0000000000..ba24b87929 --- /dev/null +++ b/docs/code_overview/other/inboxablemixin.rst @@ -0,0 +1,5 @@ +InboxableMixin +============== + +.. autoclass:: praw.models.reddit.mixins.InboxableMixin + :inherited-members: diff --git a/praw/endpoints.py b/praw/endpoints.py index 93d3798943..c90c03c614 100644 --- a/praw/endpoints.py +++ b/praw/endpoints.py @@ -137,6 +137,7 @@ "preferences": "api/v1/me/prefs", "quarantine_opt_in": "api/quarantine_optin", "quarantine_opt_out": "api/quarantine_optout", + "read_all_messages": "api/read_all_messages", "read_message": "api/read_message/", "removal_comment_message": "api/v1/modactions/removal_comment_message", "removal_link_message": "api/v1/modactions/removal_link_message", @@ -187,6 +188,7 @@ "suggested_sort": "api/set_suggested_sort/", "trophies": "api/v1/user/{user}/trophies", "trusted": "prefs/trusted", + "unblock_subreddit": "api/unblock_subreddit", "uncollapse": "api/uncollapse_message/", "unfriend": "r/{subreddit}/api/unfriend/", "unhide": "api/unhide/", diff --git a/praw/models/inbox.py b/praw/models/inbox.py index d752ca0045..f0a8a5a505 100644 --- a/praw/models/inbox.py +++ b/praw/models/inbox.py @@ -80,6 +80,23 @@ def comment_replies( self._reddit, API_PATH["comment_replies"], **generator_kwargs ) + def mark_all_read(self): + """Mark all messages as read with just one API call. + + Example usage: + + .. code-block:: python + + reddit.inbox.mark_all_read() + + .. note:: + + This method returns after Reddit acknowleges your request, instead of after + the request has been fulfilled. + + """ + self._reddit.post(API_PATH["read_all_messages"]) + def mark_read( self, items: List[Union["praw.models.Comment", "praw.models.Message"]] ): diff --git a/praw/models/reddit/mixins/inboxable.py b/praw/models/reddit/mixins/inboxable.py index 00090e800e..51d30141d6 100644 --- a/praw/models/reddit/mixins/inboxable.py +++ b/praw/models/reddit/mixins/inboxable.py @@ -72,7 +72,7 @@ def mark_read(self): :meth:`~.mark_unread` To mark the whole inbox as read with a single network request, use - :meth:`praw.models.Inbox.mark_read` + :meth:`praw.models.Inbox.mark_all_read` """ self._reddit.inbox.mark_read([self]) @@ -101,6 +101,33 @@ def mark_unread(self): """ self._reddit.inbox.mark_unread([self]) + def unblock_subreddit(self): + """Unblock a subreddit. + + .. note:: + + This method pertains only to objects which were retrieved via the inbox. + + For example, to unblock all blocked subreddits that you can find by going + through your inbox: + + .. code-block:: python + + from praw.models import SubredditMessage + + subs = set() + for item in reddit.inbox.messages(limit=None): + if isinstance(item, SubredditMessage): + if ( + item.subject == "[message from blocked subreddit]" + and str(item.subreddit) not in subs + ): + item.unblock_subreddit() + subs.add(str(item.subreddit)) + + """ + self._reddit.post(API_PATH["unblock_subreddit"], data={"id": self.fullname}) + def uncollapse(self): """Mark the item as uncollapsed. diff --git a/tests/integration/cassettes/TestInbox.test_mark_all_read.json b/tests/integration/cassettes/TestInbox.test_mark_all_read.json new file mode 100644 index 0000000000..1b18fdb1a4 --- /dev/null +++ b/tests/integration/cassettes/TestInbox.test_mark_all_read.json @@ -0,0 +1,538 @@ +{ + "http_interactions": [ + { + "recorded_at": "2021-06-16T03:50:03", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "152" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "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": [ + "close" + ], + "Content-Length": [ + "121" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 03:50:03 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=AyqtdsnSFobDh2iRHx; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "299" + ], + "x-ratelimit-reset": [ + "597" + ], + "x-ratelimit-used": [ + "1" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2021-06-16T03:50:04", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=AyqtdsnSFobDh2iRHx" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/message/inbox/?limit=2&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"kind\": \"Listing\", \"data\": {\"modhash\": null, \"dist\": 2, \"children\": [{\"kind\": \"t4\", \"data\": {\"first_message\": null, \"first_message_name\": null, \"subreddit\": \"\", \"likes\": null, \"replies\": \"\", \"author_fullname\": null, \"id\": \"1234567\", \"subject\": \"invitation to moderate /r/\", \"associated_awarding_id\": null, \"score\": 0, \"author\": null, \"num_comments\": null, \"parent_id\": null, \"subreddit_name_prefixed\": \"r/\", \"new\": false, \"type\": \"unknown\", \"body\": \"gadzooks! **you are invited to become a moderator** of [/r/: DR8](/r//about/moderators)!\\n\\n***to accept*, visit the [moderators page for /r/](/r//about/moderators) and click \\\"accept\\\".**\\n\\n*otherwise,* if you did not expect to receive this, you can simply ignore this invitation or report it.\", \"dest\": \"\", \"was_comment\": false, \"body_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Egadzooks! \\u003Cstrong\\u003Eyou are invited to become a moderator\\u003C/strong\\u003E of \\u003Ca href=\\\"/r//about/moderators\\\"\\u003E/r/: DR8\\u003C/a\\u003E!\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cstrong\\u003E\\u003Cem\\u003Eto accept\\u003C/em\\u003E, visit the \\u003Ca href=\\\"/r//about/moderators\\\"\\u003Emoderators page for /r/\\u003C/a\\u003E and click \\u0026quot;accept\\u0026quot;.\\u003C/strong\\u003E\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cem\\u003Eotherwise,\\u003C/em\\u003E if you did not expect to receive this, you can simply ignore this invitation or report it.\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"name\": \"t4_1234567\", \"created\": 1623824779.0, \"created_utc\": 1623795979.0, \"context\": \"\", \"distinguished\": \"moderator\"}}, {\"kind\": \"t4\", \"data\": {\"first_message\": null, \"first_message_name\": null, \"subreddit\": \"\", \"likes\": null, \"replies\": \"\", \"author_fullname\": null, \"id\": \"7654321\", \"subject\": \"invitation to moderate /r/\", \"associated_awarding_id\": null, \"score\": 0, \"author\": null, \"num_comments\": null, \"parent_id\": null, \"subreddit_name_prefixed\": \"r/\", \"new\": false, \"type\": \"unknown\", \"body\": \"gadzooks! **you are invited to become a moderator** of [/r/: DR6](/r//about/moderators)!\\n\\n***to accept*, visit the [moderators page for /r/](/r//about/moderators) and click \\\"accept\\\".**\\n\\n*otherwise,* if you did not expect to receive this, you can simply ignore this invitation or report it.\", \"dest\": \"\", \"was_comment\": false, \"body_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Egadzooks! \\u003Cstrong\\u003Eyou are invited to become a moderator\\u003C/strong\\u003E of \\u003Ca href=\\\"/r//about/moderators\\\"\\u003E/r/: DR6\\u003C/a\\u003E!\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cstrong\\u003E\\u003Cem\\u003Eto accept\\u003C/em\\u003E, visit the \\u003Ca href=\\\"/r//about/moderators\\\"\\u003Emoderators page for /r/\\u003C/a\\u003E and click \\u0026quot;accept\\u0026quot;.\\u003C/strong\\u003E\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cem\\u003Eotherwise,\\u003C/em\\u003E if you did not expect to receive this, you can simply ignore this invitation or report it.\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"name\": \"t4_7654321\", \"created\": 1623812528.0, \"created_utc\": 1623783728.0, \"context\": \"\", \"distinguished\": \"moderator\"}}], \"after\": \"t4_7654321\", \"before\": null}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3379" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 03:50:03 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=ihtesnogpqatafxakd.0.1623815403501.Z0FBQUFBQmd5WFRyN9RDeFlFRU1fSVF1U19EdldDS0VER1Fyb2EwXzd0WTl1c2IyQndaY0lkaWgxV3BnUlVzaFhwcUptY2RTZF9ZaGl0SWNROHFmQ3hTRDZUWEw5Q0tSemV4jkQzcHFGMUJBeEE0dW9NT0dPdWdV32d5MXhsNGxLdExqTGQxTy1DcXM; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 05:50:03 GMT; secure; SameSite=None; Secure", + "csv=1; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "597" + ], + "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/message/inbox/?limit=2&raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T03:50:04", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t4_1234567%2Ct4_7654321" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "40" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "csv=1; edgebucket=AyqtdsnSFobDh2iRHx; session_tracker=ihtesnogpqatafxakd.0.1623815403501.Z0FBQUFBQmd5WFRyN9RDeFlFRU1fSVF1U19EdldDS0VER1Fyb2EwXzd0WTl1c2IyQndaY0lkaWgxV3BnUlVzaFhwcUptY2RTZF9ZaGl0SWNROHFmQ3hTRDZUWEw5Q0tSemV4jkQzcHFGMUJBeEE0dW9NT0dPdWdV32d5MXhsNGxLdExqTGQxTy1DcXM" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/unread_message/?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": [ + "Wed, 16 Jun 2021 03:50:03 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=ihtesnogpqatafxakd.0.1623815403656.Z0FBQUFBQmd5WFRyUDFndmRlu3c0OUpTSWp4RTNZaWc3VU5DUnhwa0RKYpJOTS1tODEtTlZEcUQyU3U4rHlEMDRWakVKRlVYVEFyTzRWcXlBUXRfTG1fcGRtN29BdxlZYklGc1lCVWpfUXJLQ2V5OUMtaHNnR0QwTU9kT0J3TVRBd1g3cGFSWTUtQks; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 05:50:03 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "597" + ], + "x-ratelimit-used": [ + "2" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/unread_message/?raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T03:50:04", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "13" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "csv=1; edgebucket=AyqtdsnSFobDh2iRHx; session_tracker=ihtesnogpqatafxakd.0.1623815403656.Z0FBQUFBQmd5WFRyUDFndmRlu3c0OUpTSWp4RTNZaWc3VU5DUnhwa0RKYpJOTS1tODEtTlZEcUQyU3U4rHlEMDRWakVKRlVYVEFyTzRWcXlBUXRfTG1fcGRtN29BdxlZYklGc1lCVWpfUXJLQ2V5OUMtaHNnR0QwTU9kT0J3TVRBd1g3cGFSWTUtQks" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/read_all_messages?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": [ + "Wed, 16 Jun 2021 03:50:03 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=ihtesnogpqatafxakd.0.1623815403812.Z0FBQUFBQmd5WFRac0UxYlE1SGFvYmNHSnRPY2tCNHJJZ1JVQjJRaTF9UE9SbWxfTW1RaTBzUzNNOTVieVdId3lucmR4aEZSX1dXOEdGLU1ZZW9OeWxaUENuUFMwNllYYiVSblg4WlVjNElBS3opUEktcWFBWGhSeW1iQtRLVExCTzROcVlqcFlIZGk; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 05:50:03 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "597.0" + ], + "x-ratelimit-reset": [ + "597" + ], + "x-ratelimit-used": [ + "3" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 202, + "message": "Accepted" + }, + "url": "https://oauth.reddit.com/api/read_all_messages?raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T03:50:04", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "csv=1; edgebucket=AyqtdsnSFobDh2iRHx; session_tracker=ihtesnogpqatafxakd.0.1623815403812.Z0FBQUFBQmd5WFRac0UxYlE1SGFvYmNHSnRPY2tCNHJJZ1JVQjJRaTF9UE9SbWxfTW1RaTBzUzNNOTVieVdId3lucmR4aEZSX1dXOEdGLU1ZZW9OeWxaUENuUFMwNllYYiVSblg4WlVjNElBS3opUEktcWFBWGhSeW1iQtRLVExCTzROcVlqcFlIZGk" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/message/unread/?mark=False&limit=100&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"kind\": \"Listing\", \"data\": {\"modhash\": null, \"dist\": 0, \"children\": [], \"after\": null, \"before\": null}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "104" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 03:50:03 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=ihtesnogpqatafxakd.0.1623815403889.Z0FBQUFBQmd5WFRyOFZwaHJiSnZfxmFhM0NjLXZWYU5LUnNZdTFPc2xOb2VFVWdGN3FsbDhIRFIwljV4enpoNlh5QUNCeWlJb0lqdElvQVhiVEpNd25rTzF2LUtnU1k0RnlQSilQOXp2RzdxUEtsWmU2QmtLZERBWjRoQVRyR9RTWFVaTm9zTmhpZ3g; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 05:50:03 GMT; secure; SameSite=None; Secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "597" + ], + "x-ratelimit-used": [ + "4" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/message/unread/?mark=False&limit=100&raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} diff --git a/tests/integration/cassettes/TestMessage.test_unblock_subreddit.json b/tests/integration/cassettes/TestMessage.test_unblock_subreddit.json new file mode 100644 index 0000000000..763bcefdf8 --- /dev/null +++ b/tests/integration/cassettes/TestMessage.test_unblock_subreddit.json @@ -0,0 +1,648 @@ +{ + "http_interactions": [ + { + "recorded_at": "2021-06-16T00:11:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "grant_type=password&password=&username=" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "Basic " + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "152" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "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": [ + "close" + ], + "Content-Length": [ + "121" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 00:11:58 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=n9XVCmbR3ULpBqQ9k6; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "max-age=0, must-revalidate" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "299" + ], + "x-ratelimit-reset": [ + "482" + ], + "x-ratelimit-used": [ + "1" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "recorded_at": "2021-06-16T00:11:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "edgebucket=n9XVCmbR3ULpBqQ9k6" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/message/messages/?limit=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"kind\": \"Listing\", \"data\": {\"modhash\": null, \"dist\": null, \"children\": [{\"kind\": \"t4\", \"data\": {\"first_message\": null, \"first_message_name\": null, \"subreddit\": \"\", \"likes\": null, \"replies\": \"\", \"author_fullname\": null, \"id\": \"1234567\", \"subject\": \"invitation to moderate /r/\", \"associated_awarding_id\": null, \"score\": 0, \"author\": null, \"num_comments\": null, \"parent_id\": null, \"subreddit_name_prefixed\": \"r/\", \"new\": false, \"type\": \"unknown\", \"body\": \"gadzooks! **you are invited to become a moderator** of [/r/: DR8](/r//about/moderators)!\\n\\n***to accept*, visit the [moderators page for /r/](/r//about/moderators) and click \\\"accept\\\".**\\n\\n*otherwise,* if you did not expect to receive this, you can simply ignore this invitation or report it.\", \"dest\": \"\", \"was_comment\": false, \"body_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Egadzooks! \\u003Cstrong\\u003Eyou are invited to become a moderator\\u003C/strong\\u003E of \\u003Ca href=\\\"/r//about/moderators\\\"\\u003E/r/: DR8\\u003C/a\\u003E!\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cstrong\\u003E\\u003Cem\\u003Eto accept\\u003C/em\\u003E, visit the \\u003Ca href=\\\"/r//about/moderators\\\"\\u003Emoderators page for /r/\\u003C/a\\u003E and click \\u0026quot;accept\\u0026quot;.\\u003C/strong\\u003E\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cem\\u003Eotherwise,\\u003C/em\\u003E if you did not expect to receive this, you can simply ignore this invitation or report it.\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"name\": \"t4_1234567\", \"created\": 1623824779.0, \"created_utc\": 1623795979.0, \"context\": \"\", \"distinguished\": \"moderator\"}}], \"after\": \"t4_1234567\", \"before\": null}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "1687" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 00:11:58 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=lzyqvmmlrkgfwagxix.0.1623802318821.Z0FBQUFBQmd5VUhPbXYzV1kyVmFMRkdzRFNCcmFtSFhtSC1DazBQNkVUUDFSS1FeZ1NVd0I3VmliV3VXUTNYUXRJcDJSRnVsS2xiLX9Vd2NHRHRjNlVRSTNsMDJ2cEdBalJ4Yjm1dGwzMzJXdDJTck8tUzFOdDJwZwNVMS15VEJVZ0htQ3FQMnFFZEY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 02:11:58 GMT; secure; SameSite=None; Secure", + "csv=1; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "599.0" + ], + "x-ratelimit-reset": [ + "482" + ], + "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/message/messages/?limit=1&raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T00:11:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t4_1234567" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "27" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "csv=1; edgebucket=n9XVCmbR3ULpBqQ9k6; session_tracker=lzyqvmmlrkgfwagxix.0.1623802318821.Z0FBQUFBQmd5VUhPbXYzV1kyVmFMRkdzRFNCcmFtSFhtSC1DazBQNkVUUDFSS1FeZ1NVd0I3VmliV3VXUTNYUXRJcDJSRnVsS2xiLX9Vd2NHRHRjNlVRSTNsMDJ2cEdBalJ4Yjm1dGwzMzJXdDJTck8tUzFOdDJwZwNVMS15VEJVZ0htQ3FQMnFFZEY" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/block?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": [ + "Wed, 16 Jun 2021 00:11:58 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=lzyqvmmlrkgfwagxix.0.1623802318923.Z0FBQUFBQmd5VUhPWFpreURRQmtuamt4OXB2SjhUQlRFaDRrOEo5aEw5NHQtfGFhd3FZalJmODlsRFFrTDYyS1RvSzZ0NlBnVXptUEl4S1dpd1Q5RElicFM3cHUyTHhjTHRkWkJMdkg2bE9FaGk5QW9oTjY5OE1PMFlfN0FSS2h0VDVqR1JNLWZsWmU; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 02:11:58 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "598.0" + ], + "x-ratelimit-reset": [ + "482" + ], + "x-ratelimit-used": [ + "2" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/block?raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T00:11:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "csv=1; edgebucket=n9XVCmbR3ULpBqQ9k6; session_tracker=lzyqvmmlrkgfwagxix.0.1623802318923.Z0FBQUFBQmd5VUhPWFpreURRQmtuamt4OXB2SjhUQlRFaDRrOEo5aEw5NHQtfGFhd3FZalJmODlsRFFrTDYyS1RvSzZ0NlBnVXptUEl4S1dpd1Q5RElicFM3cHUyTHhjTHRkWkJMdkg2bE9FaGk5QW9oTjY5OE1PMFlfN0FSS2h0VDVqR1JNLWZsWmU" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/message/messages/?limit=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"kind\": \"Listing\", \"data\": {\"modhash\": null, \"dist\": null, \"children\": [{\"kind\": \"t4\", \"data\": {\"first_message\": null, \"first_message_name\": null, \"subreddit\": \"\", \"likes\": null, \"replies\": \"\", \"author_fullname\": null, \"id\": \"1234567\", \"subject\": \"[message from blocked subreddit]\", \"associated_awarding_id\": null, \"score\": 0, \"author\": null, \"num_comments\": null, \"parent_id\": null, \"subreddit_name_prefixed\": \"r/\", \"new\": false, \"type\": \"unknown\", \"body\": \"gadzooks! **you are invited to become a moderator** of [/r/: DR8](/r//about/moderators)!\\n\\n***to accept*, visit the [moderators page for /r/](/r//about/moderators) and click \\\"accept\\\".**\\n\\n*otherwise,* if you did not expect to receive this, you can simply ignore this invitation or report it.\", \"dest\": \"\", \"was_comment\": false, \"body_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Egadzooks! \\u003Cstrong\\u003Eyou are invited to become a moderator\\u003C/strong\\u003E of \\u003Ca href=\\\"/r//about/moderators\\\"\\u003E/r/: DR8\\u003C/a\\u003E!\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cstrong\\u003E\\u003Cem\\u003Eto accept\\u003C/em\\u003E, visit the \\u003Ca href=\\\"/r//about/moderators\\\"\\u003Emoderators page for /r/\\u003C/a\\u003E and click \\u0026quot;accept\\u0026quot;.\\u003C/strong\\u003E\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cem\\u003Eotherwise,\\u003C/em\\u003E if you did not expect to receive this, you can simply ignore this invitation or report it.\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"name\": \"t4_1234567\", \"created\": 1623824779.0, \"created_utc\": 1623795979.0, \"context\": \"\", \"distinguished\": \"moderator\"}}], \"after\": \"t4_1234567\", \"before\": null}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "1690" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 00:11:59 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=lzyqvmmlrkgfwagxix.0.1623802318996.Z0FBQUFBQmd5VUhQZ3drb1pFd3RLcm9nYUpHdzFLN1ZudXZaMGRnRFhCZlV5ki1JR0ZzeHloazNYS2UwN29ZaEVEOFQwM1NQbS1WNjJGNGo1WDRIbXJNeG5ncy0yOUU1Qi1jdHNHOWZweVehSE96WVlSdXBlRWN5TndyNHBwRoAtdnFUcDIzVzJrZ2E; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 02:11:59 GMT; secure; SameSite=None; Secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "597.0" + ], + "x-ratelimit-reset": [ + "482" + ], + "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/message/messages/?limit=1&raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T00:11:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "api_type=json&id=t4_1234567" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "27" + ], + "Content-Type": [ + "application/x-www-form-urlencoded" + ], + "Cookie": [ + "csv=1; edgebucket=n9XVCmbR3ULpBqQ9k6; session_tracker=lzyqvmmlrkgfwagxix.0.1623802318996.Z0FBQUFBQmd5VUhQZ3drb1pFd3RLcm9nYUpHdzFLN1ZudXZaMGRnRFhCZlV5ki1JR0ZzeHloazNYS2UwN29ZaEVEOFQwM1NQbS1WNjJGNGo1WDRIbXJNeG5ncy0yOUU1Qi1jdHNHOWZweVehSE96WVlSdXBlRWN5TndyNHBwRoAtdnFUcDIzVzJrZ2E" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/unblock_subreddit?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": [ + "Wed, 16 Jun 2021 00:11:59 GMT" + ], + "Server": [ + "snooserv" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "set-cookie": [ + "session_tracker=lzyqvmmlrkgfwagxix.0.1623802319102.Z0FBQUFBQmd5VUhQWGlCQ201S3F2b1Y2NVhFMa0zZWVyWlNkenNRRl9WeWF0RlNZZkZldnlnZjlNQzJkOWlrOW1PUnNXQUNnSG5QZXNEQThlNGlhQm0xdDJSNWtKYnNVVWZvOFhUNqstOGI1NXhlWVAwb1UwNERaalfCSHZHSEIxcy1XVlVCcEh6cGY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 02:11:59 GMT; secure" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "596.0" + ], + "x-ratelimit-reset": [ + "481" + ], + "x-ratelimit-used": [ + "4" + ], + "x-ua-compatible": [ + "IE=edge" + ], + "x-xss-protection": [ + "1; mode=block" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/unblock_subreddit?raw_json=1" + } + }, + { + "recorded_at": "2021-06-16T00:11:59", + "request": { + "body": { + "encoding": "utf-8", + "string": "" + }, + "headers": { + "Accept": [ + "*/*" + ], + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Connection": [ + "keep-alive" + ], + "Cookie": [ + "csv=1; edgebucket=n9XVCmbR3ULpBqQ9k6; session_tracker=lzyqvmmlrkgfwagxix.0.1623802319102.Z0FBQUFBQmd5VUhQWGlCQ201S3F2b1Y2NVhFMa0zZWVyWlNkenNRRl9WeWF0RlNZZkZldnlnZjlNQzJkOWlrOW1PUnNXQUNnSG5QZXNEQThlNGlhQm0xdDJSNWtKYnNVVWZvOFhUNqstOGI1NXhlWVAwb1UwNERaalfCSHZHSEIxcy1XVlVCcEh6cGY" + ], + "User-Agent": [ + " PRAW/7.2.1.dev0 prawcore/2.2.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/message/messages/?limit=1&raw_json=1" + }, + "response": { + "body": { + "encoding": "UTF-8", + "string": "{\"kind\": \"Listing\", \"data\": {\"modhash\": null, \"dist\": null, \"children\": [{\"kind\": \"t4\", \"data\": {\"first_message\": null, \"first_message_name\": null, \"subreddit\": \"\", \"likes\": null, \"replies\": \"\", \"author_fullname\": null, \"id\": \"1234567\", \"subject\": \"invitation to moderate /r/\", \"associated_awarding_id\": null, \"score\": 0, \"author\": null, \"num_comments\": null, \"parent_id\": null, \"subreddit_name_prefixed\": \"r/\", \"new\": false, \"type\": \"unknown\", \"body\": \"gadzooks! **you are invited to become a moderator** of [/r/: DR8](/r//about/moderators)!\\n\\n***to accept*, visit the [moderators page for /r/](/r//about/moderators) and click \\\"accept\\\".**\\n\\n*otherwise,* if you did not expect to receive this, you can simply ignore this invitation or report it.\", \"dest\": \"\", \"was_comment\": false, \"body_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Egadzooks! \\u003Cstrong\\u003Eyou are invited to become a moderator\\u003C/strong\\u003E of \\u003Ca href=\\\"/r//about/moderators\\\"\\u003E/r/: DR8\\u003C/a\\u003E!\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cstrong\\u003E\\u003Cem\\u003Eto accept\\u003C/em\\u003E, visit the \\u003Ca href=\\\"/r//about/moderators\\\"\\u003Emoderators page for /r/\\u003C/a\\u003E and click \\u0026quot;accept\\u0026quot;.\\u003C/strong\\u003E\\u003C/p\\u003E\\n\\n\\u003Cp\\u003E\\u003Cem\\u003Eotherwise,\\u003C/em\\u003E if you did not expect to receive this, you can simply ignore this invitation or report it.\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"name\": \"t4_1234567\", \"created\": 1623824779.0, \"created_utc\": 1623795979.0, \"context\": \"\", \"distinguished\": \"moderator\"}}], \"after\": \"t4_1234567\", \"before\": null}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "1687" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Wed, 16 Jun 2021 00:11:59 GMT" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=lzyqvmmlrkgfwagxix.0.1623802319231.Z0FBQUFBQmd5VUhQYmhkVUJHZTZSaUtqeGstSWYwflNGd0dRN3Rfa29uN3M3TFhnaktzdVo3OHw1WktzSFlSVVM1dm9KQkpNT3FNVGJZYUQ5NHRwVU5hc2hzSEd4U0pwVEZfjWhxaG9YTWliezlRUnZyYmNvUWRUSnktZ0Q0TFVlSVdzRGdMSXp6SmY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Wed, 16-Jun-2021 02:11:59 GMT; secure; SameSite=None; Secure" + ], + "Strict-Transport-Security": [ + "max-age=15552000; includeSubDomains; preload" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Clacks-Overhead": [ + "GNU Terry Pratchett" + ], + "X-Moose": [ + "majestic" + ], + "cache-control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate" + ], + "expires": [ + "-1" + ], + "x-content-type-options": [ + "nosniff" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "x-ratelimit-remaining": [ + "595.0" + ], + "x-ratelimit-reset": [ + "481" + ], + "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/message/messages/?limit=1&raw_json=1" + } + } + ], + "recorded_with": "betamax/0.8.1" +} diff --git a/tests/integration/models/reddit/test_message.py b/tests/integration/models/reddit/test_message.py index c11f1efb86..d0fee1be03 100644 --- a/tests/integration/models/reddit/test_message.py +++ b/tests/integration/models/reddit/test_message.py @@ -98,6 +98,22 @@ def test_reply(self, _): assert reply.body == "Message reply" assert reply.first_message_name == message.fullname + @mock.patch("time.sleep", return_value=None) + def test_unblock_subreddit(self, _): + self.reddit.read_only = False + with self.use_cassette(): + message1 = next(self.reddit.inbox.messages(limit=1)) + assert isinstance(message1, SubredditMessage) + message_fullname = message1.fullname + message1.block() + message2 = next(self.reddit.inbox.messages(limit=1)) + assert message2.fullname == message_fullname + assert message2.subject == "[message from blocked subreddit]" + message2.unblock_subreddit() + message3 = next(self.reddit.inbox.messages(limit=1)) + assert message3.fullname == message_fullname + assert message3.subject != "[message from blocked subreddit]" + class TestSubredditMessage(IntegrationTest): def test_mute(self): diff --git a/tests/integration/models/test_inbox.py b/tests/integration/models/test_inbox.py index d5d0fcf438..49ef5e6384 100644 --- a/tests/integration/models/test_inbox.py +++ b/tests/integration/models/test_inbox.py @@ -45,6 +45,14 @@ def test_comment_reply__refresh(self, _): comment.refresh() assert saved_id == comment.id + @mock.patch("time.sleep", return_value=None) + def test_mark_all_read(self, _): + self.reddit.read_only = False + with self.use_cassette(): + self.reddit.inbox.mark_unread(list(self.reddit.inbox.all(limit=2))) + self.reddit.inbox.mark_all_read() + assert not list(self.reddit.inbox.unread()) + @mock.patch("time.sleep", return_value=None) def test_mark_read(self, _): self.reddit.read_only = False