예제 #1
0
파일: tests.py 프로젝트: logan/praw
 def test_author_encoding(self):
     # pylint: disable-msg=E1101
     a1 = six_next(self.r.get_new(url_data={'sort': 'new'})).author
     a2 = self.r.get_redditor(text_type(a1))
     self.assertEqual(a1, a2)
     s1 = six_next(a1.get_submitted())
     s2 = six_next(a2.get_submitted())
     self.assertEqual(s1, s2)
예제 #2
0
 def test_author_encoding(self):
     # pylint: disable-msg=E1101
     a1 = six_next(self.r.get_front_page()).author
     a2 = self.r.get_redditor(text_type(a1))
     self.assertEqual(a1, a2)
     s1 = six_next(a1.get_submitted())
     s2 = six_next(a2.get_submitted())
     self.assertEqual(s1, s2)
예제 #3
0
 def next(self):
     # Strip whitespace here if the reader was not able to do it by itself already (only CSV is capable of doing it currently)
     if self.manually_strip_whitespaces:
         newrow = {}
         for k, v in six_next(self.reader).iteritems():
             if isinstance(v, basestring):
                 newrow[k] = v.strip()
             else:
                 newrow[k] = v
         return newrow
     else:
         return six_next(self.reader)
예제 #4
0
 def next(self):
     # Strip whitespace here if the reader was not able to do it by itself already (only CSV is capable of doing it currently)
     if self.manually_strip_whitespaces:
         newrow = {}
         for k, v in six_next(self.reader).iteritems():
             if isinstance(v, basestring):
                 newrow[k] = v.strip()
             else:
                 newrow[k] = v
         return newrow
     else:
         return six_next(self.reader)
예제 #5
0
파일: tests.py 프로젝트: logan/praw
 def test_equality(self):
     subreddit = self.r.get_subreddit(self.sr)
     same_subreddit = self.r.get_subreddit(self.sr)
     submission = six_next(subreddit.get_hot())
     self.assertTrue(subreddit == same_subreddit)
     self.assertFalse(subreddit != same_subreddit)
     self.assertFalse(subreddit == submission)
예제 #6
0
 def test_short_link(self):
     submission = six_next(self.r.get_front_page())
     if self.r.config.is_reddit:
         self.assertTrue(submission.id in submission.short_link)
     else:
         self.assertRaises(errors.ClientException, getattr, submission,
                           'short_link')
예제 #7
0
파일: tests.py 프로젝트: logan/praw
 def test_short_link(self):
     submission = six_next(self.r.get_new(url_data={'sort': 'new'}))
     if self.r.config.is_reddit:
         self.assertTrue(submission.id in submission.short_link)
     else:
         self.assertRaises(errors.ClientException, getattr, submission,
                           'short_link')
예제 #8
0
 def test_mark_as_read(self):
     oth = Reddit(USER_AGENT)
     oth.login('PyApiTestUser3', '1111')
     # pylint: disable-msg=E1101
     msg = six_next(oth.user.get_unread(limit=1))
     msg.mark_as_read()
     self.assertTrue(msg not in oth.user.get_unread(limit=5))
예제 #9
0
 def test_add_comment_and_verify(self):
     text = 'Unique comment: %s' % uuid.uuid4()
     # pylint: disable-msg=E1101
     submission = six_next(self.subreddit.get_new_by_date())
     # pylint: enable-msg=E1101
     comment = submission.add_comment(text)
     self.assertEqual(comment.submission, submission)
     self.assertEqual(comment.body, text)
예제 #10
0
파일: tests.py 프로젝트: logan/praw
 def test_info_by_self_url_raises_warning(self):
     url = six_next(self.r.get_new(url_data={'sort': 'new'})).permalink
     with warnings.catch_warnings(record=True) as w:
         warnings.simplefilter('always')
         self.r.info(url)
         self.assertEqual(len(w), 1)
         self.assertEqual(w[0].category, UserWarning)
         self.assertTrue('self' in text_type(w[0].message))
예제 #11
0
 def test_approve(self):
     submission = six_next(self.subreddit.get_spam())
     if not submission:
         self.fail("Could not find a submission to approve.")
     submission.approve()
     for approved in self.subreddit.get_new_by_date():
         if approved.id == submission.id:
             break
     else:
         self.fail("Could not find approved submission.")
예제 #12
0
 def test_remove(self):
     submission = six_next(self.subreddit.get_new_by_date())
     if not submission:
         self.fail('Could not find a submission to remove.')
     submission.remove()
     for removed in self.subreddit.get_spam():
         if removed.id == submission.id:
             break
     else:
         self.fail('Could not find removed submission.')
예제 #13
0
 def test_info_by_url_also_found_by_id(self):
     if self.r.config.is_reddit:
         url = 'http://imgur.com/Vr8ZZ'
     else:
         url = 'http://google.com/?q=82.1753988563'
     # pylint: disable-msg=E1101
     found_link = six_next(self.r.info(url))
     found_by_id = self.r.info(thing_id=found_link.content_id)
     self.assertTrue(found_by_id)
     self.assertTrue(found_link in found_by_id)
