Beispiel #1
0
 def test_quoting_mentions_hashtags(self):
     """Parenthesis around items"""
     links = parse_links('"https://pjuu.com/user1"')
     self.assertEqual(links[0]['link'], 'https://pjuu.com/user1')
     hashtags = parse_hashtags('"#pjuu"')
     self.assertEqual(hashtags[0]['hashtag'], 'pjuu')
     mentions = parse_mentions('"@joe"', check_user=False)
     self.assertEqual(mentions[0]['username'], 'joe')
Beispiel #2
0
 def test_mention_real_user(self):
     """Find a user mentions (user does exist)"""
     user1 = create_account('user1', '*****@*****.**', 'Password1')
     mentions = parse_mentions('@user1 @user2')
     self.assertEqual(len(mentions), 1)
     self.assertEqual(mentions[0]['username'], 'user1')
     self.assertEqual(mentions[0]['user_id'], user1)
     self.assertEqual(mentions[0]['span'], (0, 6))
Beispiel #3
0
 def test_quoting_mentions_hashtags(self):
     """Parenthesis around items"""
     links = parse_links('"https://pjuu.com/user1"')
     self.assertEqual(links[0]['link'], 'https://pjuu.com/user1')
     hashtags = parse_hashtags('"#pjuu"')
     self.assertEqual(hashtags[0]['hashtag'], 'pjuu')
     mentions = parse_mentions('"@joe"', check_user=False)
     self.assertEqual(mentions[0]['username'], 'joe')
Beispiel #4
0
 def test_mention_no_user(self):
     """Find a user mention (doens't exist)"""
     mentions = parse_mentions('@joe @ant', check_user=False)
     self.assertEqual(mentions[0]['username'], 'joe')
     self.assertEqual(mentions[0]['user_id'], 'NA')
     self.assertEqual(mentions[0]['span'], (0, 4))
     self.assertEqual(mentions[1]['username'], 'ant')
     self.assertEqual(mentions[1]['user_id'], 'NA')
     self.assertEqual(mentions[1]['span'], (5, 9))
Beispiel #5
0
 def test_mention_real_user(self):
     """Find a user mentions (user does exist)"""
     user1 = create_account('user1', '*****@*****.**', 'Password1')
     activate(user1)
     mentions = parse_mentions('@user1 @user2')
     self.assertEqual(len(mentions), 1)
     self.assertEqual(mentions[0]['username'], 'user1')
     self.assertEqual(mentions[0]['user_id'], user1)
     self.assertEqual(mentions[0]['span'], (0, 6))
Beispiel #6
0
 def test_mention_no_user(self):
     """Find a user mention (doens't exist)"""
     mentions = parse_mentions('@joe @ant', check_user=False)
     self.assertEqual(mentions[0]['username'], 'joe')
     self.assertEqual(mentions[0]['user_id'], 'NA')
     self.assertEqual(mentions[0]['span'], (0, 4))
     self.assertEqual(mentions[1]['username'], 'ant')
     self.assertEqual(mentions[1]['user_id'], 'NA')
     self.assertEqual(mentions[1]['span'], (5, 9))
Beispiel #7
0
    def test_delimited(self):
        """Ensure hashtags can be delimited"""
        hashtags = parse_hashtags('#pjuu\'s test')
        self.assertEqual(hashtags[0]['hashtag'], 'pjuu')

        user1 = create_account('user1', '*****@*****.**', 'Password1')
        activate(user1)
        mentions = parse_mentions('@user1\'s')
        self.assertEqual(mentions[0]['username'], 'user1')
        self.assertEqual(mentions[0]['user_id'], user1)