Пример #1
0
    def test_url_shortened(self):
        from max.utils.formatting import shortenURL

        http_mock_bitly()
        url = 'http://example.com'
        newurl = shortenURL(url)
        self.assertEqual(newurl, "http://shortened.url")
Пример #2
0
    def test_url_shortened_parsing_failure(self):
        from max.utils.formatting import shortenURL

        http_mock_bitly(status=500, body="invalid json")
        url = 'http://example.com'
        newurl = shortenURL(url)
        self.assertEqual(url, newurl)
Пример #3
0
    def test_url_shortened_parsing_failure(self):
        from max.utils.formatting import shortenURL

        http_mock_bitly(status=500, body="invalid json")
        url = 'http://example.com'
        bitly_username = '******'
        bitly_api_key = 'R_1123ce7d9aea4d699f65af02912c048e'
        newurl = shortenURL(url, bitly_username, bitly_api_key)
        self.assertEqual(url, newurl)
Пример #4
0
    def test_url_secure_shortened(self):
        from max.utils.formatting import shortenURL

        http_mock_bitly()
        url = 'http://example.com'
        bitly_username = '******'
        bitly_api_key = 'R_1123ce7d9aea4d699f65af02912c048e'
        newurl = shortenURL(url, bitly_username, bitly_api_key, secure=True)
        self.assertEqual(newurl, "https://shortened.url")