'''Test live services.''' import codecs import glob import os import os.path import unittest from terroroftinytown.services.registry import registry from terroroftinytown.services.status import URLStatus from terroroftinytown.six import u import terroroftinytown import time from terroroftinytown.client.errors import MalformedResponse MOCK_PARAMS = { 'isgd': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_', 'url_template': 'https://is.gd/{shortcode}', 'redirect_codes': [301, 302], 'no_redirect_codes': [404], 'unavailable_codes': [200, 410], 'banned_codes': [403, 420, 429, 502], 'method': 'get', 'location_anti_regex': r'^https://is\.gd/' }, 'vgd': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_', 'url_template': 'https://v.gd/{shortcode}', 'redirect_codes': [301, 302], 'no_redirect_codes': [404], 'unavailable_codes': [200, 410], 'banned_codes': [403, 420, 429, 502], 'method': 'get', }, 'bitly': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_', 'url_template': 'http://bit.ly/{shortcode}', 'redirect_codes': [301, 302], 'no_redirect_codes': [404], 'unavailable_codes': [410], 'banned_codes': [403], 'method': 'head', }, 'xco': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://x.co/{shortcode}', 'redirect_codes': [301], 'no_redirect_codes': [200], 'banned_codes': [403, 420, 429], 'method': 'head', }, 'pub-vitrue-com': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://pub.vitrue.com/{shortcode}', 'redirect_codes': [301], 'no_redirect_codes': [302], 'banned_codes': [403, 420, 429], 'method': 'head', }, 'tighturl-com': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://tighturl.com/{shortcode}', 'redirect_codes': [301], 'no_redirect_codes': [404], 'banned_codes': [420, 429], 'method': 'head', }, 'tinyurl': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyz', 'url_template': 'http://tinyurl.com/{shortcode}', 'redirect_codes': [200, 301, 307], 'no_redirect_codes': [404], 'unavailable_codes': [302], 'banned_codes': [420, 429], 'method': 'head', }, 'adjix': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyz', 'url_template': 'http://adjix.com/{shortcode}', 'redirect_codes': [200], 'no_redirect_codes': [403, 404], 'unavailable_codes': [], 'banned_codes': [420, 429], 'method': 'get', }, 'yatuc': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyz', 'url_template': 'http://yatuc.com/{shortcode}', 'redirect_codes': [302], 'no_redirect_codes': [], 'unavailable_codes': [], 'banned_codes': [420, 429], 'method': 'head', }, 'shar-es': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://shar.es/{shortcode}', 'redirect_codes': [200, 301], 'no_redirect_codes': [404], 'unavailable_codes': [], 'banned_codes': [403, 420, 429], 'method': 'get', 'body_regex': r'', }, 'feedly': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_', 'url_template': 'http://feedly.com/e/{shortcode}', 'redirect_codes': [302], 'no_redirect_codes': [], 'unavailable_codes': [], 'banned_codes': [403, 420, 429], 'method': 'head', }, 'awe-sm': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://awe.sm/{shortcode}', 'redirect_codes': [301], 'no_redirect_codes': [], 'unavailable_codes': [], 'banned_codes': [403, 420, 429], 'method': 'head', }, 'ow-ly': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://ow.ly/{shortcode}', 'redirect_codes': [301, 302], 'no_redirect_codes': [404], 'unavailable_codes': [410], 'banned_codes': [403, 420, 429], 'method': 'head', }, 'snipurl': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyz-_~', 'url_template': 'http://snipurl.com/{shortcode}', 'redirect_codes': [301], 'no_redirect_codes': [410], 'unavailable_codes': [], 'banned_codes': [403, 420, 429], 'method': 'head', }, 'sharedby-co': { 'alphabet': '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'url_template': 'http://sharedby.co/{shortcode}', 'redirect_codes': [200, 301], 'no_redirect_codes': [302], 'unavailable_codes': [], 'banned_codes': [403, 420, 429], 'method': 'get', 'body_regex': r'