예제 #1
0
    def test_should_add_flair_to_comment_author(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        heatware.main()

        self._assert_flair_added_to_comment_author(mock_reddit_api, mock_comment)
예제 #2
0
    def test_should_add_flair_if_swapbot_has_not_already_replied_to_comment_but_someone_else_has(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        self._add_reply_to_comment(mock_comment, 'janedoe')

        heatware.main()

        self._assert_flair_added_to_comment_author(mock_reddit_api, mock_comment)
예제 #3
0
    def test_should_not_add_flair_if_swapbot_has_already_replied_to_comment(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        self._add_swapbot_reply_to_comment(mock_comment)

        heatware.main()

        self._assert_flair_not_added_to_author(mock_reddit_api)
예제 #4
0
    def test_should_not_add_flair_if_author_attribute_is_empty(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        mock_comment.author = None

        heatware.main()

        self._assert_flair_not_added_to_author(mock_reddit_api)
예제 #5
0
    def test_should_not_add_flair_if_author_attribute_not_present(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        delattr(mock_comment, 'author')

        heatware.main()

        self._assert_flair_not_added_to_author(mock_reddit_api)
예제 #6
0
    def test_should_not_add_flair_to_comment_author_if_author_already_has_flair(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        mock_comment.author_flair_text = 'existing flair'

        heatware.main()

        self._assert_flair_not_added_to_author(mock_reddit_api)
예제 #7
0
    def test_should_not_add_flair_if_comment_body_does_not_match_pattern(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        mock_comment = self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        heatware.config.heatware.regex = '^body must match this$'
        mock_comment.body = 'invalid'

        heatware.main()

        self._assert_flair_not_added_to_author(mock_reddit_api)
예제 #8
0
    def test_login_to_reddit_with_values_from_config(self, MockReddit):
        mock_reddit_api = self._setup_mock_reddit_api(MockReddit)
        self._add_a_mock_comment_to_heatware_submission(mock_reddit_api)

        heatware.main()

        heatware.praw.Reddit.assert_called_with(client_id='fake app key',
                                                client_secret='fake app secret',
                                                username='******',
                                                password='******',
                                                user_agent='fake username')