Commit 32f1ed7d authored by Sriram Karra's avatar Sriram Karra

Move the unit test code from pimdb_gc.py to test/test_gc.py

parent 3ad3b9f3
##
## Created : Thu Jul 07 14:47:54 IST 2011
## Last Modified : Mon Jul 02 21:27:51 IST 2012
## Last Modified : Tue Jul 03 07:45:32 IST 2012
##
## Copyright (C) 2011, 2012 by Sriram Karra <karra.etc@gmail.com>
##
......@@ -20,8 +20,6 @@
##
## ####
##
## If you want to run the unit tests in this file from the command line, the
## usage is (from the cwd PYTHONPATH=../lib/:. python pimdb_gc.py
import datetime, getopt, logging, sys, time, utils
import atom, gdata.contacts.data, gdata.contacts.client, base64
......@@ -247,47 +245,3 @@ class GCPIMDB(PIMDB):
def exec_batch (self, batch_feed):
return self.get_gdc().ExecuteBatch(
batch_feed, gdata.contacts.client.DEFAULT_BATCH_URL)
def main():
config = Config('../app_state.json')
# Parse command line options
try:
opts, args = getopt.getopt(sys.argv[1:], '', ['user=', 'pw='])
except getopt.error, msg:
print 'python gc_wrapper.py --user [username] --pw [password]'
sys.exit(2)
user = ''
pw = ''
# Process options
for option, arg in opts:
if option == '--user':
user = arg
elif option == '--pw':
pw = arg
while not user:
user = raw_input('Please enter your username: ')
while not pw:
pw = raw_input('Password: ')
if not pw:
print 'Password cannot be blank'
try:
sample = GCPIMDB(config, user, pw)
except gdata.client.BadAuthentication:
print 'Invalid credentials. WTF.'
return
sample.print_groups()
gid = sample.new_folder('Hurrah Testing', Folder.CONTACT_t)
#gid = 'http://www.google.com/m8/feeds/groups/karra.etc%40gmail.com/base/50fccc2a8e0100eb'
sample.del_folder(gid)
sample.print_groups()
if __name__ == '__main__':
logging.getLogger().setLevel(logging.DEBUG)
main()
......@@ -144,6 +144,45 @@ class TestGCContact:
sl = SyncLists(f, 'ol')
f.prep_sync_lists('ol', sl)
def test_pimdbgc ():
config = Config('../app_state.json')
# Parse command line options
try:
opts, args = getopt.getopt(sys.argv[1:], '', ['user=', 'pw='])
except getopt.error, msg:
print 'python gc_wrapper.py --user [username] --pw [password]'
sys.exit(2)
user = ''
pw = ''
# Process options
for option, arg in opts:
if option == '--user':
user = arg
elif option == '--pw':
pw = arg
while not user:
user = raw_input('Please enter your username: ')
while not pw:
pw = raw_input('Password: ')
if not pw:
print 'Password cannot be blank'
try:
sample = GCPIMDB(config, user, pw)
except gdata.client.BadAuthentication:
print 'Invalid credentials. WTF.'
return
sample.print_groups()
gid = sample.new_folder('Hurrah Testing', Folder.CONTACT_t)
#gid = 'http://www.google.com/m8/feeds/groups/karra.etc%40gmail.com/base/50fccc2a8e0100eb'
sample.del_folder(gid)
sample.print_groups()
if __name__ == '__main__':
logging.getLogger().setLevel(logging.DEBUG)
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment