Example #1
0
    def test_twitter_username_with_tweet_number(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(self, 'user_loneblockbuster.json')

        expected = u'2018-07-24 19:30:59 \x02loneblockbuster\x02: ' \
                   u'We never would have planted the ferns out ' \
                   u'front if we knew we\'d get so many death threats.'

        actual = twitter('loneblockbuster 10', api_key=FAKE_API_KEY)

        assert expected == actual
Example #2
0
    def test_comment(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, '9943987.json')

        expected = u'"Yes, they must have meant kilowatt hours. Was ' \
                   u'there no editor?" -- oaktowner'

        url = 'https://news.ycombinator.com/item?id=9943987'
        actual = execute_skybot_regex(hackernews, url)

        assert expected == actual
Example #3
0
    def test_twitter_username_no_tweet_number(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(self, 'user_loneblockbuster.json')

        expected = u'2018-08-16 17:38:52 \x02loneblockbuster\x02: ' \
                   u'We had the motto "When you\'re here you\'re ' \
                   u'family" before Olive Garden but like ' \
                   u'everything else it was taken away ' \
                   u'from us.'

        actual = twitter('loneblockbuster', api_key=FAKE_API_KEY)

        assert expected == actual
Example #4
0
    def test_bitcoin(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, 'bitcoin.json')

        say_mock = Mock()

        bitcoin('', say=say_mock)

        expected = 'USD/BTC: \x0307$6,390.67\x0f - High: \x0307$6,627.' \
                   '00\x0f - Low: \x0307$6,295.73\x0f - Volume: ' \
                   '10,329.67 BTC'
        say_mock.assert_called_once_with(expected)
Example #5
0
    def test_bitcoin(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, "bitcoin.json")

        say_mock = Mock()

        bitcoin("", say=say_mock)

        expected = ("USD/BTC: \x0307$6,390.67\x0f - High: \x0307$6,627."
                    "00\x0f - Low: \x0307$6,295.73\x0f - Volume: "
                    "10,329.67 BTC")
        say_mock.assert_called_once_with(expected)
Example #6
0
    def test_ethereum(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, 'ethereum.json')

        say_mock = Mock()

        ethereum('', say=say_mock)

        expected = 'USD/ETH: \x0307$355.02\x0f - High: \x0307$370.43' \
                   '\x0f - Low: \x0307$350.00\x0f - Volume: ' \
                   '16,408.97 ETH'

        say_mock.assert_called_once_with(expected)
Example #7
0
    def test_ethereum(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, "ethereum.json")

        say_mock = Mock()

        ethereum("", say=say_mock)

        expected = ("USD/ETH: \x0307$355.02\x0f - High: \x0307$370.43"
                    "\x0f - Low: \x0307$350.00\x0f - Volume: "
                    "16,408.97 ETH")

        say_mock.assert_called_once_with(expected)
Example #8
0
    def test_story(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, '9943431.json')

        expected = u'Can Desalination Counter the Drought? by cwal37 ' \
                   u'with 51 points and 94 comments ' \
                   u'(http://www.newyorker.com/tech/elements/can-' \
                   u'desalination-counter-the-drought)'

        url = 'https://news.ycombinator.com/item?id=9943431'
        actual = execute_skybot_regex(hackernews, url)

        assert expected == actual
Example #9
0
    def test_crypto_eth_to_default(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, 'crypto_eth_to_default.json')

        expected = u'USD/\u039e: \x0307$ 315.91\x0f - High: ' \
                   u'\x0307$ 332.41\x0f - Low: \x0307$ 312.35\x0f ' \
                   u'- Volume: \u039e 163,011.9 ($ 52,513,531.9) - ' \
                   u'Total Supply: \u039e 101,251,550.4 - ' \
                   u'MktCap: $ 31.99 B'

        say_mock = Mock()
        crypto('eth', say_mock)

        say_mock.assert_called_once_with(expected)
Example #10
0
    def test_twitter_username_with_tweet_number(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, "user_loneblockbuster.json"
        )

        expected = (
            u"2018-07-24 19:30:59 \x02loneblockbuster\x02: "
            u"We never would have planted the ferns out "
            u"front if we knew we'd get so many death threats."
        )

        actual = twitter("loneblockbuster 10", api_key=FAKE_API_KEY)

        assert expected == actual
Example #11
0
    def test_crypto_eth_to_default(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, "crypto_eth_to_default.json")

        expected = (u"USD/\u039e: \x0307$ 315.91\x0f - High: "
                    u"\x0307$ 332.41\x0f - Low: \x0307$ 312.35\x0f "
                    u"- Volume: \u039e 163,011.9 ($ 52,513,531.9) - "
                    u"Total Supply: \u039e 101,251,550.4 - "
                    u"MktCap: $ 31.99 B")

        say_mock = Mock()
        crypto("eth", say_mock)

        say_mock.assert_called_once_with(expected)
Example #12
0
    def test_crypto_btc_to_default(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, 'crypto_btc_to_default.json')

        expected = u'USD/\u0243: \x0307$ 6,084.30\x0f - High: ' \
                   u'\x0307$ 6,178.90\x0f - Low: \x0307$ 6,014.26' \
                   u'\x0f - Volume: \u0243 21,428.7 ' \
                   u'($ 131,067,493.3) - Total Supply: ' \
                   u'\u0243 17,202,675.0 - MktCap: $ 104.67 B'

        say_mock = Mock()
        crypto('btc', say=say_mock)

        say_mock.assert_called_once_with(expected)
Example #13
0
    def test_twitter_hashtag_with_tweet_number(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(self, 'hashtag_nyc.json')

        expected = u'2018-08-17 20:19:32 \x02Kugey\x02: ' \
                   u'I know for sure that life is beautiful ' \
                   u'around the world... \u2022 \u2022 Here ' \
                   u'is yet another iconic piece of the ' \
                   u'NYC skyline... \u2022 \u2022 #nyc ' \
                   u'#photography #streetphotography ' \
                   u'#urbanphotography\u2026 ' \
                   u'https://t.co/bq9i0FZN89'

        actual = twitter('#NYC 10', api_key=FAKE_API_KEY)

        assert expected == actual
Example #14
0
    def test_twitter_username_no_tweet_number(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, "user_loneblockbuster.json"
        )

        expected = (
            u"2018-08-16 17:38:52 \x02loneblockbuster\x02: "
            u"We had the motto \"When you're here you're "
            u'family" before Olive Garden but like '
            u"everything else it was taken away "
            u"from us."
        )

        actual = twitter("loneblockbuster", api_key=FAKE_API_KEY)

        assert expected == actual
Example #15
0
    def test_twitter_hashtag_with_tweet_number(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(self, "hashtag_nyc.json")

        expected = (
            u"2018-08-17 20:19:32 \x02Kugey\x02: "
            u"I know for sure that life is beautiful "
            u"around the world... \u2022 \u2022 Here "
            u"is yet another iconic piece of the "
            u"NYC skyline... \u2022 \u2022 #nyc "
            u"#photography #streetphotography "
            u"#urbanphotography\u2026 "
            u"https://t.co/bq9i0FZN89"
        )

        actual = twitter("#NYC 10", api_key=FAKE_API_KEY)

        assert expected == actual
Example #16
0
    def test_tweet_regex(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(self, '1014260007771295745.json')

        expected = u'2018-07-03 21:30:04 \x02jk_rowling\x02: ' \
                   u'hahahahahahahahahahahahahahahahahahahahaha' \
                   u'hahahahahahahahahahahahahahahahahahahahaha' \
                   u'hahahahahahahahahahahahahahahahahahahahaha' \
                   u'hahahaha ' \
                   u'*draws breath* ' \
                   u'hahahahahahahahahahahahahahahahahahahahaha' \
                   u'hahahahahahahahahahahahahahahahahahahahaha' \
                   u'hahahahahahahahahahahahahahahahahahahahaha' \
                   u'haha https://t.co/gbionAPK9Z'

        url = 'https://twitter.com/jk_rowling/status/1014260007771295745'
        actual = execute_skybot_regex(show_tweet, url, api_key=FAKE_API_KEY)

        assert expected == actual
Example #17
0
    def test_twitter_hashtag_no_tweet_number(self, mock_http_get, mock_random_randint):
        mock_http_get.return_value = get_fixture_file_data(self, 'hashtag_nyc.json')

        # This plugin chooses a random value.
        # I chose this value randomly by rolling a D20.
        mock_random_randint.return_value = 6

        expected = u'2018-08-17 20:19:56 \x02The_Carl_John\x02: ' \
                   u'RT @ItVisn How many records can your ' \
                   u'company afford to lose? https://t.co/iJzFYtJmCh ' \
                   u'Be proactive and Protect Your Business ' \
                   u'#CyberSecurity #DataProtection ' \
                   u'#DataBreaches #SmallBusiness #Tech ' \
                   u'#Data #NYC #Technology #DarkWeb #Ransomware ' \
                   u'#Malware #Phishing #Business ' \
                   u'https://t.co/xAJVRhjOww'

        actual = twitter('#NYC', api_key=FAKE_API_KEY)

        assert expected == actual
Example #18
0
    def test_comment_encoding(self, mock_http_get):
        mock_http_get.return_value = get_fixture_file_data(
            self, '9943897.json')

        expected = u'"> All told, it takes about 3460 kilowatts per ' \
                   u'acre-foot to pump water from Northern California ' \
                   u'to San Diego; Carlsbad will use about thirty per ' \
                   u'cent more energy, five thousand kilowatts per ' \
                   u'acre-foot, to desalinate ocean water and deliver ' \
                   u'it to households, according to Poseidon\u2019s ' \
                   u'report to the Department of Water Resources // ' \
                   u'These units are abominations.  Couldn\'t just ' \
                   u'say 2.8 Watts per liter vs 4.0 Watts per liter?  ' \
                   u'Or even 10.6 and 15.3 Watts per gallon?  I\'m ' \
                   u'not a metric purist, but the only advantage to ' \
                   u'using imperial units is that they are more ' \
                   u'familiar to the average American, but when does ' \
                   u'the average person deal with acre-feet?" ' \
                   u'-- alwaysdoit'

        url = 'https://news.ycombinator.com/item?id=9943897'
        actual = execute_skybot_regex(hackernews, url)

        assert expected == actual