From 3ec77a55ce19ddaae0f8a094acff37a46d9c44de Mon Sep 17 00:00:00 2001 From: jkim423 Date: Tue, 28 Dec 2021 15:11:22 -0600 Subject: [PATCH] Add support for specifying layout upon create collection (cherry picked from commit praw-dev/praw@9cce27993443750b3529d03c32e2c7e70e1481c5) --- CHANGES.rst | 2 + asyncpraw/models/reddit/collections.py | 35 +- ...sModeration.test_create__empty_layout.json | 320 +++++++++++++++++ ...oderation.test_create__gallery_layout.json | 324 ++++++++++++++++++ ...oderation.test_create__invalid_layout.json | 324 ++++++++++++++++++ ...eration.test_create__lowercase_layout.json | 324 ++++++++++++++++++ ...nsModeration.test_create__none_layout.json | 320 +++++++++++++++++ ...deration.test_create__timeline_layout.json | 324 ++++++++++++++++++ .../models/reddit/test_collections.py | 107 +++++- 9 files changed, 2065 insertions(+), 15 deletions(-) create mode 100644 tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__empty_layout.json create mode 100644 tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__gallery_layout.json create mode 100644 tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__invalid_layout.json create mode 100644 tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__lowercase_layout.json create mode 100644 tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__none_layout.json create mode 100644 tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__timeline_layout.json diff --git a/CHANGES.rst b/CHANGES.rst index 42f7e0a8..2de8f381 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,8 @@ Unreleased - :meth:`.pin` to manage pinned submissions on the authenticated user's profile. - :meth:`.update_display_layout` to update the display layout of posts in a :class:`.Collection`. +- :meth:`.SubredditCollectionsModeration.create` keyword argument ``display_layout`` for + specifying a display layout when creating a :class:`.Collection`. **Changed** diff --git a/asyncpraw/models/reddit/collections.py b/asyncpraw/models/reddit/collections.py index 3fc200e5..95e34f2d 100644 --- a/asyncpraw/models/reddit/collections.py +++ b/asyncpraw/models/reddit/collections.py @@ -179,8 +179,8 @@ async def update_display_layout(self, display_layout: str): """Update the collection's display layout. :param display_layout: Either ``"TIMELINE"`` for events or discussions or - ``"GALLERY"`` for images or memes. Passing ``""`` or ``None`` will clear the - set layout and ``collection.display_layout`` will be ``None``, however, the + ``"GALLERY"`` for images or memes. Passing ``None`` will clear the set + layout and ``collection.display_layout`` will be ``None``, however, the collection will appear on Reddit as if ``display_layout`` is set to ``"TIMELINE"``. @@ -465,7 +465,9 @@ def __init__( super().__init__(reddit, _data) self.subreddit = subreddit - async def create(self, title: str, description: str): + async def create( + self, title: str, description: str, display_layout: Optional[str] = None + ): """Create a new :class:`.Collection`. The authenticated account must have appropriate moderator permissions in the @@ -473,6 +475,10 @@ async def create(self, title: str, description: str): :param title: The title of the collection, up to 300 characters. :param description: The description, up to 500 characters. + :param display_layout: Either ``"TIMELINE"`` for events or discussions or + ``"GALLERY"`` for images or memes. Passing ``""`` or ``None`` will make the + collection appear on Reddit as if this is set to ``"TIMELINE"`` (default: + ``None``). :returns: The newly created :class:`.Collection`. @@ -484,6 +490,16 @@ async def create(self, title: str, description: str): new_collection = await sub.collections.mod.create("Title", "desc") await new_collection.mod.add_post("bgibu9") + To specify the display layout as ``"GALLERY"`` when creating the collection: + + .. code-block:: python + + my_sub = await reddit.subreddit("test") + new_collection = await my_sub.collections.mod.create( + title="Title", description="desc", display_layout="GALLERY" + ) + await new_collection.mod.add_post("bgibu9") + .. seealso:: :meth:`~.CollectionModeration.delete` @@ -491,13 +507,16 @@ async def create(self, title: str, description: str): """ if not self.subreddit._fetched: await self.subreddit._fetch() + data = { + "sr_fullname": self.subreddit.fullname, + "title": title, + "description": description, + } + if display_layout: + data["display_layout"] = display_layout return await self._reddit.post( API_PATH["collection_create"], - data={ - "sr_fullname": self.subreddit.fullname, - "title": title, - "description": description, - }, + data=data, ) diff --git a/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__empty_layout.json b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__empty_layout.json new file mode 100644 index 00000000..6a03f1cd --- /dev/null +++ b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__empty_layout.json @@ -0,0 +1,320 @@ +{ + "interactions": [ + { + "request": { + "body": [ + [ + "grant_type", + "refresh_token" + ], + [ + "refresh_token", + "" + ] + ], + "headers": { + "AUTHORIZATION": [ + "Basic " + ], + "Accept-Encoding": [ + "identity" + ], + "Connection": [ + "close" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"\", \"scope\": \"account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "428" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:49 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=Tc6DuAQ9AdJJzJGHd6; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "299" + ], + "x-ratelimit-reset": [ + "251" + ], + "x-ratelimit-used": [ + "1" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "request": { + "body": null, + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "edgebucket=Tc6DuAQ9AdJJzJGHd6" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r//about/?raw_json=1" + }, + "response": { + "body": { + "string": "{\"kind\": \"t5\", \"data\": {\"user_flair_background_color\": null, \"submit_text_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Esubmit_text\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"restrict_posting\": true, \"user_is_banned\": false, \"free_form_reports\": false, \"wiki_enabled\": true, \"user_is_muted\": false, \"user_can_flair_in_sr\": true, \"display_name\": \"\", \"header_img\": \"https://b.thumbs.redditmedia.com/E4LN_I1u2bbhXabbPggf5iVku2j4J-5BFHvtB2stTJA.png\", \"title\": \"\", \"allow_galleries\": false, \"icon_size\": [256, 256], \"primary_color\": \"\", \"active_user_count\": 0, \"icon_img\": \"https://b.thumbs.redditmedia.com/9YfWue0XL2CLyD4j34JgSSdm3g-zUFcUcysD9zXV41s.jpg\", \"display_name_prefixed\": \"r/\", \"accounts_active\": 0, \"public_traffic\": false, \"subscribers\": 2, \"user_flair_richtext\": [], \"videostream_links_count\": 0, \"name\": \"t5_29ey0j\", \"quarantine\": false, \"hide_ads\": false, \"prediction_leaderboard_entry_type\": \"IN_FEED\", \"emojis_enabled\": false, \"advertiser_category\": \"\", \"public_description\": \"pub_desc\", \"comment_score_hide_mins\": 0, \"allow_predictions\": false, \"user_has_favorited\": false, \"user_flair_template_id\": null, \"community_icon\": \"\", \"banner_background_image\": \"https://styles.redditmedia.com/t5_29ey0j/styles/bannerBackgroundImage_vni73293e5a51.png?width=4000\\u0026s=5f74f9b38a3e8364a5b999e959ba0aa9726e2037\", \"original_content_tag_enabled\": false, \"community_reviewed\": false, \"submit_text\": \"submit_text\", \"description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Enew sidebar content\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"spoilers_enabled\": false, \"allow_talks\": false, \"header_size\": [300, 300], \"user_flair_position\": \"right\", \"all_original_content\": false, \"collections_enabled\": true, \"is_enrolled_in_new_modmail\": true, \"key_color\": \"\", \"event_posts_enabled\": true, \"can_assign_user_flair\": false, \"created\": 1575168181.0, \"wls\": null, \"show_media_preview\": true, \"submission_type\": \"any\", \"user_is_subscriber\": true, \"disable_contributor_requests\": false, \"allow_videogifs\": true, \"should_archive_posts\": false, \"user_flair_type\": \"text\", \"allow_polls\": true, \"collapse_deleted_comments\": true, \"coins\": 0, \"emojis_custom_size\": null, \"public_description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Epub_desc\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"allow_videos\": true, \"is_crosspostable_subreddit\": true, \"notification_level\": \"low\", \"can_assign_link_flair\": true, \"has_menu_widget\": false, \"accounts_active_is_fuzzed\": false, \"allow_prediction_contributors\": false, \"submit_text_label\": \"\", \"link_flair_position\": \"right\", \"user_sr_flair_enabled\": true, \"user_flair_enabled_in_sr\": true, \"allow_discovery\": true, \"accept_followers\": true, \"user_sr_theme_enabled\": false, \"link_flair_enabled\": true, \"subreddit_type\": \"public\", \"suggested_comment_sort\": \"top\", \"banner_img\": \"https://b.thumbs.redditmedia.com/UwKZ1FguKqLsZ-dVSM-D0-o2OJVyOWKw966EPKv5wKA.jpg\", \"user_flair_text\": null, \"banner_background_color\": \"\", \"show_media\": false, \"id\": \"29ey0j\", \"user_is_moderator\": true, \"over18\": false, \"header_title\": \"header text\", \"description\": \"new sidebar content\", \"submit_link_label\": \"\", \"user_flair_text_color\": null, \"restrict_commenting\": true, \"user_flair_css_class\": null, \"allow_images\": true, \"lang\": \"en\", \"whitelist_status\": null, \"url\": \"/r//\", \"created_utc\": 1575168181.0, \"banner_size\": [640, 192], \"mobile_banner_image\": \"\", \"user_is_contributor\": true, \"allow_predictions_tournament\": false}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3595" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:50 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGYyU3MzQ3k0VEN4NTJsaVgtUlU3QlpJV0w5TkRqem53NEtvdHpfV09ZZFhRSjM2Wk42Z3JVS2lNOXI5OGR2a2x2RHp4MENzeFhWMFJUSU1xb3RtdmIxeHptbmtOLXotanNIM1VYZjRKTVczMUVqTUdFVU5XNWVab094MnpvUHZ6eng; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 10-Jun-2024 20:15:50 GMT; secure; SameSite=None; Secure", + "session_tracker=nrpomcqamreqmkdioi.0.1654978550014.Z0FBQUFBQmlwUGYyWjdqeGlpdmFEV0d2ZEwxc0NXY2s3QTJZZzM5SFpxOXZIdTZJR1hheGZ5UVV6TU9PWk5sbmtKTkotVm92UGdNUmgxaFhzQUVab1BhYWlFZnVteGN1dy1SZG5abl9pcENMVEQ3cjIwOXU1R1k3YXBGcVk0VDJSNjNMZ0x1UUszbWM; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:50 GMT; secure; SameSite=None; Secure", + "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Tue, 10-Jun-2025 20:15:50 GMT; secure", + "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "276.0" + ], + "x-ratelimit-reset": [ + "250" + ], + "x-ratelimit-used": [ + "324" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r//about/?raw_json=1" + } + }, + { + "request": { + "body": [ + [ + "api_type", + "json" + ], + [ + "description", + "The description." + ], + [ + "sr_fullname", + "t5_29ey0j" + ], + [ + "title", + "The title!" + ] + ], + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "csv=2; edgebucket=Tc6DuAQ9AdJJzJGHd6; loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGYyU3MzQ3k0VEN4NTJsaVgtUlU3QlpJV0w5TkRqem53NEtvdHpfV09ZZFhRSjM2Wk42Z3JVS2lNOXI5OGR2a2x2RHp4MENzeFhWMFJUSU1xb3RtdmIxeHptbmtOLXotanNIM1VYZjRKTVczMUVqTUdFVU5XNWVab094MnpvUHZ6eng; redesign_optout=true; session_tracker=nrpomcqamreqmkdioi.0.1654978550014.Z0FBQUFBQmlwUGYyWjdqeGlpdmFEV0d2ZEwxc0NXY2s3QTJZZzM5SFpxOXZIdTZJR1hheGZ5UVV6TU9PWk5sbmtKTkotVm92UGdNUmgxaFhzQUVab1BhYWlFZnVteGN1dy1SZG5abl9pcENMVEQ3cjIwOXU1R1k3YXBGcVk0VDJSNjNMZ0x1UUszbWM" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + }, + "response": { + "body": { + "string": "{\"subreddit_id\": \"t5_29ey0j\", \"description\": \"The description.\", \"author_name\": \"\", \"collection_id\": \"5c385c38-9f4d-4c3c-8ca2-4a02416c244e\", \"display_layout\": null, \"permalink\": \"https://www.reddit.com/r//collection/5c385c38-9f4d-4c3c-8ca2-4a02416c244e\", \"link_ids\": [], \"title\": \"The title!\", \"created_at_utc\": 1654978550.238, \"author_id\": \"t2_o77bz\", \"last_update_utc\": 1654978550.238}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "407" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:50 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=nrpomcqamreqmkdioi.0.1654978550226.Z0FBQUFBQmlwUGYyMEFkcDlITWwyc2VSTHZVbWpNU3huM2YxTHNFTXd3UVZqWUl2Sllta2JRMjRRMmladmU5VXdZYmw0bndwZVlWRkVLdDZwa3czUHdJcVpweEVBNWF5OVlvTm1ZdElGWkl6Sm5xb3lBanBoUFNVWFRRSlNqUkVCY1ZEbGZ4VV9yVHE; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:50 GMT; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "275.0" + ], + "x-ratelimit-reset": [ + "250" + ], + "x-ratelimit-used": [ + "325" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + } + } + ], + "recorded_at": "2022-06-11T15:15:50", + "version": 1 +} diff --git a/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__gallery_layout.json b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__gallery_layout.json new file mode 100644 index 00000000..501b5b60 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__gallery_layout.json @@ -0,0 +1,324 @@ +{ + "interactions": [ + { + "request": { + "body": [ + [ + "grant_type", + "refresh_token" + ], + [ + "refresh_token", + "" + ] + ], + "headers": { + "AUTHORIZATION": [ + "Basic " + ], + "Accept-Encoding": [ + "identity" + ], + "Connection": [ + "close" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"\", \"scope\": \"account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "428" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:50 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=oKuIaAE0PXjm0mhR96; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "298" + ], + "x-ratelimit-reset": [ + "250" + ], + "x-ratelimit-used": [ + "2" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "request": { + "body": null, + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "edgebucket=oKuIaAE0PXjm0mhR96" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r//about/?raw_json=1" + }, + "response": { + "body": { + "string": "{\"kind\": \"t5\", \"data\": {\"user_flair_background_color\": null, \"submit_text_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Esubmit_text\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"restrict_posting\": true, \"user_is_banned\": false, \"free_form_reports\": false, \"wiki_enabled\": true, \"user_is_muted\": false, \"user_can_flair_in_sr\": true, \"display_name\": \"\", \"header_img\": \"https://b.thumbs.redditmedia.com/E4LN_I1u2bbhXabbPggf5iVku2j4J-5BFHvtB2stTJA.png\", \"title\": \"\", \"allow_galleries\": false, \"icon_size\": [256, 256], \"primary_color\": \"\", \"active_user_count\": 0, \"icon_img\": \"https://b.thumbs.redditmedia.com/9YfWue0XL2CLyD4j34JgSSdm3g-zUFcUcysD9zXV41s.jpg\", \"display_name_prefixed\": \"r/\", \"accounts_active\": 0, \"public_traffic\": false, \"subscribers\": 2, \"user_flair_richtext\": [], \"videostream_links_count\": 0, \"name\": \"t5_29ey0j\", \"quarantine\": false, \"hide_ads\": false, \"prediction_leaderboard_entry_type\": \"IN_FEED\", \"emojis_enabled\": false, \"advertiser_category\": \"\", \"public_description\": \"pub_desc\", \"comment_score_hide_mins\": 0, \"allow_predictions\": false, \"user_has_favorited\": false, \"user_flair_template_id\": null, \"community_icon\": \"\", \"banner_background_image\": \"https://styles.redditmedia.com/t5_29ey0j/styles/bannerBackgroundImage_vni73293e5a51.png?width=4000\\u0026s=5f74f9b38a3e8364a5b999e959ba0aa9726e2037\", \"original_content_tag_enabled\": false, \"community_reviewed\": false, \"submit_text\": \"submit_text\", \"description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Enew sidebar content\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"spoilers_enabled\": false, \"allow_talks\": false, \"header_size\": [300, 300], \"user_flair_position\": \"right\", \"all_original_content\": false, \"collections_enabled\": true, \"is_enrolled_in_new_modmail\": true, \"key_color\": \"\", \"event_posts_enabled\": true, \"can_assign_user_flair\": false, \"created\": 1575168181.0, \"wls\": null, \"show_media_preview\": true, \"submission_type\": \"any\", \"user_is_subscriber\": true, \"disable_contributor_requests\": false, \"allow_videogifs\": true, \"should_archive_posts\": false, \"user_flair_type\": \"text\", \"allow_polls\": true, \"collapse_deleted_comments\": true, \"coins\": 0, \"emojis_custom_size\": null, \"public_description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Epub_desc\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"allow_videos\": true, \"is_crosspostable_subreddit\": true, \"notification_level\": \"low\", \"can_assign_link_flair\": true, \"has_menu_widget\": false, \"accounts_active_is_fuzzed\": false, \"allow_prediction_contributors\": false, \"submit_text_label\": \"\", \"link_flair_position\": \"right\", \"user_sr_flair_enabled\": true, \"user_flair_enabled_in_sr\": true, \"allow_discovery\": true, \"accept_followers\": true, \"user_sr_theme_enabled\": false, \"link_flair_enabled\": true, \"subreddit_type\": \"public\", \"suggested_comment_sort\": \"top\", \"banner_img\": \"https://b.thumbs.redditmedia.com/UwKZ1FguKqLsZ-dVSM-D0-o2OJVyOWKw966EPKv5wKA.jpg\", \"user_flair_text\": null, \"banner_background_color\": \"\", \"show_media\": false, \"id\": \"29ey0j\", \"user_is_moderator\": true, \"over18\": false, \"header_title\": \"header text\", \"description\": \"new sidebar content\", \"submit_link_label\": \"\", \"user_flair_text_color\": null, \"restrict_commenting\": true, \"user_flair_css_class\": null, \"allow_images\": true, \"lang\": \"en\", \"whitelist_status\": null, \"url\": \"/r//\", \"created_utc\": 1575168181.0, \"banner_size\": [640, 192], \"mobile_banner_image\": \"\", \"user_is_contributor\": true, \"allow_predictions_tournament\": false}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3595" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:50 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGYyRXd1TXNJSTlxMksya29ZM21RNVVMSDI3cDk3VkQ1eHVjZlZaVmY4YTJpbVF4VnJOSHB1d0xMYW1vNk5YSlBsZndtUW5HOElnc2licUl0NUZWRHRzUTNGZXJLSUFxREJlVV81SGhzclNVUldFZEw4cEtEQXh0amtoSHNJR0hQZXg; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 10-Jun-2024 20:15:50 GMT; secure; SameSite=None; Secure", + "session_tracker=ibfehrrkknlcrcaigb.0.1654978550608.Z0FBQUFBQmlwUGYyd3NnN1hNWXhTamFNUEtOMlNkX2h2TGkyd1pNUGlla3F4dGRpM05zbVBPMzM3ekFnZDlvOGkzZHNPRHFVY3Z4dlRQLUZ5aW9JNERTbXZoZG5BaTRQT3haZkJCcTMxQm5nd2I2ODhrWlJ0Qm9ZbFdVVTJSeGJ2U2NSLV9PSkFkN3k; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:50 GMT; secure; SameSite=None; Secure", + "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Tue, 10-Jun-2025 20:15:50 GMT; secure", + "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "273.0" + ], + "x-ratelimit-reset": [ + "250" + ], + "x-ratelimit-used": [ + "327" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r//about/?raw_json=1" + } + }, + { + "request": { + "body": [ + [ + "api_type", + "json" + ], + [ + "description", + "The description." + ], + [ + "display_layout", + "GALLERY" + ], + [ + "sr_fullname", + "t5_29ey0j" + ], + [ + "title", + "The title!" + ] + ], + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "csv=2; edgebucket=oKuIaAE0PXjm0mhR96; loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGYyRXd1TXNJSTlxMksya29ZM21RNVVMSDI3cDk3VkQ1eHVjZlZaVmY4YTJpbVF4VnJOSHB1d0xMYW1vNk5YSlBsZndtUW5HOElnc2licUl0NUZWRHRzUTNGZXJLSUFxREJlVV81SGhzclNVUldFZEw4cEtEQXh0amtoSHNJR0hQZXg; redesign_optout=true; session_tracker=ibfehrrkknlcrcaigb.0.1654978550608.Z0FBQUFBQmlwUGYyd3NnN1hNWXhTamFNUEtOMlNkX2h2TGkyd1pNUGlla3F4dGRpM05zbVBPMzM3ekFnZDlvOGkzZHNPRHFVY3Z4dlRQLUZ5aW9JNERTbXZoZG5BaTRQT3haZkJCcTMxQm5nd2I2ODhrWlJ0Qm9ZbFdVVTJSeGJ2U2NSLV9PSkFkN3k" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + }, + "response": { + "body": { + "string": "{\"subreddit_id\": \"t5_29ey0j\", \"description\": \"The description.\", \"author_name\": \"\", \"collection_id\": \"23808694-f382-43dc-9a57-b0ea85b4290d\", \"display_layout\": \"GALLERY\", \"permalink\": \"https://www.reddit.com/r//collection/23808694-f382-43dc-9a57-b0ea85b4290d\", \"link_ids\": [], \"title\": \"The title!\", \"created_at_utc\": 1654978550.877, \"author_id\": \"t2_o77bz\", \"last_update_utc\": 1654978550.877}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "412" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:50 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=ibfehrrkknlcrcaigb.0.1654978550865.Z0FBQUFBQmlwUGYySE90d3V1ZFQ4d1M2cmt3YkIwSklkTTNpaXhDUW9pVmF3c1pmUDdhbExTbURmQ2h6cDdiNEtkTFZpWktSdEJvOGF1OUN1S21mdkpnZkY5Tm1PWE95U29Fa3MzZU9Ga3pLUFh3WUFIbkNSbE5zR2REeFR2aTB1U2tmNzNVdkIxdnc; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:50 GMT; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "272.0" + ], + "x-ratelimit-reset": [ + "250" + ], + "x-ratelimit-used": [ + "328" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + } + } + ], + "recorded_at": "2022-06-11T15:15:50", + "version": 1 +} diff --git a/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__invalid_layout.json b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__invalid_layout.json new file mode 100644 index 00000000..1cd88b0a --- /dev/null +++ b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__invalid_layout.json @@ -0,0 +1,324 @@ +{ + "interactions": [ + { + "request": { + "body": [ + [ + "grant_type", + "refresh_token" + ], + [ + "refresh_token", + "" + ] + ], + "headers": { + "AUTHORIZATION": [ + "Basic " + ], + "Accept-Encoding": [ + "identity" + ], + "Connection": [ + "close" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"\", \"scope\": \"account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "428" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:51 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=KRwuPXYHZ6aB94iVy4; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "297" + ], + "x-ratelimit-reset": [ + "249" + ], + "x-ratelimit-used": [ + "3" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "request": { + "body": null, + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "edgebucket=KRwuPXYHZ6aB94iVy4" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r//about/?raw_json=1" + }, + "response": { + "body": { + "string": "{\"kind\": \"t5\", \"data\": {\"user_flair_background_color\": null, \"submit_text_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Esubmit_text\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"restrict_posting\": true, \"user_is_banned\": false, \"free_form_reports\": false, \"wiki_enabled\": true, \"user_is_muted\": false, \"user_can_flair_in_sr\": true, \"display_name\": \"\", \"header_img\": \"https://b.thumbs.redditmedia.com/E4LN_I1u2bbhXabbPggf5iVku2j4J-5BFHvtB2stTJA.png\", \"title\": \"\", \"allow_galleries\": false, \"icon_size\": [256, 256], \"primary_color\": \"\", \"active_user_count\": 0, \"icon_img\": \"https://b.thumbs.redditmedia.com/9YfWue0XL2CLyD4j34JgSSdm3g-zUFcUcysD9zXV41s.jpg\", \"display_name_prefixed\": \"r/\", \"accounts_active\": 0, \"public_traffic\": false, \"subscribers\": 2, \"user_flair_richtext\": [], \"videostream_links_count\": 0, \"name\": \"t5_29ey0j\", \"quarantine\": false, \"hide_ads\": false, \"prediction_leaderboard_entry_type\": \"IN_FEED\", \"emojis_enabled\": false, \"advertiser_category\": \"\", \"public_description\": \"pub_desc\", \"comment_score_hide_mins\": 0, \"allow_predictions\": false, \"user_has_favorited\": false, \"user_flair_template_id\": null, \"community_icon\": \"\", \"banner_background_image\": \"https://styles.redditmedia.com/t5_29ey0j/styles/bannerBackgroundImage_vni73293e5a51.png?width=4000\\u0026s=5f74f9b38a3e8364a5b999e959ba0aa9726e2037\", \"original_content_tag_enabled\": false, \"community_reviewed\": false, \"submit_text\": \"submit_text\", \"description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Enew sidebar content\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"spoilers_enabled\": false, \"allow_talks\": false, \"header_size\": [300, 300], \"user_flair_position\": \"right\", \"all_original_content\": false, \"collections_enabled\": true, \"is_enrolled_in_new_modmail\": true, \"key_color\": \"\", \"event_posts_enabled\": true, \"can_assign_user_flair\": false, \"created\": 1575168181.0, \"wls\": null, \"show_media_preview\": true, \"submission_type\": \"any\", \"user_is_subscriber\": true, \"disable_contributor_requests\": false, \"allow_videogifs\": true, \"should_archive_posts\": false, \"user_flair_type\": \"text\", \"allow_polls\": true, \"collapse_deleted_comments\": true, \"coins\": 0, \"emojis_custom_size\": null, \"public_description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Epub_desc\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"allow_videos\": true, \"is_crosspostable_subreddit\": true, \"notification_level\": \"low\", \"can_assign_link_flair\": true, \"has_menu_widget\": false, \"accounts_active_is_fuzzed\": false, \"allow_prediction_contributors\": false, \"submit_text_label\": \"\", \"link_flair_position\": \"right\", \"user_sr_flair_enabled\": true, \"user_flair_enabled_in_sr\": true, \"allow_discovery\": true, \"accept_followers\": true, \"user_sr_theme_enabled\": false, \"link_flair_enabled\": true, \"subreddit_type\": \"public\", \"suggested_comment_sort\": \"top\", \"banner_img\": \"https://b.thumbs.redditmedia.com/UwKZ1FguKqLsZ-dVSM-D0-o2OJVyOWKw966EPKv5wKA.jpg\", \"user_flair_text\": null, \"banner_background_color\": \"\", \"show_media\": false, \"id\": \"29ey0j\", \"user_is_moderator\": true, \"over18\": false, \"header_title\": \"header text\", \"description\": \"new sidebar content\", \"submit_link_label\": \"\", \"user_flair_text_color\": null, \"restrict_commenting\": true, \"user_flair_css_class\": null, \"allow_images\": true, \"lang\": \"en\", \"whitelist_status\": null, \"url\": \"/r//\", \"created_utc\": 1575168181.0, \"banner_size\": [640, 192], \"mobile_banner_image\": \"\", \"user_is_contributor\": true, \"allow_predictions_tournament\": false}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3595" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:51 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGYzMERMTTVIYXVJNzZ3WHJiMmcxQWdSUU9wS3p0bmd0SGdCQnJsdEFFUUVkOUhMOVpSSGliM0ZfU0dkNk9SeVJPdVdveFBlbl90VW1zYjgwYmN5QzVLOEVIMl9DRzRJUW11S3hzaDU1WXlUcnM3SUxnd2RRbFBUSmNhUHE5SUtxdTc; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 10-Jun-2024 20:15:51 GMT; secure; SameSite=None; Secure", + "session_tracker=ipijekgepheergmmqd.0.1654978551385.Z0FBQUFBQmlwUGYzNTJfbDhnUUhwTnJmbjBXVllyUkl1RUkxbXlQM0lpeFVFbHR6Vm9PQUw3SUlYVmJ0UklXVzcweXdVLTNXR2I2YmdWX0Y3NFo1MllXUEZRZ2p5cmtZcEEzc3RCV3pOM3I4VDVMQWY4aVRYQXNXZW9SdUpleko1VkhKVWVZdjFoOUY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:51 GMT; secure; SameSite=None; Secure", + "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Tue, 10-Jun-2025 20:15:51 GMT; secure", + "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "271.0" + ], + "x-ratelimit-reset": [ + "249" + ], + "x-ratelimit-used": [ + "329" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r//about/?raw_json=1" + } + }, + { + "request": { + "body": [ + [ + "api_type", + "json" + ], + [ + "description", + "The description." + ], + [ + "display_layout", + "milk before cereal" + ], + [ + "sr_fullname", + "t5_29ey0j" + ], + [ + "title", + "The title!" + ] + ], + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "csv=2; edgebucket=KRwuPXYHZ6aB94iVy4; loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGYzMERMTTVIYXVJNzZ3WHJiMmcxQWdSUU9wS3p0bmd0SGdCQnJsdEFFUUVkOUhMOVpSSGliM0ZfU0dkNk9SeVJPdVdveFBlbl90VW1zYjgwYmN5QzVLOEVIMl9DRzRJUW11S3hzaDU1WXlUcnM3SUxnd2RRbFBUSmNhUHE5SUtxdTc; redesign_optout=true; session_tracker=ipijekgepheergmmqd.0.1654978551385.Z0FBQUFBQmlwUGYzNTJfbDhnUUhwTnJmbjBXVllyUkl1RUkxbXlQM0lpeFVFbHR6Vm9PQUw3SUlYVmJ0UklXVzcweXdVLTNXR2I2YmdWX0Y3NFo1MllXUEZRZ2p5cmtZcEEzc3RCV3pOM3I4VDVMQWY4aVRYQXNXZW9SdUpleko1VkhKVWVZdjFoOUY" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + }, + "response": { + "body": { + "string": "{\"json\": {\"errors\": [[\"INVALID_OPTION\", \"that option is not valid\", \"display_layout\"]]}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "88" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:51 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=ipijekgepheergmmqd.0.1654978551718.Z0FBQUFBQmlwUGYzOUp4U0Z0X3JNWlBMcGxTSXhqQ2kwUTVlVzhtRXZ6VkQ0Q1NEN0pqQUVjODRTdkJyTF9IWjJhYmJMQ2FQUExpV3pCVmpuLXF4N0cza2xndVVnLVJmeGdrYUpjdjVZams4dG81UDgxRGVVZndhXzhvMS15d3prYmgxRV9KQXhiOVM; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:51 GMT; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "270.0" + ], + "x-ratelimit-reset": [ + "249" + ], + "x-ratelimit-used": [ + "330" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + } + } + ], + "recorded_at": "2022-06-11T15:15:51", + "version": 1 +} diff --git a/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__lowercase_layout.json b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__lowercase_layout.json new file mode 100644 index 00000000..2520d26d --- /dev/null +++ b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__lowercase_layout.json @@ -0,0 +1,324 @@ +{ + "interactions": [ + { + "request": { + "body": [ + [ + "grant_type", + "refresh_token" + ], + [ + "refresh_token", + "" + ] + ], + "headers": { + "AUTHORIZATION": [ + "Basic " + ], + "Accept-Encoding": [ + "identity" + ], + "Connection": [ + "close" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"\", \"scope\": \"account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "428" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:16:18 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=YIG3KENVgdt4ebqw0t; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "295" + ], + "x-ratelimit-reset": [ + "222" + ], + "x-ratelimit-used": [ + "5" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "request": { + "body": null, + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "edgebucket=YIG3KENVgdt4ebqw0t" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r//about/?raw_json=1" + }, + "response": { + "body": { + "string": "{\"kind\": \"t5\", \"data\": {\"user_flair_background_color\": null, \"submit_text_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Esubmit_text\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"restrict_posting\": true, \"user_is_banned\": false, \"free_form_reports\": false, \"wiki_enabled\": true, \"user_is_muted\": false, \"user_can_flair_in_sr\": true, \"display_name\": \"\", \"header_img\": \"https://b.thumbs.redditmedia.com/E4LN_I1u2bbhXabbPggf5iVku2j4J-5BFHvtB2stTJA.png\", \"title\": \"\", \"allow_galleries\": false, \"icon_size\": [256, 256], \"primary_color\": \"\", \"active_user_count\": 0, \"icon_img\": \"https://b.thumbs.redditmedia.com/9YfWue0XL2CLyD4j34JgSSdm3g-zUFcUcysD9zXV41s.jpg\", \"display_name_prefixed\": \"r/\", \"accounts_active\": 0, \"public_traffic\": false, \"subscribers\": 2, \"user_flair_richtext\": [], \"videostream_links_count\": 0, \"name\": \"t5_29ey0j\", \"quarantine\": false, \"hide_ads\": false, \"prediction_leaderboard_entry_type\": \"IN_FEED\", \"emojis_enabled\": false, \"advertiser_category\": \"\", \"public_description\": \"pub_desc\", \"comment_score_hide_mins\": 0, \"allow_predictions\": false, \"user_has_favorited\": false, \"user_flair_template_id\": null, \"community_icon\": \"\", \"banner_background_image\": \"https://styles.redditmedia.com/t5_29ey0j/styles/bannerBackgroundImage_vni73293e5a51.png?width=4000\\u0026s=5f74f9b38a3e8364a5b999e959ba0aa9726e2037\", \"original_content_tag_enabled\": false, \"community_reviewed\": false, \"submit_text\": \"submit_text\", \"description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Enew sidebar content\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"spoilers_enabled\": false, \"allow_talks\": false, \"header_size\": [300, 300], \"user_flair_position\": \"right\", \"all_original_content\": false, \"collections_enabled\": true, \"is_enrolled_in_new_modmail\": true, \"key_color\": \"\", \"event_posts_enabled\": true, \"can_assign_user_flair\": false, \"created\": 1575168181.0, \"wls\": null, \"show_media_preview\": true, \"submission_type\": \"any\", \"user_is_subscriber\": true, \"disable_contributor_requests\": false, \"allow_videogifs\": true, \"should_archive_posts\": false, \"user_flair_type\": \"text\", \"allow_polls\": true, \"collapse_deleted_comments\": true, \"coins\": 0, \"emojis_custom_size\": null, \"public_description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Epub_desc\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"allow_videos\": true, \"is_crosspostable_subreddit\": true, \"notification_level\": \"low\", \"can_assign_link_flair\": true, \"has_menu_widget\": false, \"accounts_active_is_fuzzed\": false, \"allow_prediction_contributors\": false, \"submit_text_label\": \"\", \"link_flair_position\": \"right\", \"user_sr_flair_enabled\": true, \"user_flair_enabled_in_sr\": true, \"allow_discovery\": true, \"accept_followers\": true, \"user_sr_theme_enabled\": false, \"link_flair_enabled\": true, \"subreddit_type\": \"public\", \"suggested_comment_sort\": \"top\", \"banner_img\": \"https://b.thumbs.redditmedia.com/UwKZ1FguKqLsZ-dVSM-D0-o2OJVyOWKw966EPKv5wKA.jpg\", \"user_flair_text\": null, \"banner_background_color\": \"\", \"show_media\": false, \"id\": \"29ey0j\", \"user_is_moderator\": true, \"over18\": false, \"header_title\": \"header text\", \"description\": \"new sidebar content\", \"submit_link_label\": \"\", \"user_flair_text_color\": null, \"restrict_commenting\": true, \"user_flair_css_class\": null, \"allow_images\": true, \"lang\": \"en\", \"whitelist_status\": null, \"url\": \"/r//\", \"created_utc\": 1575168181.0, \"banner_size\": [640, 192], \"mobile_banner_image\": \"\", \"user_is_contributor\": true, \"allow_predictions_tournament\": false}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3595" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:16:18 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGdTNWgxLTFDenR2LTMxVmdueUk3eWNrUGxiMnBKcFBoZHk5RFVNbXM2M1B3MV9pcU5pU2dmLXdMc0U5dkhtSk8yTy01bXVPTkRzU3hiR2lER3VHTkRQRHVjYnJUWjFhaUdqNGlOTncycEM1dG9iV19Na3B4R05HbklYdUsweWJGZVg; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 10-Jun-2024 20:16:18 GMT; secure; SameSite=None; Secure", + "session_tracker=rriojijdlminkrhaqd.0.1654978578267.Z0FBQUFBQmlwUGdTb0p6bU5sYlJmSGh6eF9iZHBxZzZ3dWhEOXFfQmdrNFJLdEoxWnBwbm9HWlBaUEZpZTVFeXZzOHVINVQwZHUwSmZGZ3BGX0E1eTFQQjRTeEhxQVZaVzdDRS1qSV94TmZGVWZMbFdaUjl1dWtyZTZPYnVsV0ZGU2V1MXpWRWk3cXY; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:16:18 GMT; secure; SameSite=None; Secure", + "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Tue, 10-Jun-2025 20:16:18 GMT; secure", + "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "247.0" + ], + "x-ratelimit-reset": [ + "222" + ], + "x-ratelimit-used": [ + "353" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r//about/?raw_json=1" + } + }, + { + "request": { + "body": [ + [ + "api_type", + "json" + ], + [ + "description", + "The description." + ], + [ + "display_layout", + "gallery" + ], + [ + "sr_fullname", + "t5_29ey0j" + ], + [ + "title", + "The title!" + ] + ], + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "csv=2; edgebucket=YIG3KENVgdt4ebqw0t; loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGdTNWgxLTFDenR2LTMxVmdueUk3eWNrUGxiMnBKcFBoZHk5RFVNbXM2M1B3MV9pcU5pU2dmLXdMc0U5dkhtSk8yTy01bXVPTkRzU3hiR2lER3VHTkRQRHVjYnJUWjFhaUdqNGlOTncycEM1dG9iV19Na3B4R05HbklYdUsweWJGZVg; redesign_optout=true; session_tracker=rriojijdlminkrhaqd.0.1654978578267.Z0FBQUFBQmlwUGdTb0p6bU5sYlJmSGh6eF9iZHBxZzZ3dWhEOXFfQmdrNFJLdEoxWnBwbm9HWlBaUEZpZTVFeXZzOHVINVQwZHUwSmZGZ3BGX0E1eTFQQjRTeEhxQVZaVzdDRS1qSV94TmZGVWZMbFdaUjl1dWtyZTZPYnVsV0ZGU2V1MXpWRWk3cXY" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + }, + "response": { + "body": { + "string": "{\"json\": {\"errors\": [[\"INVALID_OPTION\", \"that option is not valid\", \"display_layout\"]]}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "88" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:16:18 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=rriojijdlminkrhaqd.0.1654978578425.Z0FBQUFBQmlwUGdTaXVPNmpvN294TDhKU2tjRjlvUHNJeUpGZzNiSWhVY0x0Ml90T0xIMW1yV2tqQjZHWTA2dWlURDRTZ0s3b2VDY3gtU1hac0JNMTdwMUNDTFp3RWplR3VKb3htZjNidGdrTUZZMlBKOUhZbDhlVWJyUEtJd3NmYjVnN2dMb1VmUV8; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:16:18 GMT; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "246.0" + ], + "x-ratelimit-reset": [ + "222" + ], + "x-ratelimit-used": [ + "354" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + } + } + ], + "recorded_at": "2022-06-11T15:16:18", + "version": 1 +} diff --git a/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__none_layout.json b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__none_layout.json new file mode 100644 index 00000000..c8f1ec26 --- /dev/null +++ b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__none_layout.json @@ -0,0 +1,320 @@ +{ + "interactions": [ + { + "request": { + "body": [ + [ + "grant_type", + "refresh_token" + ], + [ + "refresh_token", + "" + ] + ], + "headers": { + "AUTHORIZATION": [ + "Basic " + ], + "Accept-Encoding": [ + "identity" + ], + "Connection": [ + "close" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"\", \"scope\": \"account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "428" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:16:18 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=8Ecmg6GwBzioYwf7Ku; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "294" + ], + "x-ratelimit-reset": [ + "222" + ], + "x-ratelimit-used": [ + "6" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "request": { + "body": null, + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "edgebucket=8Ecmg6GwBzioYwf7Ku" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r//about/?raw_json=1" + }, + "response": { + "body": { + "string": "{\"kind\": \"t5\", \"data\": {\"user_flair_background_color\": null, \"submit_text_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Esubmit_text\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"restrict_posting\": true, \"user_is_banned\": false, \"free_form_reports\": false, \"wiki_enabled\": true, \"user_is_muted\": false, \"user_can_flair_in_sr\": true, \"display_name\": \"\", \"header_img\": \"https://b.thumbs.redditmedia.com/E4LN_I1u2bbhXabbPggf5iVku2j4J-5BFHvtB2stTJA.png\", \"title\": \"\", \"allow_galleries\": false, \"icon_size\": [256, 256], \"primary_color\": \"\", \"active_user_count\": 0, \"icon_img\": \"https://b.thumbs.redditmedia.com/9YfWue0XL2CLyD4j34JgSSdm3g-zUFcUcysD9zXV41s.jpg\", \"display_name_prefixed\": \"r/\", \"accounts_active\": 0, \"public_traffic\": false, \"subscribers\": 2, \"user_flair_richtext\": [], \"videostream_links_count\": 0, \"name\": \"t5_29ey0j\", \"quarantine\": false, \"hide_ads\": false, \"prediction_leaderboard_entry_type\": \"IN_FEED\", \"emojis_enabled\": false, \"advertiser_category\": \"\", \"public_description\": \"pub_desc\", \"comment_score_hide_mins\": 0, \"allow_predictions\": false, \"user_has_favorited\": false, \"user_flair_template_id\": null, \"community_icon\": \"\", \"banner_background_image\": \"https://styles.redditmedia.com/t5_29ey0j/styles/bannerBackgroundImage_vni73293e5a51.png?width=4000\\u0026s=5f74f9b38a3e8364a5b999e959ba0aa9726e2037\", \"original_content_tag_enabled\": false, \"community_reviewed\": false, \"submit_text\": \"submit_text\", \"description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Enew sidebar content\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"spoilers_enabled\": false, \"allow_talks\": false, \"header_size\": [300, 300], \"user_flair_position\": \"right\", \"all_original_content\": false, \"collections_enabled\": true, \"is_enrolled_in_new_modmail\": true, \"key_color\": \"\", \"event_posts_enabled\": true, \"can_assign_user_flair\": false, \"created\": 1575168181.0, \"wls\": null, \"show_media_preview\": true, \"submission_type\": \"any\", \"user_is_subscriber\": true, \"disable_contributor_requests\": false, \"allow_videogifs\": true, \"should_archive_posts\": false, \"user_flair_type\": \"text\", \"allow_polls\": true, \"collapse_deleted_comments\": true, \"coins\": 0, \"emojis_custom_size\": null, \"public_description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Epub_desc\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"allow_videos\": true, \"is_crosspostable_subreddit\": true, \"notification_level\": \"low\", \"can_assign_link_flair\": true, \"has_menu_widget\": false, \"accounts_active_is_fuzzed\": false, \"allow_prediction_contributors\": false, \"submit_text_label\": \"\", \"link_flair_position\": \"right\", \"user_sr_flair_enabled\": true, \"user_flair_enabled_in_sr\": true, \"allow_discovery\": true, \"accept_followers\": true, \"user_sr_theme_enabled\": false, \"link_flair_enabled\": true, \"subreddit_type\": \"public\", \"suggested_comment_sort\": \"top\", \"banner_img\": \"https://b.thumbs.redditmedia.com/UwKZ1FguKqLsZ-dVSM-D0-o2OJVyOWKw966EPKv5wKA.jpg\", \"user_flair_text\": null, \"banner_background_color\": \"\", \"show_media\": false, \"id\": \"29ey0j\", \"user_is_moderator\": true, \"over18\": false, \"header_title\": \"header text\", \"description\": \"new sidebar content\", \"submit_link_label\": \"\", \"user_flair_text_color\": null, \"restrict_commenting\": true, \"user_flair_css_class\": null, \"allow_images\": true, \"lang\": \"en\", \"whitelist_status\": null, \"url\": \"/r//\", \"created_utc\": 1575168181.0, \"banner_size\": [640, 192], \"mobile_banner_image\": \"\", \"user_is_contributor\": true, \"allow_predictions_tournament\": false}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3595" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:16:18 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGdTYy1jRU1vSlVlV0l0OXR4SkZEZmtFN1FsbzgyWUI2YWlmYXRBR2pCMTNySkJTckpPVXA4UDNEVVBENmx2Tk4tTGlrUnloUklBWTM1T1FwUEZocDNOMUdscWd1TEN0Y2pOSHZmdGtOaXhTMmNpMFpVdlI0VTAybHAzY2lBTnFRMko; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 10-Jun-2024 20:16:18 GMT; secure; SameSite=None; Secure", + "session_tracker=lhbbjomfpqdrghkhlo.0.1654978578788.Z0FBQUFBQmlwUGdTSkp4OUR1VHBHelNaUzFOUUIwOE1ZZ1RXT3FHS2lFWGVTbkdkbFhQNnF3OVpuT2lsN2MyRGhNVFl3YUFSYTNnbUIwTWFDOWc5bklsSFJrbkllWXZZazQ0S1ZtelROdkFfc2RQYVJER2ZKZHdSZ3A4QzMzb1FRRXJYWnRnQ1RQdWQ; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:16:18 GMT; secure; SameSite=None; Secure", + "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Tue, 10-Jun-2025 20:16:18 GMT; secure", + "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "245.0" + ], + "x-ratelimit-reset": [ + "222" + ], + "x-ratelimit-used": [ + "355" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r//about/?raw_json=1" + } + }, + { + "request": { + "body": [ + [ + "api_type", + "json" + ], + [ + "description", + "The description." + ], + [ + "sr_fullname", + "t5_29ey0j" + ], + [ + "title", + "The title!" + ] + ], + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "csv=2; edgebucket=8Ecmg6GwBzioYwf7Ku; loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGdTYy1jRU1vSlVlV0l0OXR4SkZEZmtFN1FsbzgyWUI2YWlmYXRBR2pCMTNySkJTckpPVXA4UDNEVVBENmx2Tk4tTGlrUnloUklBWTM1T1FwUEZocDNOMUdscWd1TEN0Y2pOSHZmdGtOaXhTMmNpMFpVdlI0VTAybHAzY2lBTnFRMko; redesign_optout=true; session_tracker=lhbbjomfpqdrghkhlo.0.1654978578788.Z0FBQUFBQmlwUGdTSkp4OUR1VHBHelNaUzFOUUIwOE1ZZ1RXT3FHS2lFWGVTbkdkbFhQNnF3OVpuT2lsN2MyRGhNVFl3YUFSYTNnbUIwTWFDOWc5bklsSFJrbkllWXZZazQ0S1ZtelROdkFfc2RQYVJER2ZKZHdSZ3A4QzMzb1FRRXJYWnRnQ1RQdWQ" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + }, + "response": { + "body": { + "string": "{\"subreddit_id\": \"t5_29ey0j\", \"description\": \"The description.\", \"author_name\": \"\", \"collection_id\": \"8cf8e092-7bdf-4171-af38-3c785317d287\", \"display_layout\": null, \"permalink\": \"https://www.reddit.com/r//collection/8cf8e092-7bdf-4171-af38-3c785317d287\", \"link_ids\": [], \"title\": \"The title!\", \"created_at_utc\": 1654978578.969, \"author_id\": \"t2_o77bz\", \"last_update_utc\": 1654978578.969}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "407" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:16:19 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=lhbbjomfpqdrghkhlo.0.1654978578955.Z0FBQUFBQmlwUGdTeWlzZzkyLWFOQ1dtV0dwaFJObkx6ZUFGMlNtRnZRdGxrbll2ZjZjaVJKQV93ZXAxeVQtUmt6ZlB6a0kzQjItM1FSa2ZCMnlLNVhKTS1WMWpfOUVkQ3czOF94SFd0el9rWXU2SUd5cjZKeWJqejRLZDdXUFpnSTdqMGxVanI4Wno; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:16:18 GMT; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "244.0" + ], + "x-ratelimit-reset": [ + "222" + ], + "x-ratelimit-used": [ + "356" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + } + } + ], + "recorded_at": "2022-06-11T15:16:18", + "version": 1 +} diff --git a/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__timeline_layout.json b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__timeline_layout.json new file mode 100644 index 00000000..b348e55f --- /dev/null +++ b/tests/integration/cassettes/TestSubredditCollectionsModeration.test_create__timeline_layout.json @@ -0,0 +1,324 @@ +{ + "interactions": [ + { + "request": { + "body": [ + [ + "grant_type", + "refresh_token" + ], + [ + "refresh_token", + "" + ] + ], + "headers": { + "AUTHORIZATION": [ + "Basic " + ], + "Accept-Encoding": [ + "identity" + ], + "Connection": [ + "close" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://www.reddit.com/api/v1/access_token" + }, + "response": { + "body": { + "string": "{\"access_token\": \"\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"refresh_token\": \"\", \"scope\": \"account creddits edit flair history identity livemanage modconfig modcontributors modflair modlog modmail modothers modposts modself modtraffic modwiki mysubreddits privatemessages read report save structuredstyles submit subscribe vote wikiedit wikiread\"}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, max-age=3600" + ], + "Connection": [ + "close" + ], + "Content-Length": [ + "428" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:52 GMT" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "edgebucket=ouQbS35FyxX3gcsIfs; Domain=reddit.com; Max-Age=63071999; Path=/; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "296" + ], + "x-ratelimit-reset": [ + "249" + ], + "x-ratelimit-used": [ + "4" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://www.reddit.com/api/v1/access_token" + } + }, + { + "request": { + "body": null, + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "edgebucket=ouQbS35FyxX3gcsIfs" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "GET", + "uri": "https://oauth.reddit.com/r//about/?raw_json=1" + }, + "response": { + "body": { + "string": "{\"kind\": \"t5\", \"data\": {\"user_flair_background_color\": null, \"submit_text_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Esubmit_text\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"restrict_posting\": true, \"user_is_banned\": false, \"free_form_reports\": false, \"wiki_enabled\": true, \"user_is_muted\": false, \"user_can_flair_in_sr\": true, \"display_name\": \"\", \"header_img\": \"https://b.thumbs.redditmedia.com/E4LN_I1u2bbhXabbPggf5iVku2j4J-5BFHvtB2stTJA.png\", \"title\": \"\", \"allow_galleries\": false, \"icon_size\": [256, 256], \"primary_color\": \"\", \"active_user_count\": 0, \"icon_img\": \"https://b.thumbs.redditmedia.com/9YfWue0XL2CLyD4j34JgSSdm3g-zUFcUcysD9zXV41s.jpg\", \"display_name_prefixed\": \"r/\", \"accounts_active\": 0, \"public_traffic\": false, \"subscribers\": 2, \"user_flair_richtext\": [], \"videostream_links_count\": 0, \"name\": \"t5_29ey0j\", \"quarantine\": false, \"hide_ads\": false, \"prediction_leaderboard_entry_type\": \"IN_FEED\", \"emojis_enabled\": false, \"advertiser_category\": \"\", \"public_description\": \"pub_desc\", \"comment_score_hide_mins\": 0, \"allow_predictions\": false, \"user_has_favorited\": false, \"user_flair_template_id\": null, \"community_icon\": \"\", \"banner_background_image\": \"https://styles.redditmedia.com/t5_29ey0j/styles/bannerBackgroundImage_vni73293e5a51.png?width=4000\\u0026s=5f74f9b38a3e8364a5b999e959ba0aa9726e2037\", \"original_content_tag_enabled\": false, \"community_reviewed\": false, \"submit_text\": \"submit_text\", \"description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Enew sidebar content\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"spoilers_enabled\": false, \"allow_talks\": false, \"header_size\": [300, 300], \"user_flair_position\": \"right\", \"all_original_content\": false, \"collections_enabled\": true, \"is_enrolled_in_new_modmail\": true, \"key_color\": \"\", \"event_posts_enabled\": true, \"can_assign_user_flair\": false, \"created\": 1575168181.0, \"wls\": null, \"show_media_preview\": true, \"submission_type\": \"any\", \"user_is_subscriber\": true, \"disable_contributor_requests\": false, \"allow_videogifs\": true, \"should_archive_posts\": false, \"user_flair_type\": \"text\", \"allow_polls\": true, \"collapse_deleted_comments\": true, \"coins\": 0, \"emojis_custom_size\": null, \"public_description_html\": \"\\u003C!-- SC_OFF --\\u003E\\u003Cdiv class=\\\"md\\\"\\u003E\\u003Cp\\u003Epub_desc\\u003C/p\\u003E\\n\\u003C/div\\u003E\\u003C!-- SC_ON --\\u003E\", \"allow_videos\": true, \"is_crosspostable_subreddit\": true, \"notification_level\": \"low\", \"can_assign_link_flair\": true, \"has_menu_widget\": false, \"accounts_active_is_fuzzed\": false, \"allow_prediction_contributors\": false, \"submit_text_label\": \"\", \"link_flair_position\": \"right\", \"user_sr_flair_enabled\": true, \"user_flair_enabled_in_sr\": true, \"allow_discovery\": true, \"accept_followers\": true, \"user_sr_theme_enabled\": false, \"link_flair_enabled\": true, \"subreddit_type\": \"public\", \"suggested_comment_sort\": \"top\", \"banner_img\": \"https://b.thumbs.redditmedia.com/UwKZ1FguKqLsZ-dVSM-D0-o2OJVyOWKw966EPKv5wKA.jpg\", \"user_flair_text\": null, \"banner_background_color\": \"\", \"show_media\": false, \"id\": \"29ey0j\", \"user_is_moderator\": true, \"over18\": false, \"header_title\": \"header text\", \"description\": \"new sidebar content\", \"submit_link_label\": \"\", \"user_flair_text_color\": null, \"restrict_commenting\": true, \"user_flair_css_class\": null, \"allow_images\": true, \"lang\": \"en\", \"whitelist_status\": null, \"url\": \"/r//\", \"created_utc\": 1575168181.0, \"banner_size\": [640, 192], \"mobile_banner_image\": \"\", \"user_is_contributor\": true, \"allow_predictions_tournament\": false}}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "3595" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:52 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGY0eWptcVV3TnJwWnNFUnpsQndvUzhVbmtBOW9WQ2ZyT0ZHTWtPSTFuSzlVRGJmVlI3VWpJUzZvOVFKeHhUa3NMN3RnY3FQa3lKVjZCZ01DXzh1XzB2Y2pDREpib2hjZVFrckFFQjI0X0tycGo1TEI5ZWJOcElKaGgzQTloMFJ1RmQ; Domain=reddit.com; Max-Age=63071999; Path=/; expires=Mon, 10-Jun-2024 20:15:52 GMT; secure; SameSite=None; Secure", + "session_tracker=fpkprkpajkrdcnnhpo.0.1654978552163.Z0FBQUFBQmlwUGY0b3hwT2tQTEF3T2VmNmlEN1pxNElLRjZ6cTN0ZFpHRVJlLTZXN0V0elBrZDZGYU1uT3Y1ckRBMkUweE9VRjNQQUw5ZVM3Qy02WnhQa3lqem5JMlpaU2c0MDlIcGpvRHhoZklXUTNiVjVNSjk0aWdTbVlYODh4ckJCdUVtRXRrVm4; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:52 GMT; secure; SameSite=None; Secure", + "redesign_optout=true; Domain=reddit.com; Max-Age=94607999; Path=/; expires=Tue, 10-Jun-2025 20:15:52 GMT; secure", + "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Vary": [ + "accept-encoding" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "269.0" + ], + "x-ratelimit-reset": [ + "248" + ], + "x-ratelimit-used": [ + "331" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/r//about/?raw_json=1" + } + }, + { + "request": { + "body": [ + [ + "api_type", + "json" + ], + [ + "description", + "The description." + ], + [ + "display_layout", + "TIMELINE" + ], + [ + "sr_fullname", + "t5_29ey0j" + ], + [ + "title", + "The title!" + ] + ], + "headers": { + "Accept-Encoding": [ + "identity" + ], + "Authorization": [ + "bearer " + ], + "Cookie": [ + "csv=2; edgebucket=ouQbS35FyxX3gcsIfs; loid=0000000000000o77bz.2.1434669370561.Z0FBQUFBQmlwUGY0eWptcVV3TnJwWnNFUnpsQndvUzhVbmtBOW9WQ2ZyT0ZHTWtPSTFuSzlVRGJmVlI3VWpJUzZvOVFKeHhUa3NMN3RnY3FQa3lKVjZCZ01DXzh1XzB2Y2pDREpib2hjZVFrckFFQjI0X0tycGo1TEI5ZWJOcElKaGgzQTloMFJ1RmQ; redesign_optout=true; session_tracker=fpkprkpajkrdcnnhpo.0.1654978552163.Z0FBQUFBQmlwUGY0b3hwT2tQTEF3T2VmNmlEN1pxNElLRjZ6cTN0ZFpHRVJlLTZXN0V0elBrZDZGYU1uT3Y1ckRBMkUweE9VRjNQQUw5ZVM3Qy02WnhQa3lqem5JMlpaU2c0MDlIcGpvRHhoZklXUTNiVjVNSjk0aWdTbVlYODh4ckJCdUVtRXRrVm4" + ], + "User-Agent": [ + " Async PRAW/7.5.1.dev0 asyncprawcore/2.3.0" + ] + }, + "method": "POST", + "uri": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + }, + "response": { + "body": { + "string": "{\"subreddit_id\": \"t5_29ey0j\", \"description\": \"The description.\", \"author_name\": \"\", \"collection_id\": \"0cf171d0-b404-4727-866e-287f40f37a8c\", \"display_layout\": \"TIMELINE\", \"permalink\": \"https://www.reddit.com/r//collection/0cf171d0-b404-4727-866e-287f40f37a8c\", \"link_ids\": [], \"title\": \"The title!\", \"created_at_utc\": 1654978552.327, \"author_id\": \"t2_o77bz\", \"last_update_utc\": 1654978552.327}" + }, + "headers": { + "Accept-Ranges": [ + "bytes" + ], + "Cache-Control": [ + "private, s-maxage=0, max-age=0, must-revalidate, no-store" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "413" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Sat, 11 Jun 2022 20:15:52 GMT" + ], + "Expires": [ + "-1" + ], + "NEL": [ + "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 0.05, \"failure_fraction\": 0.05}" + ], + "Report-To": [ + "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}" + ], + "Server": [ + "snooserv" + ], + "Set-Cookie": [ + "session_tracker=fpkprkpajkrdcnnhpo.0.1654978552314.Z0FBQUFBQmlwUGY0Mm1VaV85cERiYS0yU0VVZEc0bGt6U0hQekFmRnVDeG4yYzYtRGRKbF85OThhR3dlYUxPT2JYUmV2VnhYTEFSSDZkV1g2Smw2VzlwVjZPTGFCUU8zWk5QLVhGQjRzNmZxNS1haVRyMVdIaUJ4MW0yRF9IdllleGpQNTM5dmxYeDE; Domain=reddit.com; Max-Age=7199; Path=/; expires=Sat, 11-Jun-2022 22:15:52 GMT; secure" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubdomains" + ], + "Via": [ + "1.1 varnish" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "1; mode=block" + ], + "x-moose": [ + "majestic" + ], + "x-ratelimit-remaining": [ + "268.0" + ], + "x-ratelimit-reset": [ + "248" + ], + "x-ratelimit-used": [ + "332" + ], + "x-ua-compatible": [ + "IE=edge" + ] + }, + "status": { + "code": 200, + "message": "OK" + }, + "url": "https://oauth.reddit.com/api/v1/collections/create_collection?raw_json=1" + } + } + ], + "recorded_at": "2022-06-11T15:15:52", + "version": 1 +} diff --git a/tests/integration/models/reddit/test_collections.py b/tests/integration/models/reddit/test_collections.py index 8142b3dd..88f2c2b4 100644 --- a/tests/integration/models/reddit/test_collections.py +++ b/tests/integration/models/reddit/test_collections.py @@ -64,6 +64,7 @@ async def test_unfollow(self): class TestCollectionModeration(IntegrationTest): NONEMPTY_REAL_UUID = "3aa31024-711b-46b2-9514-3fd50619f6e8" + UPDATE_LAYOUT_UUID = "3aa31024-711b-46b2-9514-3fd50619f6e8" @mock.patch("asyncio.sleep", return_value=None) async def test_add_post(self, _): @@ -103,7 +104,9 @@ async def test_delete(self, _): subreddit = await self.reddit.subreddit( pytest.placeholders.test_subreddit, fetch=True ) - collection = await subreddit.collections.mod.create("Title", "") + collection = await subreddit.collections.mod.create( + "Title", "Description", "GALLERY" + ) await collection.mod.delete() @mock.patch("asyncio.sleep", return_value=None) @@ -147,7 +150,7 @@ async def test_update_description(self, _): @mock.patch("asyncio.sleep", return_value=None) async def test_update_display_layout__empty_string(self, _): self.reddit.read_only = False - uuid = "3aa31024-711b-46b2-9514-3fd50619f6e8" + uuid = self.UPDATE_LAYOUT_UUID empty_string = "" with self.use_cassette(): subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) @@ -160,7 +163,7 @@ async def test_update_display_layout__empty_string(self, _): @mock.patch("asyncio.sleep", return_value=None) async def test_update_display_layout__gallery(self, _): self.reddit.read_only = False - uuid = "3aa31024-711b-46b2-9514-3fd50619f6e8" + uuid = self.UPDATE_LAYOUT_UUID gallery_layout = "GALLERY" with self.use_cassette(): subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) @@ -172,7 +175,7 @@ async def test_update_display_layout__gallery(self, _): @mock.patch("asyncio.sleep", return_value=None) async def test_update_display_layout__invalid_layout(self, _): self.reddit.read_only = False - uuid = "3aa31024-711b-46b2-9514-3fd50619f6e8" + uuid = self.UPDATE_LAYOUT_UUID invalid_layout = "colossal atom cake" with self.use_cassette(): subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) @@ -185,7 +188,7 @@ async def test_update_display_layout__invalid_layout(self, _): @mock.patch("asyncio.sleep", return_value=None) async def test_update_display_layout__lowercase(self, _): self.reddit.read_only = False - uuid = "3aa31024-711b-46b2-9514-3fd50619f6e8" + uuid = self.UPDATE_LAYOUT_UUID lowercase_gallery_layout = "gallery" with self.use_cassette(): subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) @@ -198,7 +201,7 @@ async def test_update_display_layout__lowercase(self, _): @mock.patch("asyncio.sleep", return_value=None) async def test_update_display_layout__none(self, _): self.reddit.read_only = False - uuid = "3aa31024-711b-46b2-9514-3fd50619f6e8" + uuid = self.UPDATE_LAYOUT_UUID with self.use_cassette(): subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) collection = await subreddit.collections(uuid, fetch=False) @@ -209,7 +212,7 @@ async def test_update_display_layout__none(self, _): @mock.patch("asyncio.sleep", return_value=None) async def test_update_display_layout__timeline(self, _): self.reddit.read_only = False - uuid = "3aa31024-711b-46b2-9514-3fd50619f6e8" + uuid = self.UPDATE_LAYOUT_UUID timeline_layout = "TIMELINE" with self.use_cassette(): subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) @@ -268,3 +271,93 @@ async def test_create(self, _): assert collection.title == title assert collection.description == description assert len(collection) == 0 + + @mock.patch("asyncio.sleep", return_value=None) + async def test_create__empty_layout(self, _): + title = "The title!" + description = "The description." + layout = "" + self.reddit.read_only = False + with self.use_cassette(): + subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) + collection = await subreddit.collections.mod.create( + title, description, layout + ) + assert collection.title == title + assert collection.description == description + assert collection.display_layout is None + assert len(collection) == 0 + + @mock.patch("asyncio.sleep", return_value=None) + async def test_create__gallery_layout(self, _): + title = "The title!" + description = "The description." + layout = "GALLERY" + self.reddit.read_only = False + with self.use_cassette(): + subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) + collection = await subreddit.collections.mod.create( + title, description, layout + ) + assert collection.title == title + assert collection.description == description + assert collection.display_layout == layout + assert len(collection) == 0 + + @mock.patch("asyncio.sleep", return_value=None) + async def test_create__invalid_layout(self, _): + title = "The title!" + description = "The description." + layout = "milk before cereal" + self.reddit.read_only = False + with self.use_cassette(): + with pytest.raises(RedditAPIException): + subreddit = await self.reddit.subreddit( + pytest.placeholders.test_subreddit + ) + await subreddit.collections.mod.create(title, description, layout) + + @mock.patch("asyncio.sleep", return_value=None) + async def test_create__lowercase_layout(self, _): + title = "The title!" + description = "The description." + layout = "gallery" + self.reddit.read_only = False + with self.use_cassette(): + with pytest.raises(RedditAPIException): + subreddit = await self.reddit.subreddit( + pytest.placeholders.test_subreddit + ) + await subreddit.collections.mod.create(title, description, layout) + + @mock.patch("asyncio.sleep", return_value=None) + async def test_create__none_layout(self, _): + title = "The title!" + description = "The description." + layout = None + self.reddit.read_only = False + with self.use_cassette(): + subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) + collection = await subreddit.collections.mod.create( + title, description, layout + ) + assert collection.title == title + assert collection.description == description + assert collection.display_layout is None + assert len(collection) == 0 + + @mock.patch("asyncio.sleep", return_value=None) + async def test_create__timeline_layout(self, _): + title = "The title!" + description = "The description." + layout = "TIMELINE" + self.reddit.read_only = False + with self.use_cassette(): + subreddit = await self.reddit.subreddit(pytest.placeholders.test_subreddit) + collection = await subreddit.collections.mod.create( + title, description, layout + ) + assert collection.title == title + assert collection.description == description + assert collection.display_layout == layout + assert len(collection) == 0