How to use the praw.models.Subreddit function in praw

To help you get started, we’ve selected a few praw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github praw-dev / praw / tests / unit / models / reddit / test_subreddit.py View on Github external
def test_equality(self):
        subreddit1 = Subreddit(
            self.reddit, _data={"display_name": "dummy1", "n": 1}
        )
        subreddit2 = Subreddit(
            self.reddit, _data={"display_name": "Dummy1", "n": 2}
        )
        subreddit3 = Subreddit(
            self.reddit, _data={"display_name": "dummy3", "n": 2}
        )
        assert subreddit1 == subreddit1
        assert subreddit2 == subreddit2
        assert subreddit3 == subreddit3
        assert subreddit1 == subreddit2
        assert subreddit2 != subreddit3
        assert subreddit1 != subreddit3
        assert "dummy1" == subreddit1
        assert subreddit2 == "dummy1"
github praw-dev / praw / tests / unit / models / reddit / test_emoji.py View on Github external
def test_hash(self):
        emoji1 = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="x"
        )
        emoji2 = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="2"
        )
        emoji3 = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "b"), name="1"
        )
        emoji4 = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "A"), name="x"
        )
        emoji5 = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="X"
        )
        emoji6 = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "b"), name="x"
        )
        assert hash(emoji1) == hash(emoji1)
        assert hash(emoji2) == hash(emoji2)
        assert hash(emoji3) == hash(emoji3)
        assert hash(emoji1) != hash(emoji2)
        assert hash(emoji1) != hash(emoji3)
        assert hash(emoji1) == hash(emoji4)
        assert hash(emoji1) != hash(emoji5)
        assert hash(emoji1) != hash(emoji6)
github praw-dev / praw / tests / unit / models / reddit / test_subreddit.py View on Github external
def test_hash(self):
        subreddit1 = Subreddit(
            self.reddit, _data={"display_name": "dummy1", "n": 1}
        )
        subreddit2 = Subreddit(
            self.reddit, _data={"display_name": "Dummy1", "n": 2}
        )
        subreddit3 = Subreddit(
            self.reddit, _data={"display_name": "dummy3", "n": 2}
        )
        assert hash(subreddit1) == hash(subreddit1)
        assert hash(subreddit2) == hash(subreddit2)
        assert hash(subreddit3) == hash(subreddit3)
        assert hash(subreddit1) == hash(subreddit2)
        assert hash(subreddit2) != hash(subreddit3)
        assert hash(subreddit1) != hash(subreddit3)
github praw-dev / praw / tests / unit / models / reddit / test_wikipage.py View on Github external
def test_equality(self):
        page1 = WikiPage(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="x"
        )
        page2 = WikiPage(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="2"
        )
        page3 = WikiPage(
            self.reddit, subreddit=Subreddit(self.reddit, "b"), name="1"
        )
        page4 = WikiPage(
            self.reddit, subreddit=Subreddit(self.reddit, "A"), name="x"
        )
        page5 = WikiPage(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="X"
        )
        assert page1 == page1
        assert page2 == page2
        assert page3 == page3
        assert page1 != page2
        assert page1 != page3
        assert page1 == page4
        assert page1 == page5
github praw-dev / praw / tests / unit / models / reddit / test_subreddit.py View on Github external
def test_upload_banner_additional_image(self):
        subreddit = Subreddit(self.reddit, display_name="name")
        with pytest.raises(ValueError):
            subreddit.stylesheet.upload_banner_additional_image(
                "dummy_path", align="asdf"
            )
github praw-dev / praw / tests / unit / models / reddit / test_subreddit.py View on Github external
def test_construct_failure(self):
        message = "Either `display_name` or `_data` must be provided."
        with pytest.raises(TypeError) as excinfo:
            Subreddit(self.reddit)
        assert str(excinfo.value) == message

        with pytest.raises(TypeError) as excinfo:
            Subreddit(self.reddit, "dummy", {"id": "dummy"})
        assert str(excinfo.value) == message
github praw-dev / praw / tests / unit / models / reddit / test_subreddit.py View on Github external
def test_fullname(self):
        subreddit = Subreddit(
            self.reddit, _data={"display_name": "name", "id": "dummy"}
        )
        assert subreddit.fullname == "t5_dummy"
github praw-dev / praw / tests / unit / models / reddit / test_emoji.py View on Github external
def test_pickle(self):
        emoji = Emoji(
            self.reddit, subreddit=Subreddit(self.reddit, "a"), name="x"
        )
        for level in range(pickle.HIGHEST_PROTOCOL + 1):
            other = pickle.loads(pickle.dumps(emoji, protocol=level))
            assert emoji == other
github praw-dev / praw / tests / unit / models / reddit / test_subreddit.py View on Github external
def test_construct_failure(self):
        message = "Either `display_name` or `_data` must be provided."
        with pytest.raises(TypeError) as excinfo:
            Subreddit(self.reddit)
        assert str(excinfo.value) == message

        with pytest.raises(TypeError) as excinfo:
            Subreddit(self.reddit, "dummy", {"id": "dummy"})
        assert str(excinfo.value) == message
github praw-dev / praw / tests / integration / models / test_user.py View on Github external
def test_karma(self):
        self.reddit.read_only = False
        with self.recorder.use_cassette("TestUser.test_karma"):
            karma = self.reddit.user.karma()
        assert isinstance(karma, dict)
        for subreddit in karma:
            assert isinstance(subreddit, Subreddit)
            keys = sorted(karma[subreddit].keys())
            assert ["comment_karma", "link_karma"] == keys