예제 #14
0
파일: tests.py 프로젝트: xlevus/praw
 def test_refresh_submission(self):
     subreddit = self.r.get_subreddit(self.sr)
     submission = six_next(subreddit.get_top())
     same_submission = self.r.get_submission(submission_id=submission.id)
     if submission.likes:
         submission.downvote()
     else:
         submission.upvote()
     self.assertEqual(submission.likes, same_submission.likes)
     submission.refresh()
     self.assertNotEqual(submission.likes, same_submission.likes)
예제 #15
0
    def stringified_row(self):
        """Ensure row contents are all strings"""

        row = six_next(self._iter)
        newrow = []
        for element in row:
            if element.value is not None:
                if isinstance(element.value, datetime):
                    element = str(element.value)
                elif element.data_type is openpyxl.cell.Cell.TYPE_NUMERIC:
                    element = str(element.value)
                else:
                    element = element.value
            else:
                element = CLEAR_STRING
            newrow.append(element)
        return newrow
예제 #16
0
    def stringified_row(self):
        """Ensure row contents are all strings"""

        row = six_next(self._iter)
        newrow = []
        for element in row:
            if element.value is not None:
                if isinstance(element.value, datetime):
                    element = str(element.value)
                elif element.data_type is openpyxl.cell.Cell.TYPE_NUMERIC:
                    element = str(element.value)
                else:
                    element = element.value
            else:
                element = CLEAR_STRING
            newrow.append(element)
        return newrow
예제 #17
0
 def test_unicode_comment(self):
     sub = six_next(self.r.get_subreddit(self.sr).get_new_by_date())
     text = 'Have some unicode: (\xd0, \xdd)'
     comment = sub.add_comment(text)
     self.assertEqual(text, comment.body)
예제 #18
0
파일: tests.py 프로젝트: logan/praw
 def test_flair_list(self):
     sub = self.r.get_subreddit('python')
     self.assertTrue(six_next(sub.flair_list()))
예제 #19
0
파일: tests.py 프로젝트: logan/praw
 def test_info_by_url_also_found_by_id(self):
     # pylint: disable-msg=E1101
     found_link = six_next(self.r.info(self.link_url_link))
     found_by_id = self.r.info(thing_id=found_link.content_id)
     self.assertTrue(found_by_id)
     self.assertTrue(found_link in found_by_id)
예제 #20
0
 def test_add_link_flair_to_invalid_subreddit(self):
     sub = six_next(self.r.get_subreddit('bboe').get_new_by_date())
     self.assertRaises(HTTPError, self.subreddit.set_flair, sub, 'text')
예제 #21
0
 def test_add_link_flair_through_submission(self):
     flair_text = 'Falir: %s' % uuid.uuid4()
     sub = six_next(self.subreddit.get_new_by_date())
     sub.set_flair(flair_text)
     sub = self.r.get_submission(sub.permalink)
     self.assertEqual(sub.link_flair_text, flair_text)
예제 #22
0
 def test_front_page_comment_replies_are_none(self):
     # pylint: disable-msg=E1101,W0212
     item = six_next(self.r.get_all_comments())
     self.assertEqual(item._replies, None)
예제 #23
0
파일: tests.py 프로젝트: xlevus/praw
 def test_liked(self):
     # Pulls from get_disliked. Problem here may come from get_disliked
     item = six_next(self.r.user.get_disliked())
     item.upvote()
     self.assertTrue(item in self.r.user.get_liked())
예제 #24
0
 def test_get_comments_permalink(self):
     sub = self.r.get_subreddit(self.sr)
     item = six_next(sub.get_comments())
     self.assertTrue(item.id in item.permalink)
예제 #25
0
 def test_user_comments_permalink(self):
     item = six_next(self.r.user.get_comments())
     self.assertTrue(item.id in item.permalink)
예제 #26
0
 def test_reply(self):
     comment = six_next(self.r.user.get_comments())
     new_body = '%s\n\n+Edit Text' % comment.body
     comment = comment.edit(new_body)
     self.assertEqual(comment.body, new_body)
예제 #27
0
파일: tests.py 프로젝트: logan/praw
 def test_liked(self):
     # Pulls from get_disliked. Problem here may come from get_disliked
     item = six_next(self.r.user.get_disliked())
     item.upvote()
     self.delay()  # The queue needs to be processed
     self.assertFalse(item in list(self.r.user.get_disliked()))
예제 #28
0
파일: tests.py 프로젝트: dulichan/praw
 def test_get_hidden(self):
     item = six_next(self.r.user.get_hidden())
     item.unhide()
     self.delay()  # The queue needs to be processed
     self.assertFalse(item in list(self.r.user.get_hidden()))