Skip to content

Commit

Permalink
Sort praw.models.reddit.wikipage.WikiPage.edit arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jan 14, 2022
1 parent f7cdd9d commit f2c0e82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions praw/models/reddit/wikipage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import TYPE_CHECKING, Any, Dict, Generator, Iterator, Optional, Union

from ...const import API_PATH
from ...util import _deprecate_args
from ...util.cache import cachedproperty
from ..listing.generator import ListingGenerator
from .base import RedditBase
Expand Down Expand Up @@ -254,8 +255,11 @@ def _fetch(self):
self.__dict__.update(data)
self._fetched = True

def edit(self, content: str, reason: Optional[str] = None, **other_settings: Any):
"""Edit this WikiPage's contents.
@_deprecate_args("content", "reason")
def edit(
self, *, content: str, reason: Optional[str] = None, **other_settings: Any
):
"""Edit this wiki page's contents.
:param content: The updated Markdown content of the page.
:param reason: The reason for the revision.
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/models/reddit/test_wikipage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_edit(self):

self.reddit.read_only = False
with self.use_cassette():
page.edit("PRAW updated")
page.edit(content="PRAW updated")

def test_edit__usernotes(self):
subreddit = self.reddit.subreddit(pytest.placeholders.test_subreddit)
Expand All @@ -55,15 +55,15 @@ def test_edit__usernotes(self):
]
+ [{"placeholder": "<CONTENT>", "replace": large_content}]
):
page.edit(large_content)
page.edit(content=large_content)

def test_edit__with_reason(self):
subreddit = self.reddit.subreddit(pytest.placeholders.test_subreddit)
page = WikiPage(self.reddit, subreddit, "test")

self.reddit.read_only = False
with self.use_cassette():
page.edit("PRAW updated with reason", reason="PRAW testing")
page.edit(content="PRAW updated with reason", reason="PRAW testing")

def test_init__with_revision(self):
subreddit = self.reddit.subreddit(pytest.placeholders.test_subreddit)
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_revert_css_fail(self, _):
name="css-revert-fail",
image_path="tests/integration/files/icon.jpg",
)
page.edit("div {background: url(%%css-revert-fail%%)}")
page.edit(content="div {background: url(%%css-revert-fail%%)}")
revision_id = next(page.revisions(limit=1))["id"]
subreddit.stylesheet.delete_image("css-revert-fail")
with pytest.raises(Forbidden) as exc:
Expand Down

0 comments on commit f2c0e82

Please sign in to comment.