-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to leverage PRAW8's ReadOnlyException in user.me
(cherry picked from commit bb0e00f7ec628f7dfcd0396f3da323c121f22aa1)
- Loading branch information
1 parent
9fdb7f7
commit f101446
Showing
4 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
import pytest | ||
|
||
from asyncpraw import Reddit | ||
from asyncpraw.exceptions import ReadOnlyException | ||
from asyncpraw.models import User | ||
|
||
from .. import UnitTest | ||
|
||
|
||
class TestUser(UnitTest): | ||
async def test_me__in_read_only_mode(self): | ||
self.reddit = Reddit( | ||
client_id="dummy", | ||
client_secret="dummy", | ||
praw8_raise_exception_on_me=True, | ||
user_agent="dummy", | ||
) | ||
self.reddit._core._requestor._http = None | ||
assert self.reddit.read_only | ||
user = User(self.reddit) | ||
assert await user.me() is None | ||
with pytest.raises(ReadOnlyException): | ||
await user.me() | ||
|
||
async def test_me__in_read_only_mode__deprecated(self): | ||
assert self.reddit.read_only | ||
assert await User(self.reddit).me() is None |