"""Utilities to support testing."""
from gtmetrix import settings

G_saved_settings = None

def save_settings():
    global G_saved_settings
    G_saved_settings = (settings.GTMETRIX_REST_API_EMAIL,
             settings.GTMETRIX_REST_API_KEY,
             settings.GTMETRIX_REST_API_URL)


def restore_settings():
    settings.GTMETRIX_REST_API_EMAIL,   \
    settings.GTMETRIX_REST_API_KEY,     \
    settings.GTMETRIX_REST_API_URL = G_saved_settings


def email_is_valid(email):
    """Check for valid email address.  Stubbed out for now."""
    return email != None


def api_key_is_valid(key):
    """Check for valid API key.  Stubbed out for now."""
    return key != None


def api_url_is_valid(url):
    """Ensure that it's set to what it was when settings.py was written.

    Prevents e.g. testing api/0.1 calls against api/1.0 if it ever comes
    out."""
    return (settings.GTMETRIX_REST_API_URL ==
            'https://gtmetrix.com/api/0.1/test')

@@ -1,8 +1,32 @@
+# -*- coding: utf-8 -*-%0A
 %22%22%22Utili
@@ -109,16 +109,112 @@
 = None%0A%0A
+# Change this when the test URL changes%0AG_test_valid_url = 'https://gtmetrix.com/api/0.1/test'%0A%0A
 def save
@@ -572,511 +572,4 @@
 s%0A%0A%0A
-def email_is_valid(email):%0A    %22%22%22Check for valid email address.  Stubbed out for now.%22%22%22%0A    return email != None%0A%0A%0Adef api_key_is_valid(key):%0A    %22%22%22Check for valid API key.  Stubbed out for now.%22%22%22%0A    return key != None%0A%0A%0Adef api_url_is_valid(url):%0A    %22%22%22Ensure that it's set to what it was when settings.py was written.%0A%0A    Prevents e.g. testing api/0.1 calls against api/1.0 if it ever comes%0A    out.%22%22%22%0A    return (settings.GTMETRIX_REST_API_URL ==%0A            'https://gtmetrix.com/api/0.1/test')%0A

Move validation routines to utils