def test_sanitize_username(self): dirty_and_clean = [ ('@dialelo', 'dialelo'), ('dialelo', 'dialelo'), ('?@mental_floss', 'mental_floss'), ('@4n_4Wfu1_US3RN4M3', '4n_4Wfu1_US3RN4M3'), ] for dirty, clean in dirty_and_clean: sanitized = sanitize_username(dirty) self.assertEqual(sanitized, clean)
def mentioned_usernames(self): """ Return mentioned usernames in `status` without '@'. """ # TODO: use self.entities if available usernames = [] for word in self.text.split(): if len(word) > 1 and word.startswith("@"): word.strip("@") usernames.append(sanitize_username(word)) return list(set(usernames))
def mentioned_usernames(self): """ Return mentioned usernames in `status` without '@'. """ # TODO: use self.entities if available usernames = [] for word in self.text.split(): if len(word) > 1 and word.startswith('@'): word.strip('@') usernames.append(sanitize_username(word)) return list(set(usernames))