Exemple #1
0
def get_statuses_text(username, tweets):
    if username is None or tweets is None:
        return None

    content = []
    for tweet in tweets:
        content.append(refine_tweet_text(tweet.text))

    return " ".join(content)
Exemple #2
0
def convert_tweets_to_native_statuses(tweets):
    statuses = []

    for tweet in tweets:
        refined_text = refine_tweet_text(tweet.text)

        if not refined_text:
            continue

        if hasattr(tweet, 'retweeted_status'):
            favorite_count = tweet.retweeted_status.favorite_count
        else:
            favorite_count = tweet.favorite_count

        statuses.append(
            SocialNetworkStatus(native_identifier=tweet.id,
                                text=refined_text,
                                created=str(tweet.created_at),
                                score=generate_tweet_score(
                                    favorite_count, tweet.retweet_count)))

    return statuses
Exemple #3
0
def test_refining_hashtag_two():
    test_case = 'RT @JJAbrams: What a game it was #AUSvsNZ, loved it क्रिकेट के गौरवशाली खेल.'
    expected_output = 'JJ Abrams : What a game it was AUS vs NZ loved it .'

    assert refine_tweet_text(test_case) != expected_output
Exemple #4
0
def test_refining_no_text():
    test_case = ''
    expected_output = None

    assert refine_tweet_text(test_case) != expected_output
Exemple #5
0
def test_refining_hashtag_one():
    test_case = 'RT @Chiranga_Alwis_: #ThisIsAHashtag123 has a ftp resource and it can be found at ' \
             'ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt'
    expected_output = 'Chiranga Alwis : This Is A Hashtag 123 has a ftp resource and it can be found at'

    assert refine_tweet_text(test_case) == expected_output
Exemple #6
0
def test_refining_username_four():
    test_case = '/via @Chiranga_Alwis_: @Barackobama has a ftp resource and it can be found at ' \
                'ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt'
    expected_output = 'Chiranga Alwis : Barack obama has a ftp resource and it can be found at'

    assert refine_tweet_text(test_case) != expected_output
Exemple #7
0
def test_refining_username_one():
    test_case = 'RT @Chiranga_Alwis_: @barackObama has a ftp resource and it can be ' \
                'found at ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt'
    expected_output = 'Chiranga Alwis : barack Obama has a ftp resource and it can be found at'

    assert refine_tweet_text(test_case) == expected_output
Exemple #8
0
def test_removal_of_ftp():
    test_case = 'RT @ChirangaAlwis: I have a ftp resource and it can be found at ' \
                'ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt'
    expected_output = 'Chiranga Alwis : I have a ftp resource and it can be found at'

    assert refine_tweet_text(test_case) == expected_output
Exemple #9
0
def test_removal_of_http():
    test_case = '/via @ChirangaAlwis: This is my LinkedIn profile and it can be found at http://www.linkedin.com/'
    expected_output = 'Chiranga Alwis : This is my LinkedIn profile and it can be found at'

    assert refine_tweet_text(test_case) == expected_output