Skip to content

Commit

Permalink
failed remove post test
Browse files Browse the repository at this point in the history
  • Loading branch information
barrycarey committed Feb 18, 2024
1 parent 720792a commit 495c280
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/submonitorsvc/test_subMonitor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from unittest import TestCase
from unittest.mock import MagicMock, Mock, patch, ANY

from praw.models import Submission

from redditrepostsleuth.core.config import Config
from redditrepostsleuth.core.db.databasemodels import Post, MonitoredSub, PostType, UserReview, UserWhitelist
from redditrepostsleuth.submonitorsvc.monitored_sub_service import MonitoredSubService
Expand Down Expand Up @@ -170,7 +172,10 @@ def test__handle_high_volume_reposter_check_over_threshold_remove(self, mock_ban
user_whitelist=MagicMock(get_by_username_and_subreddit=MagicMock(return_value=None))
)
mock_response_handler = Mock(send_mod_mail=Mock())
sub_monitor = MonitoredSubService(MagicMock(), MagicMock(), MagicMock(), MagicMock(), mock_response_handler,
submission = Submission( MagicMock(), id='11')
sub_monitor = MonitoredSubService(MagicMock(), MagicMock(),
MagicMock(submission=MagicMock(return_value=submission)), MagicMock(),
mock_response_handler,
config=MagicMock())
monitored_sub = MonitoredSub(
name='test_subreddit',
Expand All @@ -183,7 +188,7 @@ def test__handle_high_volume_reposter_check_over_threshold_remove(self, mock_ban
post = Post(subreddit='test_subreddit', author='test_user')
sub_monitor.handle_high_volume_reposter_check(post, mock_uow, monitored_sub)
mock_ban_user.assert_not_called()
mock_remove_post.assert_called_once_with('Removed', ANY)
mock_remove_post.assert_called_once_with('Removed', submission, mod_note=ANY)
mock_response_handler.send_mod_mail.assert_not_called()

@patch.object(MonitoredSubService, '_remove_post')
Expand All @@ -194,7 +199,10 @@ def test__handle_high_volume_reposter_check_over_threshold_remove_and_ban(self,
user_whitelist=MagicMock(get_by_username_and_subreddit=MagicMock(return_value=None))
)
mock_response_handler = Mock(send_mod_mail=Mock())
sub_monitor = MonitoredSubService(MagicMock(), MagicMock(), MagicMock(), MagicMock(), mock_response_handler,
submission = Submission(MagicMock(), id='11')
sub_monitor = MonitoredSubService(MagicMock(), MagicMock(),
MagicMock(submission=MagicMock(return_value=submission)), MagicMock(),
mock_response_handler,
config=MagicMock())
monitored_sub = MonitoredSub(
name='test_subreddit',
Expand All @@ -207,7 +215,7 @@ def test__handle_high_volume_reposter_check_over_threshold_remove_and_ban(self,
post = Post(subreddit='test_subreddit', author='test_user')
sub_monitor.handle_high_volume_reposter_check(post, mock_uow, monitored_sub)
mock_ban_user.assert_called_once_with('test_user', 'test_subreddit', 'High volume of reposts detected by Repost Sleuth')
mock_remove_post.assert_called_once_with('Removed', ANY)
mock_remove_post.assert_called_once_with('Removed', submission, mod_note=ANY)
mock_response_handler.send_mod_mail.assert_not_called()

@patch.object(MonitoredSubService, '_remove_post')
Expand Down

0 comments on commit 495c280

Please sign in to comment.