コード例 #1
0
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                            TEST_USER_AGENT, TEST_LIMIT)
     self.bots_comment = CommentMock(TEST_USER, [])
     self.other_comment = CommentMock('Siegmeyer',
                                      ['Gwyn, Gwyndolin, Gwynevere'])
     self.blacklist_comment = CommentMock('test_user', [])
     self.already_replied = CommentMock('Solaire',
                                        [TEST_USER, 'Crestfallen', 'Andre'])
コード例 #2
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
class TestSetupBlacklist(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)

    def test_blacklist_contains_current_user(self):
        self.assertIn(TEST_USER.lower(), self.replier._setup_blacklist("BLACKLIST.txt"))

    def test_blacklist_only_contains_user_if_no_file(self):
        self.assertEqual([TEST_USER.lower()], self.replier._setup_blacklist("blah"))
コード例 #3
0
ファイル: autogithubbot.py プロジェクト: naiyt/autogithubbot
def main():
    bot = Replier(
        Parser(),
        s.user,
        s.password,
        'all',
        debug=True
    )
    bot.start()
コード例 #4
0
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                            TEST_USER_AGENT, TEST_LIMIT)
     self.comments = [
         CommentMock('Laurentius'),
         CommentMock('Tarkus', [], "TAAAAARRRRKUUUUSSS!!"),
         CommentMock('Logan', [], 'Big Hats are Best Hats'),
         CommentMock('Giant Dad', [], 'Git Gud'),
         CommentMock('Sif'),
         CommentMock(TEST_USER)
     ]
コード例 #5
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
class TestStart(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)

    @mock.patch.object(Replier, "_login")
    @mock.patch.object(praw.helpers, "comment_stream")
    @mock.patch.object(Replier, "_main_loop")
    def test_start(self, mock_loop, mock_stream, mock_login):
        self.replier.start()
        mock_loop.assert_called_with(mock_stream.return_value)
        mock_stream.assert_called_with(self.replier.r, self.replier.subreddits, self.replier.limit)
        mock_login.assert_called_with()
コード例 #6
0
class TestSetupBlacklist(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                               TEST_USER_AGENT, TEST_LIMIT)

    def test_blacklist_contains_current_user(self):
        self.assertIn(TEST_USER.lower(),
                      self.replier._setup_blacklist('BLACKLIST.txt'))

    def test_blacklist_only_contains_user_if_no_file(self):
        self.assertEqual([TEST_USER.lower()],
                         self.replier._setup_blacklist('blah'))
コード例 #7
0
class TestStart(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                               TEST_USER_AGENT, TEST_LIMIT)

    @mock.patch.object(Replier, '_login')
    @mock.patch.object(praw.helpers, 'comment_stream')
    @mock.patch.object(Replier, '_main_loop')
    def test_start(self, mock_loop, mock_stream, mock_login):
        self.replier.start()
        mock_loop.assert_called_with(mock_stream.return_value)
        mock_stream.assert_called_with(self.replier.r, self.replier.subreddits,
                                       self.replier.limit)
        mock_login.assert_called_with()
