More work to get the backend tests to work
authorepage <eopage@byu.net>
Sat, 30 May 2009 01:53:30 +0000 (01:53 +0000)
committerepage <eopage@byu.net>
Sat, 30 May 2009 01:53:30 +0000 (01:53 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@347 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

tests/gc_samples/__init__.py [new file with mode: 0644]
tests/gc_samples/generate_gc_samples.py
tests/gv_samples/__init__.py [new file with mode: 0644]
tests/gv_samples/generate_gv_samples.py

diff --git a/tests/gc_samples/__init__.py b/tests/gc_samples/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 463932a..9aacd62 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import sys
+import os
 import urllib
 import urllib2
 import traceback
@@ -12,13 +12,6 @@ sys.path.append("../../src")
 import browser_emu
 import gc_backend
 
-       _forwardselectURL = "http://www.grandcentral.com/mobile/settings/forwarding_select"
-       _loginURL = "https://www.grandcentral.com/mobile/account/login"
-       _setforwardURL = "http://www.grandcentral.com/mobile/settings/set_forwarding?from=settings"
-       _clicktocallURL = "http://www.grandcentral.com/mobile/calls/click_to_call?a_t=%s&destno=%s"
-       _inboxallURL = "http://www.grandcentral.com/mobile/messages/inbox?types=all"
-       _contactsURL = "http://www.grandcentral.com/mobile/contacts"
-       _contactDetailURL = "http://www.grandcentral.com/mobile/contacts/detail"
 webpages = [
        ("forward", gc_backend.GCDialer._forwardselectURL),
        ("login", gc_backend.GCDialer._loginURL),
@@ -30,7 +23,12 @@ webpages = [
 ]
 
 
+# Create Browser
 browser = browser_emu.MozillaEmulator(1)
+cookieFile = os.path.join(".", ".gv_cookies.txt")
+browser.cookies.filename = cookieFile
+
+# Get Pages
 for name, url in webpages:
        try:
                page = browser.download(url)
@@ -40,6 +38,7 @@ for name, url in webpages:
        with open("not_loggedin_%s.txt" % name, "w") as f:
                f.write(page)
 
+# Login
 username = sys.argv[1]
 password = sys.argv[2]
 
@@ -58,21 +57,17 @@ except urllib2.URLError, e:
        warnings.warn(traceback.format_exc())
        raise RuntimeError("%s is not accesible" % gc_backend.GCDialer._loginURL)
 
-forwardPage = browser.download(gc_backend.GCDialer._forwardURL)
+forwardPage = browser.download(gc_backend.GCDialer._forwardselectURL)
 
-tokenGroup = gc_backend.GCDialer._tokenRe.search(forwardPage)
+tokenGroup = gc_backend.GCDialer._accessTokenRe.search(forwardPage)
 if tokenGroup is None:
        print forwardPage
-       raise RuntimeError("Could not extract authentication token from GoogleVoice")
+       raise RuntimeError("Could not extract authentication token from GrandCentral")
 token = tokenGroup.group(1)
 
-browser = browser_emu.MozillaEmulator(1)
+# Get Pages
 for name, url in webpages:
        try:
-               #data = urllib.urlencode({
-               #       "_rnr_se": token,
-               #})
-               #page = browser.download(url, data)
                page = browser.download(url)
        except StandardError, e:
                warnings.warn(traceback.format_exc())
diff --git a/tests/gv_samples/__init__.py b/tests/gv_samples/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 6ba1c30..a228a48 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import sys
+import os
 import urllib
 import urllib2
 import traceback
@@ -13,12 +13,7 @@ import browser_emu
 import gv_backend
 
 webpages = [
-       ("login", gv_backend.GVDialer._loginURL),
-       ("clicktocall", gv_backend.GVDialer._clicktocallURL),
-       ("sendsms", gv_backend.GVDialer._sendSmsURL),
-       ("setforward", gv_backend.GVDialer._setforwardURL),
        ("contacts", gv_backend.GVDialer._contactsURL),
-       ("contactdetails", gv_backend.GVDialer._contactDetailURL),
        ("voicemail", gv_backend.GVDialer._voicemailURL),
        ("sms", gv_backend.GVDialer._smsURL),
        ("forward", gv_backend.GVDialer._forwardURL),
@@ -29,7 +24,12 @@ webpages = [
 ]
 
 
+# Create Browser
 browser = browser_emu.MozillaEmulator(1)
+cookieFile = os.path.join(".", ".gv_cookies.txt")
+browser.cookies.filename = cookieFile
+
+# Get Pages
 for name, url in webpages:
        try:
                page = browser.download(url)
@@ -39,6 +39,7 @@ for name, url in webpages:
        with open("not_loggedin_%s.txt" % name, "w") as f:
                f.write(page)
 
+# Login
 username = sys.argv[1]
 password = sys.argv[2]
 
@@ -65,13 +66,9 @@ if tokenGroup is None:
        raise RuntimeError("Could not extract authentication token from GoogleVoice")
 token = tokenGroup.group(1)
 
-browser = browser_emu.MozillaEmulator(1)
+# Get Pages
 for name, url in webpages:
        try:
-               #data = urllib.urlencode({
-               #       "_rnr_se": token,
-               #})
-               #page = browser.download(url, data)
                page = browser.download(url)
        except StandardError, e:
                warnings.warn(traceback.format_exc())