コード例 #8
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
class TestMakeComment(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
        self.comment = CommentMock("Ornstein", [], "Pikachu")

    @mock.patch.object(CommentMock, "reply")
    def test_non_debug_reply(self, reply_mock):
        self.replier._make_comment(self.comment, "Pikachu")
        reply_mock.assert_called_with("Pikachu")

    @mock.patch.object(CommentMock, "reply")
    def test_debug_reply(self, reply_mock):
        self.replier.debug = True
        self.replier._make_comment(self.comment, "Pikachu")
        self.assertFalse(reply_mock.called)
コード例 #9
0
class TestMakeComment(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                               TEST_USER_AGENT, TEST_LIMIT)
        self.comment = CommentMock('Ornstein', [], 'Pikachu')

    @mock.patch.object(CommentMock, 'reply')
    def test_non_debug_reply(self, reply_mock):
        self.replier._make_comment(self.comment, 'Pikachu')
        reply_mock.assert_called_with('Pikachu')

    @mock.patch.object(CommentMock, 'reply')
    def test_debug_reply(self, reply_mock):
        self.replier.debug = True
        self.replier._make_comment(self.comment, 'Pikachu')
        self.assertFalse(reply_mock.called)
コード例 #10
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
     self.comments = [
         CommentMock("Laurentius"),
         CommentMock("Tarkus", [], "TAAAAARRRRKUUUUSSS!!"),
         CommentMock("Logan", [], "Big Hats are Best Hats"),
         CommentMock("Giant Dad", [], "Git Gud"),
         CommentMock("Sif"),
         CommentMock(TEST_USER),
     ]
コード例 #11
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
class TestSearchComments(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
        self.comments = [
            CommentMock("Laurentius"),
            CommentMock("Tarkus", [], "TAAAAARRRRKUUUUSSS!!"),
            CommentMock("Logan", [], "Big Hats are Best Hats"),
            CommentMock("Giant Dad", [], "Git Gud"),
            CommentMock("Sif"),
            CommentMock(TEST_USER),
        ]

    def test_searching(self):
        """
        Basic test for comments being replied to. Keep in mind
        that it's your responsibility to test your own replier
        """
        self.replier._search_comments(self.comments)
        self.assertEqual(self.replier.comments_replied_to, 2)
コード例 #12
0
class TestSearchComments(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                               TEST_USER_AGENT, TEST_LIMIT)
        self.comments = [
            CommentMock('Laurentius'),
            CommentMock('Tarkus', [], "TAAAAARRRRKUUUUSSS!!"),
            CommentMock('Logan', [], 'Big Hats are Best Hats'),
            CommentMock('Giant Dad', [], 'Git Gud'),
            CommentMock('Sif'),
            CommentMock(TEST_USER)
        ]

    def test_searching(self):
        '''
        Basic test for comments being replied to. Keep in mind
        that it's your responsibility to test your own replier
        '''
        self.replier._search_comments(self.comments)
        self.assertEqual(self.replier.comments_replied_to, 2)
コード例 #13
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
class TestShouldReply(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
        self.bots_comment = CommentMock(TEST_USER, [])
        self.other_comment = CommentMock("Siegmeyer", ["Gwyn, Gwyndolin, Gwynevere"])
        self.blacklist_comment = CommentMock("test_user", [])
        self.already_replied = CommentMock("Solaire", [TEST_USER, "Crestfallen", "Andre"])

    def test_should_not_reply_to_self(self):
        self.replier._should_reply(self.bots_comment)
        self.assertFalse(self.replier._should_reply(self.bots_comment))

    def test_should_not_reply_to_blacklist(self):
        self.assertFalse(self.replier._should_reply(self.blacklist_comment))

    def test_should_not_reply_to_same_comment_twice(self):
        self.assertFalse(self.replier._should_reply(self.already_replied))

    def test_should_reply_to_others(self):
        self.assertTrue(self.replier._should_reply(self.other_comment))
コード例 #14
0
class TestShouldReply(unittest.TestCase):
    def setUp(self):
        self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                               TEST_USER_AGENT, TEST_LIMIT)
        self.bots_comment = CommentMock(TEST_USER, [])
        self.other_comment = CommentMock('Siegmeyer',
                                         ['Gwyn, Gwyndolin, Gwynevere'])
        self.blacklist_comment = CommentMock('test_user', [])
        self.already_replied = CommentMock('Solaire',
                                           [TEST_USER, 'Crestfallen', 'Andre'])

    def test_should_not_reply_to_self(self):
        self.replier._should_reply(self.bots_comment)
        self.assertFalse(self.replier._should_reply(self.bots_comment))

    def test_should_not_reply_to_blacklist(self):
        self.assertFalse(self.replier._should_reply(self.blacklist_comment))

    def test_should_not_reply_to_same_comment_twice(self):
        self.assertFalse(self.replier._should_reply(self.already_replied))

    def test_should_reply_to_others(self):
        self.assertTrue(self.replier._should_reply(self.other_comment))
コード例 #15
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
     self.comment = CommentMock("Ornstein", [], "Pikachu")
コード例 #16
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
コード例 #17
0
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                            TEST_USER_AGENT, TEST_LIMIT)
     self.comment = CommentMock('Ornstein', [], 'Pikachu')
コード例 #18
0
ファイル: tests.py プロジェクト: naiyt/reddit-replier
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB, TEST_USER_AGENT, TEST_LIMIT)
     self.bots_comment = CommentMock(TEST_USER, [])
     self.other_comment = CommentMock("Siegmeyer", ["Gwyn, Gwyndolin, Gwynevere"])
     self.blacklist_comment = CommentMock("test_user", [])
     self.already_replied = CommentMock("Solaire", [TEST_USER, "Crestfallen", "Andre"])
コード例 #19
0
 def setUp(self):
     self.replier = Replier(TestParser(), TEST_USER, TEST_PASS, TEST_SUB,
                            TEST_USER_AGENT, TEST_LIMIT)