86>Jan 29 02:33:48 userdel[4078888]: delete user 'rooter'
<86>Jan 29 02:33:48 userdel[4078888]: removed group 'rooter' owned by 'rooter'
<86>Jan 29 02:33:48 userdel[4078888]: removed shadow group 'rooter' owned by 'rooter'
<86>Jan 29 02:33:48 groupadd[4078912]: group added to /etc/group: name=rooter, GID=960
<86>Jan 29 02:33:48 groupadd[4078912]: group added to /etc/gshadow: name=rooter
<86>Jan 29 02:33:48 groupadd[4078912]: new group: name=rooter, GID=960
<86>Jan 29 02:33:48 useradd[4078938]: new user: name=rooter, UID=960, GID=960, home=/root, shell=/bin/bash
<86>Jan 29 02:33:48 userdel[4078978]: delete user 'builder'
<86>Jan 29 02:33:48 userdel[4078978]: removed group 'builder' owned by 'builder'
<86>Jan 29 02:33:48 groupadd[4079005]: group added to /etc/group: name=builder, GID=961
<86>Jan 29 02:33:48 groupadd[4079005]: group added to /etc/gshadow: name=builder
<86>Jan 29 02:33:48 groupadd[4079005]: new group: name=builder, GID=961
<86>Jan 29 02:33:48 useradd[4079023]: new user: name=builder, UID=961, GID=961, home=/usr/src, shell=/bin/bash
<13>Jan 29 02:33:50 rpmi: libgdbm-1.8.3-alt10 sisyphus+278100.1600.1.1 1626058413 installed
<13>Jan 29 02:33:50 rpmi: libexpat-2.4.3-alt1 sisyphus+293693.200.2.1 1642508362 installed
<13>Jan 29 02:33:50 rpmi: libp11-kit-0.24.1-alt1 sisyphus+293720.100.1.1 1642535264 installed
<13>Jan 29 02:33:50 rpmi: libtasn1-4.17.0-alt2 sisyphus+285706.100.1.1 1632328563 installed
<13>Jan 29 02:33:50 rpmi: rpm-macros-alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed
<13>Jan 29 02:33:50 rpmi: alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed
<13>Jan 29 02:33:50 rpmi: ca-certificates-2021.10.06-alt1 sisyphus+286526.200.1.1 1633528578 installed
<13>Jan 29 02:33:50 rpmi: ca-trust-0.1.2-alt1 sisyphus+233348.100.1.1 1561653823 installed
<13>Jan 29 02:33:50 rpmi: p11-kit-trust-0.24.1-alt1 sisyphus+293720.100.1.1 1642535264 installed
<13>Jan 29 02:33:50 rpmi: libcrypto1.1-1.1.1l-alt2 sisyphus+287339.100.1.1 1634383589 installed
<13>Jan 29 02:33:50 rpmi: libssl1.1-1.1.1l-alt2 sisyphus+287339.100.1.1 1634383589 installed
<13>Jan 29 02:33:50 rpmi: python3-3.9.9-alt1 sisyphus+291125.100.2.1 1638385948 installed
<13>Jan 29 02:33:50 rpmi: python3-base-3.9.9-alt1 sisyphus+291125.100.2.1 1638385948 installed
<13>Jan 29 02:33:50 rpmi: tests-for-installed-python3-pkgs-0.1.18-alt1 sisyphus+290420.100.1.1 1637593698 installed
<13>Jan 29 02:33:50 rpmi: rpm-build-python3-0.1.18-alt1 sisyphus+290420.100.1.1 1637593698 installed
<13>Jan 29 02:33:51 rpmi: libpython-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:51 rpmi: python2-base-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:51 rpmi: python-modules-encodings-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:51 rpmi: python-modules-compiler-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:51 rpmi: python-modules-email-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:51 rpmi: python-modules-unittest-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:52 rpmi: python-modules-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:52 rpmi: libffi7-1:3.3-alt2 sisyphus+287337.160.5.1 1634396592 installed
<13>Jan 29 02:33:52 rpmi: python-modules-ctypes-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:52 rpmi: python-modules-multiprocessing-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:52 rpmi: python-modules-logging-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
<13>Jan 29 02:33:52 rpmi: python-tools-2to3-2.7.18-alt8 sisyphus+286676.100.1.1 1633726916 installed
Building target platforms: x86_64
Building for target x86_64
Wrote: /usr/src/in/nosrpm/python3-module-gdata-2.0.18-alt4.nosrc.rpm (w1.gzdio)
<13>Jan 29 02:33:53 rpmi: python3-module-pkg_resources-1:60.5.4-alt1 sisyphus+293292.1330.5.1 1642856709 installed
<13>Jan 29 02:33:53 rpmi: libpython3-3.9.9-alt1 sisyphus+291125.100.2.1 1638385948 installed
<13>Jan 29 02:33:53 rpmi: libncurses-6.3.20211106-alt1 sisyphus+289273.100.1.1 1636477028 installed
<13>Jan 29 02:33:53 rpmi: libtinfo-devel-6.3.20211106-alt1 sisyphus+289273.100.1.1 1636477028 installed
<13>Jan 29 02:33:53 rpmi: libncurses-devel-6.3.20211106-alt1 sisyphus+289273.100.1.1 1636477028 installed
<13>Jan 29 02:33:53 rpmi: python3-dev-3.9.9-alt1 sisyphus+291125.100.2.1 1638385948 installed
<13>Jan 29 02:33:53 rpmi: python3-module-setuptools-1:60.5.4-alt1 sisyphus+293292.1330.5.1 1642856709 installed
Installing python3-module-gdata-2.0.18-alt4.src.rpm
Building target platforms: x86_64
Building for target x86_64
Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.42150
+ umask 022
+ /bin/mkdir -p /usr/src/RPM/BUILD
+ cd /usr/src/RPM/BUILD
+ cd /usr/src/RPM/BUILD
+ rm -rf python3-module-gdata-2.0.18
+ echo 'Source #0 (python3-module-gdata-2.0.18-alt4.tar):'
Source #0 (python3-module-gdata-2.0.18-alt4.tar):
+ /bin/tar -xf /usr/src/RPM/SOURCES/python3-module-gdata-2.0.18-alt4.tar
+ cd python3-module-gdata-2.0.18
+ /bin/chmod -c -Rf u+rwX,go-w .
+ echo 'Patch #0 (port-on-python3.patch):'
Patch #0 (port-on-python3.patch):
+ /usr/bin/patch -p1
patching file src/gdata/contacts/client.py
+ rm -f samples/apps/emailsettings_pop_settings.py
+ find ./ -type f -name '*.py' -exec 2to3 -w -n '{}' +
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored ./upload-diffs.py
--- ./upload-diffs.py (original)
+++ ./upload-diffs.py (refactored)
@@ -31,8 +31,8 @@
# This code is derived from appcfg.py in the App Engine SDK (open source),
# and from ASPN recipe #146306.
-import ConfigParser
-import cookielib
+import configparser
+import http.cookiejar
import fnmatch
import getpass
import logging
@@ -43,9 +43,9 @@
import socket
import subprocess
import sys
-import urllib
-import urllib2
-import urlparse
+import urllib.request, urllib.parse, urllib.error
+import urllib.request, urllib.error, urllib.parse
+import urllib.parse
# The md5 module was deprecated in Python 2.5.
try:
@@ -107,15 +107,15 @@
last_email = last_email_file.readline().strip("\n")
last_email_file.close()
prompt += " [%s]" % last_email
- except IOError, e:
+ except IOError as e:
pass
- email = raw_input(prompt + ": ").strip()
+ email = input(prompt + ": ").strip()
if email:
try:
last_email_file = open(last_email_file_name, "w")
last_email_file.write(email)
last_email_file.close()
- except IOError, e:
+ except IOError as e:
pass
else:
email = last_email
@@ -131,20 +131,20 @@
msg: The string to print.
"""
if verbosity > 0:
- print msg
+ print(msg)
def ErrorExit(msg):
"""Print an error message to stderr and exit."""
- print >>sys.stderr, msg
+ print(msg, file=sys.stderr)
sys.exit(1)
-class ClientLoginError(urllib2.HTTPError):
+class ClientLoginError(urllib.error.HTTPError):
"""Raised to indicate there was an error authenticating with ClientLogin."""
def __init__(self, url, code, msg, headers, args):
- urllib2.HTTPError.__init__(self, url, code, msg, headers, None)
+ urllib.error.HTTPError.__init__(self, url, code, msg, headers, None)
self.args = args
self.reason = args["Error"]
@@ -190,10 +190,10 @@
def _CreateRequest(self, url, data=None):
"""Creates a new urllib request."""
logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
- req = urllib2.Request(url, data=data)
+ req = urllib.request.Request(url, data=data)
if self.host_override:
req.add_header("Host", self.host_override)
- for key, value in self.extra_headers.iteritems():
+ for key, value in self.extra_headers.items():
req.add_header(key, value)
return req
@@ -217,7 +217,7 @@
account_type = "HOSTED"
req = self._CreateRequest(
url="https://www.google.com/accounts/ClientLogin",
- data=urllib.urlencode({
+ data=urllib.parse.urlencode({
"Email": email,
"Passwd": password,
"service": "ah",
@@ -231,7 +231,7 @@
response_dict = dict(x.split("=")
for x in response_body.split("\n") if x)
return response_dict["Auth"]
- except urllib2.HTTPError, e:
+ except urllib.error.HTTPError as e:
if e.code == 403:
body = e.read()
response_dict = dict(x.split("=", 1) for x in body.split("\n") if x)
@@ -253,14 +253,14 @@
continue_location = "http://localhost/"
args = {"continue": continue_location, "auth": auth_token}
req = self._CreateRequest("http://%s/_ah/login?%s" %
- (self.host, urllib.urlencode(args)))
+ (self.host, urllib.parse.urlencode(args)))
try:
response = self.opener.open(req)
- except urllib2.HTTPError, e:
+ except urllib.error.HTTPError as e:
response = e
if (response.code != 302 or
response.info()["location"] != continue_location):
- raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,
+ raise urllib.error.HTTPError(req.get_full_url(), response.code, response.msg,
response.headers, response.fp)
self.authenticated = True
@@ -283,34 +283,34 @@
credentials = self.auth_function()
try:
auth_token = self._GetAuthToken(credentials[0], credentials[1])
- except ClientLoginError, e:
+ except ClientLoginError as e:
if e.reason == "BadAuthentication":
- print >>sys.stderr, "Invalid username or password."
+ print("Invalid username or password.", file=sys.stderr)
continue
if e.reason == "CaptchaRequired":
- print >>sys.stderr, (
+ print((
"Please go to\n"
"https://www.google.com/accounts/DisplayUnlockCaptcha\n"
- "and verify you are a human. Then try again.")
+ "and verify you are a human. Then try again."), file=sys.stderr)
break
if e.reason == "NotVerified":
- print >>sys.stderr, "Account not verified."
+ print("Account not verified.", file=sys.stderr)
break
if e.reason == "TermsNotAgreed":
- print >>sys.stderr, "User has not agreed to TOS."
+ print("User has not agreed to TOS.", file=sys.stderr)
break
if e.reason == "AccountDeleted":
- print >>sys.stderr, "The user account has been deleted."
+ print("The user account has been deleted.", file=sys.stderr)
break
if e.reason == "AccountDisabled":
- print >>sys.stderr, "The user account has been disabled."
+ print("The user account has been disabled.", file=sys.stderr)
break
if e.reason == "ServiceDisabled":
- print >>sys.stderr, ("The user's access to the service has been "
- "disabled.")
+ print(("The user's access to the service has been "
+ "disabled."), file=sys.stderr)
break
if e.reason == "ServiceUnavailable":
- print >>sys.stderr, "The service is not available; try again later."
+ print("The service is not available; try again later.", file=sys.stderr)
break
raise
self._GetAuthCookie(auth_token)
@@ -347,7 +347,7 @@
args = dict(kwargs)
url = "http://%s%s" % (self.host, request_path)
if args:
- url += "?" + urllib.urlencode(args)
+ url += "?" + urllib.parse.urlencode(args)
req = self._CreateRequest(url=url, data=payload)
req.add_header("Content-Type", content_type)
try:
@@ -355,7 +355,7 @@
response = f.read()
f.close()
return response
- except urllib2.HTTPError, e:
+ except urllib.error.HTTPError as e:
if tries > 3:
raise
elif e.code == 401 or e.code == 302:
@@ -385,35 +385,35 @@
Returns:
A urllib2.OpenerDirector object.
"""
- opener = urllib2.OpenerDirector()
- opener.add_handler(urllib2.ProxyHandler())
- opener.add_handler(urllib2.UnknownHandler())
- opener.add_handler(urllib2.HTTPHandler())
- opener.add_handler(urllib2.HTTPDefaultErrorHandler())
- opener.add_handler(urllib2.HTTPSHandler())
+ opener = urllib.request.OpenerDirector()
+ opener.add_handler(urllib.request.ProxyHandler())
+ opener.add_handler(urllib.request.UnknownHandler())
+ opener.add_handler(urllib.request.HTTPHandler())
+ opener.add_handler(urllib.request.HTTPDefaultErrorHandler())
+ opener.add_handler(urllib.request.HTTPSHandler())
opener.add_handler(urllib2.HTTPErrorProcessor())
if self.save_cookies:
self.cookie_file = os.path.expanduser("~/.codereview_upload_cookies")
- self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file)
+ self.cookie_jar = http.cookiejar.MozillaCookieJar(self.cookie_file)
if os.path.exists(self.cookie_file):
try:
self.cookie_jar.load()
self.authenticated = True
StatusUpdate("Loaded authentication cookies from %s" %
self.cookie_file)
- except (cookielib.LoadError, IOError):
+ except (http.cookiejar.LoadError, IOError):
# Failed to load cookies - just ignore them.
pass
else:
# Create an empty cookie file with mode 600
- fd = os.open(self.cookie_file, os.O_CREAT, 0600)
+ fd = os.open(self.cookie_file, os.O_CREAT, 0o600)
os.close(fd)
# Always chmod the cookie file
- os.chmod(self.cookie_file, 0600)
+ os.chmod(self.cookie_file, 0o600)
else:
# Don't save cookies across runs of update.py.
- self.cookie_jar = cookielib.CookieJar()
- opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar))
+ self.cookie_jar = http.cookiejar.CookieJar()
+ opener.add_handler(urllib.request.HTTPCookieProcessor(self.cookie_jar))
return opener
@@ -605,7 +605,7 @@
line = p.stdout.readline()
if not line:
break
- print line.strip("\n")
+ print(line.strip("\n"))
output_array.append(line)
output = "".join(output_array)
else:
@@ -613,7 +613,7 @@
p.wait()
errout = p.stderr.read()
if print_output and errout:
- print >>sys.stderr, errout
+ print(errout, file=sys.stderr)
p.stdout.close()
p.stderr.close()
return output, p.returncode
@@ -659,11 +659,11 @@
"""Show an "are you sure?" prompt if there are unknown files."""
unknown_files = self.GetUnknownFiles()
if unknown_files:
- print "The following files are not added to version control:"
+ print("The following files are not added to version control:")
for line in unknown_files:
- print line
+ print(line)
prompt = "Are you sure to continue?(y/N) "
- answer = raw_input(prompt).strip()
+ answer = input(prompt).strip()
if answer != "y":
ErrorExit("User aborted")
@@ -715,13 +715,13 @@
else:
type = "current"
if len(content) > MAX_UPLOAD_SIZE:
- print ("Not uploading the %s file for %s because it's too large." %
- (type, filename))
+ print(("Not uploading the %s file for %s because it's too large." %
+ (type, filename)))
file_too_large = True
content = ""
checksum = md5(content).hexdigest()
if options.verbose > 0 and not file_too_large:
- print "Uploading %s file for %s" % (type, filename)
+ print("Uploading %s file for %s" % (type, filename))
url = "/%d/upload_content/%d/%d" % (int(issue), int(patchset), file_id)
form_fields = [("filename", filename),
("status", status),
@@ -743,7 +743,7 @@
patches = dict()
[patches.setdefault(v, k) for k, v in patch_list]
- for filename in patches.keys():
+ for filename in list(patches.keys()):
base_content, new_content, is_binary, status = files[filename]
file_id_str = patches.get(filename)
if file_id_str.find("nobase") != -1:
@@ -810,8 +810,8 @@
words = line.split()
if len(words) == 2 and words[0] == "URL:":
url = words[1]
- scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
- username, netloc = urllib.splituser(netloc)
+ scheme, netloc, path, params, query, fragment = urllib.parse.urlparse(url)
+ username, netloc = urllib.parse.splituser(netloc)
if username:
logging.info("Removed username from base URL")
if netloc.endswith("svn.python.org"):
@@ -829,12 +829,12 @@
logging.info("Guessed CollabNet base = %s", base)
elif netloc.endswith(".googlecode.com"):
path = path + "/"
- base = urlparse.urlunparse(("http", netloc, path, params,
+ base = urllib.parse.urlunparse(("http", netloc, path, params,
query, fragment))
logging.info("Guessed Google Code base = %s", base)
else:
path = path + "/"
- base = urlparse.urlunparse((scheme, netloc, path, params,
+ base = urllib.parse.urlunparse((scheme, netloc, path, params,
query, fragment))
logging.info("Guessed base = %s", base)
return base
@@ -1320,8 +1320,8 @@
rv = []
for patch in patches:
if len(patch[1]) > MAX_UPLOAD_SIZE:
- print ("Not uploading the patch for " + patch[0] +
- " because the file is too large.")
+ print(("Not uploading the patch for " + patch[0] +
+ " because the file is too large."))
continue
form_fields = [("filename", patch[0])]
if not options.download_base:
@@ -1329,7 +1329,7 @@
files = [("data", "data.diff", patch[1])]
ctype, body = EncodeMultipartFormData(form_fields, files)
url = "/%d/upload_patch/%d" % (int(issue), int(patchset))
- print "Uploading patch for " + patch[0]
+ print("Uploading patch for " + patch[0])
response_body = rpc_server.Send(url, body, content_type=ctype)
lines = response_body.splitlines()
if not lines or lines[0] != "OK":
@@ -1358,7 +1358,8 @@
out, returncode = RunShellWithReturnCode(["hg", "root"])
if returncode == 0:
return (VCS_MERCURIAL, out.strip())
- except OSError, (errno, message):
+ except OSError as xxx_todo_changeme:
+ (errno, message) = xxx_todo_changeme.args
if errno != 2: # ENOENT -- they don't have hg installed.
raise
@@ -1374,7 +1375,8 @@
"--is-inside-work-tree"])
if returncode == 0:
return (VCS_GIT, None)
- except OSError, (errno, message):
+ except OSError as xxx_todo_changeme1:
+ (errno, message) = xxx_todo_changeme1.args
if errno != 2: # ENOENT -- they don't have git installed.
raise
@@ -1450,7 +1452,7 @@
subversion_config = os.path.expanduser("~/.subversion/config")
if not os.path.exists(subversion_config):
return {}
- config = ConfigParser.ConfigParser()
+ config = configparser.ConfigParser()
config.read(subversion_config)
if (config.has_section("miscellany") and
config.has_option("miscellany", "enable-auto-props") and
@@ -1505,7 +1507,7 @@
svn_auto_props_map = LoadSubversionAutoProperties()
all_props = []
- for file_pattern, props in svn_auto_props_map.items():
+ for file_pattern, props in list(svn_auto_props_map.items()):
if fnmatch.fnmatch(filename, file_pattern):
all_props.extend(props)
if all_props:
@@ -1575,8 +1577,8 @@
guessed_base = vcs.GuessBase(options.download_base)
if base:
if guessed_base and base != guessed_base:
- print "Using base URL \"%s\" from --base_url instead of \"%s\"" % \
- (base, guessed_base)
+ print("Using base URL \"%s\" from --base_url instead of \"%s\"" % \
+ (base, guessed_base))
else:
base = guessed_base
@@ -1589,12 +1591,12 @@
data = vcs.GenerateDiff(args)
files = vcs.GetBaseFiles(data)
if verbosity >= 1:
- print "Upload server:", options.server, "(change with -s/--server)"
+ print("Upload server:", options.server, "(change with -s/--server)")
if options.issue:
prompt = "Message describing this patch set: "
else:
prompt = "New issue subject: "
- message = options.message or raw_input(prompt).strip()
+ message = options.message or input(prompt).strip()
if not message:
ErrorExit("A non-empty message is required")
rpc_server = GetRpcServer(options)
@@ -1625,7 +1627,7 @@
# Send a hash of all the base file so the server can determine if a copy
# already exists in an earlier patchset.
base_hashes = ""
- for file, info in files.iteritems():
+ for file, info in files.items():
if not info[0] is None:
checksum = md5(info[0]).hexdigest()
if base_hashes:
@@ -1634,7 +1636,7 @@
form_fields.append(("base_hashes", base_hashes))
if options.private:
if options.issue:
- print "Warning: Private flag ignored when updating an existing issue."
+ print("Warning: Private flag ignored when updating an existing issue.")
else:
form_fields.append(("private", "1"))
# If we're uploading base files, don't send the email before the uploads, so
@@ -1644,7 +1646,7 @@
if not options.download_base:
form_fields.append(("content_upload", "1"))
if len(data) > MAX_UPLOAD_SIZE:
- print "Patch is large, so uploading file patches separately."
+ print("Patch is large, so uploading file patches separately.")
uploaded_diff_file = []
foRefactoringTool: Refactored ./tests/run_service_tests.py
RefactoringTool: Refactored ./tests/run_data_tests.py
rm_fields.append(("separate_patches", "1"))
else:
@@ -1684,7 +1686,7 @@
try:
RealMain(sys.argv)
except KeyboardInterrupt:
- print
+ print()
StatusUpdate("Interrupted.")
sys.exit(1)
--- ./tests/run_service_tests.py (original)
+++ ./tests/run_service_tests.py (refactored)
@@ -2,24 +2,24 @@
import sys
import unittest
-import module_test_runner
+from . import module_test_runner
import getopt
import getpass
# Modules whose tests we will run.
-import atom_tests.service_test
-import gdata_tests.service_test
-import gdata_tests.apps.service_test
-import gdata_tests.calendar.service_test
-import gdata_tests.docs.service_test
-import gdata_tests.health.service_test
-import gdata_tests.spreadsheet.service_test
-import gdata_tests.spreadsheet.text_db_test
-import gdata_tests.photos.service_test
-import gdata_tests.contacts.service_test
-import gdata_tests.blogger.service_test
-import gdata_tests.youtube.service_test
-import gdata_tests.contacts.profiles.service_test
+from . import atom_tests.service_test
+from . import gdata_tests.service_test
+from . import gdata_tests.apps.service_test
+from . import gdata_tests.calendar.service_test
+from . import gdata_tests.docs.service_test
+from . import gdata_tests.health.service_test
+from . import gdata_tests.spreadsheet.service_test
+from . import gdata_tests.spreadsheet.text_db_test
+from . import gdata_tests.photos.service_test
+from . import gdata_tests.contacts.service_test
+from . import gdata_tests.blogger.service_test
+from . import gdata_tests.youtube.service_test
+from . import gdata_tests.contacts.profiles.service_test
def RunAllTests(username, password, spreadsheet_key, worksheet_key,
@@ -85,21 +85,21 @@
print ('Missing --user and --pw command line arguments, '
'prompting for credentials.')
if username == '':
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
if password == '':
password = getpass.getpass()
if spreadsheet_key == '':
- spreadsheet_key = raw_input(
+ spreadsheet_key = input(
'Please enter the key for the test spreadsheet: ')
if worksheet_key == '':
- worksheet_key = raw_input(
+ worksheet_key = input(
'Please enter the id for the worksheet to be edited: ')
if apps_username == '':
- apps_username = raw_input('Please enter your Google Apps admin username: ')
+ apps_username = input('Please enter your Google Apps admin username: ')
if apps_password == '':
apps_password = getpass.getpass()
if apps_domain == '':
- apps_domain = raw_input('Please enter your Google Apps domain: ')
+ apps_domain = input('Please enter your Google Apps domain: ')
RunAllTests(username, password, spreadsheet_key, worksheet_key,
apps_username, apps_password, apps_domain)
--- ./tests/run_data_tests.py (original)
+++ ./tests/run_data_tests.py (refactored)
@@ -2,33 +2,33 @@
import sys
import unittest
-import module_test_runner
+from . import module_test_runner
import getopt
import getpass
# Modules whose tests we will run.
-import gdata_test
-import atom_test
-import atom_tests.http_interface_test
-import atom_tests.mock_http_test
-import atom_tests.token_store_test
-import atom_tests.url_test
-import atom_tests.core_test
-import gdata_tests.apps.emailsettings.data_test
-import gdata_tests.apps.multidomain.data_test
-import gdata_tests.apps_test
-import gdata_tests.auth_test
-import gdata_tests.blogger_test
-import gdata_tests.calendar_test
-import gdata_tests.calendar_resource.data_test
-import gdata_tests.client_test
-import gdata_tests.codesearch_test
-import gdata_tests.contacts_test
-import gdata_tests.docs_test
-import gdata_tests.photos_test
-import gdata_tests.spreadsheet_test
-import gdata_tests.youtube_test
-import gdata_tests.webmastertools_test
-import gdata_tests.oauth.data_test
+from . import gdata_test
+from . import atom_test
+from . import atom_tests.http_interface_test
+from . import atom_tests.mock_http_test
+from . import atom_tests.token_store_test
+fromRefactoringTool: Refactored ./tests/run_all_tests.py
RefactoringTool: Refactored ./tests/module_test_runner.py
RefactoringTool: Refactored ./tests/gdata_tests/youtube_test.py
. import atom_tests.url_test
+from . import atom_tests.core_test
+from . import gdata_tests.apps.emailsettings.data_test
+from . import gdata_tests.apps.multidomain.data_test
+from . import gdata_tests.apps_test
+from . import gdata_tests.auth_test
+from . import gdata_tests.blogger_test
+from . import gdata_tests.calendar_test
+from . import gdata_tests.calendar_resource.data_test
+from . import gdata_tests.client_test
+from . import gdata_tests.codesearch_test
+from . import gdata_tests.contacts_test
+from . import gdata_tests.docs_test
+from . import gdata_tests.photos_test
+from . import gdata_tests.spreadsheet_test
+from . import gdata_tests.youtube_test
+from . import gdata_tests.webmastertools_test
+from . import gdata_tests.oauth.data_test
def RunAllTests():
--- ./tests/run_all_tests.py (original)
+++ ./tests/run_all_tests.py (refactored)
@@ -22,9 +22,9 @@
import unittest
import getopt
import getpass
-import module_test_runner
-import run_data_tests
-import run_service_tests
+from . import module_test_runner
+from . import run_data_tests
+from . import run_service_tests
if __name__ == '__main__':
--- ./tests/module_test_runner.py (original)
+++ ./tests/module_test_runner.py (refactored)
@@ -44,7 +44,7 @@
runner = unittest.TextTestRunner(verbosity=2)
for module in self.modules:
# Set any module variables according to the contents in the settings
- for setting, value in self.settings.iteritems():
+ for setting, value in self.settings.items():
try:
setattr(module, setting, value)
except AttributeError:
--- ./tests/gdata_tests/youtube_test.py (original)
+++ ./tests/gdata_tests/youtube_test.py (refactored)
@@ -34,141 +34,141 @@
test_data.YOUTUBE_VIDEO_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(self.video_feed.id.text,
+ self.assertEqual(self.video_feed.id.text,
'http://gdata.youtube.com/feeds/api/standardfeeds/top_rated')
- self.assertEquals(len(self.video_feed.entry), 2)
+ self.assertEqual(len(self.video_feed.entry), 2)
for entry in self.video_feed.entry:
if (entry.id.text ==
'http://gdata.youtube.com/feeds/api/videos/C71ypXYGho8'):
- self.assertEquals(entry.published.text, '2008-03-20T10:17:27.000-07:00')
- self.assertEquals(entry.updated.text, '2008-05-14T04:26:37.000-07:00')
- self.assertEquals(entry.category[0].scheme,
+ self.assertEqual(entry.published.text, '2008-03-20T10:17:27.000-07:00')
+ self.assertEqual(entry.updated.text, '2008-05-14T04:26:37.000-07:00')
+ self.assertEqual(entry.category[0].scheme,
'http://gdata.youtube.com/schemas/2007/keywords.cat')
- self.assertEquals(entry.category[0].term, 'karyn')
- self.assertEquals(entry.category[1].scheme,
+ self.assertEqual(entry.category[0].term, 'karyn')
+ self.assertEqual(entry.category[1].scheme,
'http://gdata.youtube.com/schemas/2007/keywords.cat')
- self.assertEquals(entry.category[1].term, 'garcia')
- self.assertEquals(entry.category[2].scheme,
+ self.assertEqual(entry.category[1].term, 'garcia')
+ self.assertEqual(entry.category[2].scheme,
'http://gdata.youtube.com/schemas/2007/keywords.cat')
- self.assertEquals(entry.category[2].term, 'me')
- self.assertEquals(entry.category[3].scheme,
+ self.assertEqual(entry.category[2].term, 'me')
+ self.assertEqual(entry.category[3].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(entry.category[3].term,
+ self.assertEqual(entry.category[3].term,
'http://gdata.youtube.com/schemas/2007#video')
- self.assertEquals(entry.title.text,
+ self.assertEqual(entry.title.text,
'Me odeio por te amar - KARYN GARCIA')
- self.assertEquals(entry.content.text, 'http://www.karyngarcia.com.br')
- self.assertEquals(entry.link[0].rel, 'alternate')
- self.assertEquals(entry.link[0].href,
+ self.assertEqual(entry.content.text, 'http://www.karyngarcia.com.br')
+ self.assertEqual(entry.link[0].rel, 'alternate')
+ self.assertEqual(entry.link[0].href,
'http://www.youtube.com/watch?v=C71ypXYGho8')
- self.assertEquals(entry.link[1].rel,
+ self.assertEqual(entry.link[1].rel,
'http://gdata.youtube.com/schemas/2007#video.related')
- self.assertEquals(entry.link[1].href,
+ self.assertEqual(entry.link[1].href,
'http://gdata.youtube.com/feeds/api/videos/C71ypXYGho8/related')
- self.assertEquals(entry.link[2].rel, 'self')
- self.assertEquals(entry.link[2].href,
+ self.assertEqual(entry.link[2].rel, 'self')
+ self.assertEqual(entry.link[2].href,
('http://gdata.youtube.com/feeds/api/standardfeeds'
'/top_rated/C71ypXYGho8'))
- self.assertEquals(entry.author[0].name.text, 'TvKarynGarcia')
- self.assertEquals(entry.author[0].uri.text,
+ self.assertEqual(entry.author[0].name.text, 'TvKarynGarcia')
+ self.assertEqual(entry.author[0].uri.text,
'http://gdata.youtube.com/feeds/api/users/tvkaryngarcia')
- self.assertEquals(entry.media.title.text,
+ self.assertEqual(entry.media.title.text,
'Me odeio por te amar - KARYN GARCIA')
- self.assertEquals(entry.media.description.text,
+ self.assertEqual(entry.media.description.text,
'http://www.karyngarcia.com.br')
- self.assertEquals(entry.media.keywords.text,
+ self.assertEqual(entry.media.keywords.text,
'amar, boyfriend, garcia, karyn, me, odeio, por, te')
- self.assertEquals(entry.media.duration.seconds, '203')
- self.assertEquals(entry.media.category[0].label, 'Music')
- self.assertEquals(entry.media.category[0].scheme,
+ self.assertEqual(entry.media.duration.seconds, '203')
+ self.assertEqual(entry.media.category[0].label, 'Music')
+ self.assertEqual(entry.media.category[0].scheme,
'http://gdata.youtube.com/schemas/2007/categories.cat')
- self.assertEquals(entry.media.category[0].text, 'Music')
- self.assertEquals(entry.media.category[1].label, 'test111')
- self.assertEquals(entry.media.category[1].scheme,
+ self.assertEqual(entry.media.category[0].text, 'Music')
+ self.assertEqual(entry.media.category[1].label, 'test111')
+ self.assertEqual(entry.media.category[1].scheme,
'http://gdata.youtube.com/schemas/2007/developertags.cat')
- self.assertEquals(entry.media.category[1].text, 'test111')
- self.assertEquals(entry.media.category[2].label, 'test222')
- self.assertEquals(entry.media.category[2].scheme,
+ self.assertEqual(entry.media.category[1].text, 'test111')
+ self.assertEqual(entry.media.category[2].label, 'test222')
+ self.assertEqual(entry.media.category[2].scheme,
'http://gdata.youtube.com/schemas/2007/developertags.cat')
- self.assertEquals(entry.media.category[2].text, 'test222')
- self.assertEquals(entry.media.content[0].url,
+ self.assertEqual(entry.media.category[2].text, 'test222')
+ self.assertEqual(entry.media.content[0].url,
'http://www.youtube.com/v/C71ypXYGho8')
- self.assertEquals(entry.media.content[0].type,
+ self.assertEqual(entry.media.content[0].type,
'application/x-shockwave-flash')
- self.assertEquals(entry.media.content[0].medium, 'video')
- self.assertEquals(
+ self.assertEqual(entry.media.content[0].medium, 'video')
+ self.assertEqual(
entry.media.content[0].extension_attributes['isDefault'], 'true')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[0].extension_attributes['expression'], 'full')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[0].extension_attributes['duration'], '203')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[0].extension_attributes[YT_FORMAT], '5')
- self.assertEquals(entry.media.content[1].url,
+ self.assertEqual(entry.media.content[1].url,
('rtsp://rtsp2.youtube.com/ChoLENy73wIaEQmPhgZ2pXK9CxMYDSANFEgGDA'
'==/0/0/0/video.3gp'))
- self.assertEquals(entry.media.content[1].type, 'video/3gpp')
- self.assertEquals(entry.media.content[1].medium, 'video')
- self.assertEquals(
+ self.assertEqual(entry.media.content[1].type, 'video/3gpp')
+ self.assertEqual(entry.media.content[1].medium, 'video')
+ self.assertEqual(
entry.media.content[1].extension_attributes['expression'], 'full')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[1].extension_attributes['duration'], '203')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[1].extension_attributes[YT_FORMAT], '1')
- self.assertEquals(entry.media.content[2].url,
+ self.assertEqual(entry.media.content[2].url,
('rtsp://rtsp2.youtube.com/ChoLENy73wIaEQmPhgZ2pXK9CxMYESARFEgGDA=='
'/0/0/0/video.3gp'))
- self.assertEquals(entry.media.content[2].type, 'video/3gpp')
- self.assertEquals(entry.media.content[2].medium, 'video')
- self.assertEquals(
+ self.assertEqual(entry.media.content[2].type, 'video/3gpp')
+ self.assertEqual(entry.media.content[2].medium, 'video')
+ self.assertEqual(
entry.media.content[2].extension_attributes['expression'], 'full')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[2].extension_attributes['duration'], '203')
- self.assertEquals(
+ self.assertEqual(
entry.media.content[2].extension_attributes[YT_FORMAT], '6')
- self.assertEquals(entry.media.player.url,
+ self.assertEqual(entry.media.player.url,
'http://www.youtube.com/watch?v=C71ypXYGho8')
- self.assertEquals(entry.media.thumbnail[0].url,
+ self.assertEqual(entry.media.thumbnail[0].url,
'http://img.youtube.com/vi/C71ypXYGho8/2.jpg')
- self.assertEquals(entry.media.thumbnail[0].height, '97')
- self.assertEquals(entry.media.thumbnail[0].width, '130')
- self.assertEquals(entry.media.thumbnail[0].extension_attributes['time'],
+ self.assertEqual(entry.media.thumbnail[0].height, '97')
+ self.assertEqual(entry.media.thumbnail[0].width, '130')
+ self.assertEqual(entry.media.thumbnail[0].extension_attributes['time'],
'00:01:41.500')
- self.assertEquals(entry.media.thumbnail[1].url,
+ self.assertEqual(entry.media.thumbnail[1].url,
'http://img.youtube.com/vi/C71ypXYGho8/1.jpg')
- self.assertEquals(entry.media.thumbnail[1].height, '97')
- self.assertEquals(entry.media.thumbnail[1].width, '130')
- self.assertEquals(entry.media.thumbnail[1].extension_attributes['time'],
+ self.assertEqual(entry.media.thumbnail[1].height, '97')
+ self.assertEqual(entry.media.thumbnail[1].width, '130')
+ self.assertEqual(entry.media.thumbnail[1].extension_attributes['time'],
'00:00:50.750')
- self.assertEquals(entry.media.thumbnail[2].url,
+ self.assertEqual(entry.media.thumbnail[2].url,
'http://img.youtube.com/vi/C71ypXYGho8/3.jpg')
- self.assertEquals(entry.media.thumbnail[2].height, '97')
- self.assertEquals(entry.media.thumbnail[2].width, '130')
- self.assertEquals(entry.media.thumbnail[2].extension_attributes['time'],
+ self.assertEqual(entry.media.thumbnail[2].height, '97')
+ self.assertEqual(entry.media.thumbnail[2].width, '130')
+ self.assertEqual(entry.media.thumbnail[2].extension_attributes['time'],
'00:02:32.250')
- self.assertEquals(entry.media.thumbnail[3].url,
+ self.assertEqual(entry.media.thumbnail[3].url,
'http://img.youtube.com/vi/C71ypXYGho8/0.jpg')
- self.assertEquals(entry.media.thumbnail[3].height, '240')
- self.assertEquals(entry.media.thumbnail[3].width, '320')
- self.assertEquals(entry.media.thumbnail[3].extension_attributes['time'],
+ self.assertEqual(entry.media.thumbnail[3].height, '240')
+ self.assertEqual(entry.media.thumbnail[3].width, '320')
+ self.assertEqual(entry.media.thumbnail[3].extension_attributes['time'],
'00:01:41.500')
- self.assertEquals(entry.statistics.view_count, '138864')
- self.assertEquals(entry.statistics.favorite_count, '2474')
- self.assertEquals(entry.rating.min, '1')
- self.assertEquals(entry.rating.max, '5')
- self.assertEquals(entry.rating.num_raters, '4626')
- self.assertEquals(entry.rating.average, '4.95')
- self.assertEquals(entry.comments.feed_link[0].href,
+ self.assertEqual(entry.statistics.view_count, '138864')
+ self.assertEqual(entry.statistics.favorite_count, '2474')
+ self.assertEqual(entry.rating.min, '1')
+ self.assertEqual(entry.rating.max, '5')
+ self.assertEqual(entry.rating.num_raters, '4626')
+ self.assertEqual(entry.rating.average, '4.95')
+ self.assertEqual(entry.comments.feed_link[0].href,
('http://gdata.youtube.com/feeds/api/videos/'
'C71ypXYGho8/comments'))
- self.assertEquals(entry.comments.feed_link[0].count_hint, '27')
-
- self.assertEquals(entry.GetSwfUrl(),
+ self.assertEqual(entry.comments.feed_link[0].count_hint, '27')
+
+ self.assertEqual(entry.GetSwfUrl(),
'http://www.youtube.com/v/C71ypXYGho8')
- self.assertEquals(entry.GetYouTubeCategoryAsString(), 'Music')
+ self.assertEqual(entry.GetYouTubeCategoryAsString(), 'Music')
class VideoEntryPrivateTest(unittest.TestCase):
@@ -178,9 +178,9 @@
test_data.YOUTUBE_ENTRY_PRIVATE)
def testCorrectXmlParsing(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.youtube.YouTubeVideoEntry))
- self.assert_(self.entry.media.private)
+ self.assertTrue(self.entry.media.private)
class VideoFeedTest(unittest.TestCase):
@@ -190,39 +190,39 @@
test_data.YOUTUBE_VIDEO_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(self.feed.id.text,
+ self.assertEqual(self.feed.id.text,
'http://gdata.youtube.com/feeds/api/standardfeeds/top_rated')
- self.assertEquals(self.feed.generator.text, 'YouTube data API')
- self.assertEquals(self.feed.generator.uri, 'http://gdata.youtube.com/')
- self.assertEquals(len(self.feed.author), 1)
- self.assertEquals(self.feed.author[0].name.text, 'YouTube')
- self.assertEquals(len(self.feed.category), 1)
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(self.feed.generator.text, 'YouTube data API')
+ self.assertEqual(self.feed.generator.uri, 'http://gdata.youtube.com/')
+ self.assertEqual(len(self.feed.author), 1)
+ self.assertEqual(self.feed.author[0].name.text, 'YouTube')
+ self.assertEqual(len(self.feed.category), 1)
+ self.assertEqual(self.feed.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#video')
- self.assertEquals(self.feed.items_per_page.text, '25')
- self.assertEquals(len(self.feed.link), 4)
- self.assertEquals(self.feed.link[0].href,
+ self.assertEqual(self.feed.items_per_page.text, '25')
+ self.assertEqual(len(self.feed.link), 4)
+ self.assertEqual(self.feed.link[0].href,
'http://www.youtube.com/browse?s=tr')
- self.assertEquals(self.feed.link[0].rel, 'alternate')
- self.assertEquals(self.feed.link[1].href,
+ self.assertEqual(self.feed.link[0].rel, 'alternate')
+ self.assertEqual(self.feed.link[1].href,
'http://gdata.youtube.com/feeds/api/standardfeeds/top_rated')
- self.assertEquals(self.feed.link[1].rel,
+ self.assertEqual(self.feed.link[1].rel,
'http://schemas.google.com/g/2005#feed')
- self.assertEquals(self.feed.link[2].href,
+ self.assertEqual(self.feed.link[2].href,
('http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?'
'start-index=1&max-results=25'))
- self.assertEquals(self.feed.link[2].rel, 'self')
- self.assertEquals(self.feed.link[3].href,
+ self.assertEqual(self.feed.link[2].rel, 'self')
+ self.assertEqual(self.feed.link[3].href,
('http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?'
'start-index=26&max-results=25'))
- self.assertEquals(self.feed.link[3].rel, 'next')
- self.assertEquals(self.feed.start_index.text, '1')
- self.assertEquals(self.feed.title.text, 'Top Rated')
- self.assertEquals(self.feed.total_results.text, '100')
- self.assertEquals(self.feed.updated.text, '2008-05-14T02:24:07.000-07:00')
- self.assertEquals(len(self.feed.entry), 2)
+ self.assertEqual(self.feed.link[3].rel, 'next')
+ self.assertEqual(self.feed.start_index.text, '1')
+ self.assertEqual(self.feed.title.text, 'Top Rated')
+ self.assertEqual(self.feed.total_results.text, '100')
+ self.assertEqual(self.feed.updated.text, '2008-05-14T02:24:07.000-07:00')
+ self.assertEqual(len(self.feed.entry), 2)
class YouTubePlaylistFeedTest(unittest.TestCase):
@@ -232,10 +232,10 @@
test_data.YOUTUBE_PLAYLIST_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.entry), 1)
- self.assertEquals(
+ self.assertEqual(len(self.feed.entry), 1)
+ self.assertEqual(
self.feed.category[0].scheme, 'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#playlistLink')
@@ -247,15 +247,15 @@
def testCorrectXmlParsing(self):
for entry in self.feed.entry:
- self.assertEquals(entry.category[0].scheme,
+ self.assertEqual(entry.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(entry.category[0].term,
+ self.assertEqual(entry.category[0].term,
'http://gdata.youtube.com/schemas/2007#playlistLink')
- self.assertEquals(entry.description.text,
+ self.assertEqual(entry.description.text,
'My new playlist Description')
- self.assertEquals(entry.feed_link[0].href,
+ self.assertEqual(entry.feed_link[0].href,
'http://gdata.youtube.com/feeds/playlists/8BCDD04DE8F771B2')
- self.assertEquals(entry.feed_link[0].rel,
+ self.assertEqual(entry.feed_link[0].rel,
'http://gdata.youtube.com/schemas/2007#playlist')
@@ -266,17 +266,17 @@
test_data.YOUTUBE_PLAYLIST_VIDEO_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.entry), 1)
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(len(self.feed.entry), 1)
+ self.assertEqual(self.feed.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#playlist')
- self.assertEquals(self.feed.category[1].scheme,
+ self.assertEqual(self.feed.category[1].scheme,
'http://gdata.youtube.com/schemas/2007/tags.cat')
- self.assertEquals(self.feed.category[1].term, 'videos')
- self.assertEquals(self.feed.category[2].scheme,
+ self.assertEqual(self.feed.category[1].term, 'videos')
+ self.assertEqual(self.feed.category[2].scheme,
'http://gdata.youtube.com/schemas/2007/tags.cat')
- self.assertEquals(self.feed.category[2].term, 'python')
+ self.assertEqual(self.feed.category[2].term, 'python')
class YouTubePlaylistVideoEntryTest(unittest.TestCase):
@@ -286,9 +286,9 @@
test_data.YOUTUBE_PLAYLIST_VIDEO_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.entry), 1)
+ self.assertEqual(len(self.feed.entry), 1)
for entry in self.feed.entry:
- self.assertEquals(entry.position.text, '1')
+ self.assertEqual(entry.position.text, '1')
class YouTubeVideoCommentFeedTest(unittest.TestCase):
@@ -298,27 +298,27 @@
test_data.YOUTUBE_COMMENT_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.category), 1)
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(len(self.feed.category), 1)
+ self.assertEqual(self.feed.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#comment')
- self.assertEquals(len(self.feed.link), 4)
- self.assertEquals(self.feed.link[0].rel, 'related')
- self.assertEquals(self.feed.link[0].href,
+ self.assertEqual(len(self.feed.link), 4)
+ self.assertEqual(self.feed.link[0].rel, 'related')
+ self.assertEqual(self.feed.link[0].href,
'http://gdata.youtube.com/feeds/videos/2Idhz9ef5oU')
- self.assertEquals(self.feed.link[1].rel, 'alternate')
- self.assertEquals(self.feed.link[1].href,
+ self.assertEqual(self.feed.link[1].rel, 'alternate')
+ self.assertEqual(self.feed.link[1].href,
'http://www.youtube.com/watch?v=2Idhz9ef5oU')
- self.assertEquals(self.feed.link[2].rel,
+ self.assertEqual(self.feed.link[2].rel,
'http://schemas.google.com/g/2005#feed')
- self.assertEquals(self.feed.link[2].href,
+ self.assertEqual(self.feed.link[2].href,
'http://gdata.youtube.com/feeds/videos/2Idhz9ef5oU/comments')
- self.assertEquals(self.feed.link[3].rel, 'self')
- self.assertEquals(self.feed.link[3].href,
+ self.assertEqual(self.feed.link[3].rel, 'self')
+ self.assertEqual(self.feed.link[3].href,
('http://gdata.youtube.com/feeds/videos/2Idhz9ef5oU/comments?'
'start-index=1&max-results=25'))
- self.assertEquals(len(self.feed.entry), 3)
+ self.assertEqual(len(self.feed.entry), 3)
class YouTubeVideoCommentEntryTest(unittest.TestCase):
@@ -328,22 +328,22 @@
test_data.YOUTUBE_COMMENT_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.entry), 3)
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertEqual(len(self.feed.entry), 3)
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.youtube.YouTubeVideoCommentEntry))
for entry in self.feed.entry:
if (entry.id.text ==
('http://gdata.youtube.com/feeds/videos/'
'2Idhz9ef5oU/comments/91F809A3DE2EB81B')):
- self.assertEquals(entry.category[0].scheme,
+ self.assertEqual(entry.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(entry.category[0].term,
+ self.assertEqual(entry.category[0].term,
'http://gdata.youtube.com/schemas/2007#comment')
- self.assertEquals(entry.link[0].href,
+ self.assertEqual(entry.link[0].href,
'http://gdata.youtube.com/feeds/videos/2Idhz9ef5oU')
- self.assertEquals(entry.link[0].rel, 'related')
- self.assertEquals(entry.content.text, 'test66')
+ self.assertEqual(entry.link[0].rel, 'related')
+ self.assertEqual(entry.content.text, 'test66')
class YouTubeVideoSubscriptionFeedTest(unittest.TestCase):
@@ -354,27 +354,27 @@
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.category), 1)
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(len(self.feed.category), 1)
+ self.assertEqual(self.feed.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#subscription')
- self.assertEquals(len(self.feed.link), 4)
- self.assertEquals(self.feed.link[0].rel, 'related')
- self.assertEquals(self.feed.link[0].href,
+ self.assertEqual(len(self.feed.link), 4)
+ self.assertEqual(self.feed.link[0].rel, 'related')
+ self.assertEqual(self.feed.link[0].href,
'http://gdata.youtube.com/feeds/users/andyland74')
- self.assertEquals(self.feed.link[1].rel, 'alternate')
- self.assertEquals(self.feed.link[1].href,
+ self.assertEqual(self.feed.link[1].rel, 'alternate')
+ self.assertEqual(self.feed.link[1].href,
'http://www.youtube.com/profile_subscriptions?user=andyland74')
- self.assertEquals(self.feed.link[2].rel,
+ self.assertEqual(self.feed.link[2].rel,
'http://schemas.google.com/g/2005#feed')
- self.assertEquals(self.feed.link[2].href,
+ self.assertEqual(self.feed.link[2].href,
'http://gdata.youtube.com/feeds/users/andyland74/subscriptions')
- self.assertEquals(self.feed.link[3].rel, 'self')
- self.assertEquals(self.feed.link[3].href,
+ self.assertEqual(self.feed.link[3].rel, 'self')
+ self.assertEqual(self.feed.link[3].href,
('http://gdata.youtube.com/feeds/users/andyland74/subscriptions?'
'start-index=1&max-results=25'))
- self.assertEquals(len(self.feed.entry), 1)
+ self.assertEqual(len(self.feed.entry), 1)
class YouTubeVideoSubscriptionEntryTest(unittest.TestCase):
@@ -385,31 +385,31 @@
def testCorrectXmlParsing(self):
for entry in self.feed.entry:
- self.assertEquals(len(entry.category), 2)
- self.assertEquals(entry.category[0].scheme,
+ self.assertEqual(len(entry.category), 2)
+ self.assertEqual(entry.category[0].scheme,
'http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat')
- self.assertEquals(entry.category[0].term, 'channel')
- self.assertEquals(entry.category[1].scheme,
+ self.assertEqual(entry.category[0].term, 'channel')
+ self.assertEqual(entry.category[1].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(entry.category[1].term,
+ self.assertEqual(entry.category[1].term,
'http://gdata.youtube.com/schemas/2007#subscription')
- self.assertEquals(len(entry.link), 3)
- self.assertEquals(entry.link[0].href,
+ self.assertEqual(len(entry.link), 3)
+ self.assertEqual(entry.link[0].href,
'http://gdata.youtube.com/feeds/users/andyland74')
- self.assertEquals(entry.link[0].rel, 'related')
- self.assertEquals(entry.link[1].href,
+ self.assertEqual(entry.link[0].rel, 'related')
+ self.assertEqual(entry.link[1].href,
'http://www.youtube.com/profile_videos?user=NBC')
- self.assertEquals(entry.link[1].rel, 'alternate')
- self.assertEquals(entry.link[2].href,
+ self.assertEqual(entry.link[1].rel, 'alternate')
+ self.assertEqual(entry.link[2].href,
('http://gdata.youtube.com/feeds/users/andyland74/subscriptions/'
'd411759045e2ad8c'))
- self.assertEquals(entry.link[2].rel, 'self')
- self.assertEquals(len(entry.feed_link), 1)
- self.assertEquals(entry.feed_link[0].href,
+ self.assertEqual(entry.link[2].rel, 'self')
+ self.assertEqual(len(entry.feed_link), 1)
+ self.assertEqual(entry.feed_link[0].href,
'http://gdata.youtube.com/feeds/api/users/nbc/uploads')
- self.assertEquals(entry.feed_link[0].rel,
+ self.assertEqual(entry.feed_link[0].rel,
'http://gdata.youtube.com/schemas/2007#user.uploads')
- self.assertEquals(entry.username.text, 'NBC')
+ self.assertEqual(entry.username.text, 'NBC')
class YouTubeVideoResponseFeedTest(unittest.TestCase):
@@ -419,27 +419,27 @@
test_data.YOUTUBE_VIDEO_RESPONSE_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.category), 1)
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(len(self.feed.category), 1)
+ self.assertEqual(self.feed.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#video')
- self.assertEquals(len(self.feed.link), 4)
- self.assertEquals(self.feed.link[0].href,
+ self.assertEqual(len(self.feed.link), 4)
+ self.assertEqual(self.feed.link[0].href,
'http://gdata.youtube.com/feeds/videos/2c3q9K4cHzY')
- self.assertEquals(self.feed.link[0].rel, 'related')
- self.assertEquals(self.feed.link[1].href,
+ self.assertEqual(self.feed.link[0].rel, 'related')
+ self.assertEqual(self.feed.link[1].href,
'http://www.youtube.com/video_response_view_all?v=2c3q9K4cHzY')
- self.assertEquals(self.feed.link[1].rel, 'alternate')
- self.assertEquals(self.feed.link[2].href,
+ self.assertEqual(self.feed.link[1].rel, 'alternate')
+ self.assertEqual(self.feed.link[2].href,
'http://gdata.youtube.com/feeds/videos/2c3q9K4cHzY/responses')
- self.assertEquals(self.feed.link[2].rel,
+ self.assertEqual(self.feed.link[2].rel,
'http://schemas.google.com/g/2005#feed')
- self.assertEquals(self.feed.link[3].href,
+ self.assertEqual(self.feed.link[3].href,
('http://gdata.youtube.com/feeds/videos/2c3q9K4cHzY/responses?'
'start-index=1&max-results=25'))
- self.assertEquals(self.feed.link[3].rel, 'self')
- self.assertEquals(len(self.feed.entry), 1)
+ self.assertEqual(self.feed.link[3].rel, 'self')
+ self.assertEqual(len(self.feed.entry), 1)
class YouTubeVideoResponseEntryTest(unittest.TestCase):
@@ -450,7 +450,7 @@
def testCorrectXmlParsing(self):
for entry in self.feed.entry:
- self.assert_(isinstance(entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertTrue(isinstance(entry, gdata.youtube.YouTubeVideoEntry))
class YouTubeContactFeed(unittest.TestCase):
@@ -460,10 +460,10 @@
test_data.YOUTUBE_CONTACTS_FEED)
def testCorrectXmlParsing(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertEqual(self.feed.category[0].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[0].term,
+ self.assertEqual(self.feed.category[0].term,
'http://gdata.youtube.com/schemas/2007#friend')
@@ -477,8 +477,8 @@
for entry in self.feed.entry:
if (entry.id.text == ('http://gdata.youtube.com/feeds/users/'
'apitestjhartmann/contacts/testjfisher')):
- self.assertEquals(entry.username.text, 'testjfisher')
- self.assertEquals(entry.status.text, 'pending')
+ self.assertEqual(entry.username.text, 'testjfisher')
+ self.assertEqual(entry.status.text, 'pending')
class YouTubeUserEntry(unittest.TestCase):
@@ -488,74 +488,74 @@
test_data.YOUTUBE_PROFILE)
def testCorrectXmlParsing(self):
- self.assertEquals(self.feed.author[0].name.text, 'andyland74')
- self.assertEquals(self.feed.books.text, 'Catch-22')
- self.assertEquals(self.feed.category[0].scheme,
+ self.assertEqual(self.feed.author[0].name.text, 'andyland74')
+ self.assertEqual(self.feed.books.text, 'Catch-22')
+ self.assertEqual(self.feed.category[0].scheme,
'http://gdata.youtube.com/schemas/2007/channeltypes.cat')
- self.assertEquals(self.feed.category[0].term, 'Standard')
- self.assertEquals(self.feed.category[1].scheme,
+ self.assertEqual(self.feed.category[0].term, 'Standard')
+ self.assertEqual(self.feed.category[1].scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(self.feed.category[1].term,
+ self.assertEqual(self.feed.category[1].term,
'http://gdata.youtube.com/schemas/2007#userProfile')
- self.assertEquals(self.feed.company.text, 'Google')
- self.assertEquals(self.feed.gender.text, 'm')
- self.assertEquals(self.feed.hobbies.text, 'Testing YouTube APIs')
- self.assertEquals(self.feed.hometown.text, 'Somewhere')
- self.assertEquals(len(self.feed.feed_link), 6)
- self.assertEquals(self.feed.feed_link[0].count_hint, '4')
- self.assertEquals(self.feed.feed_link[0].href,
+ self.assertEqual(self.feed.company.text, 'Google')
+ self.assertEqual(self.feed.gender.text, 'm')
+ self.assertEqual(self.feed.hobbies.text, 'Testing YouTube APIs')
+ self.assertEqual(self.feed.hometown.text, 'Somewhere')
+ self.assertEqual(len(self.feed.feed_link), 6)
+ self.assertEqual(self.feed.feed_link[0].count_hint, '4')
+ self.assertEqual(self.feed.feed_link[0].href,
'http://gdata.youtube.com/feeds/users/andyland74/favorites')
- self.assertEquals(self.feed.feed_link[0].rel,
+ self.assertEqual(self.feed.feed_link[0].rel,
'http://gdata.youtube.com/schemas/2007#user.favorites')
- self.assertEquals(self.feed.feed_link[1].count_hint, '1')
- self.assertEquals(self.feed.feed_link[1].href,
+ self.assertEqual(self.feed.feed_link[1].count_hint, '1')
+ self.assertEqual(self.feed.feed_link[1].href,
'http://gdata.youtube.com/feeds/users/andyland74/contacts')
- self.assertEquals(self.feed.feed_link[1].rel,
+ self.assertEqual(self.feed.feed_link[1].rel,
'http://gdata.youtube.com/schemas/2007#user.contacts')
- self.assertEquals(self.feed.feed_link[2].count_hint, '0')
- self.assertEquals(self.feed.feed_link[2].href,
+ self.assertEqual(self.feed.feed_link[2].count_hint, '0')
+ self.assertEqual(self.feed.feed_link[2].href,
'http://gdata.youtube.com/feeds/users/andyland74/inbox')
- self.assertEquals(self.feed.feed_link[2].rel,
+ self.assertEqual(self.feed.feed_link[2].rel,
'http://gdata.youtube.com/schemas/2007#user.inbox')
- self.assertEquals(self.feed.feed_link[3].count_hint, None)
- self.assertEquals(self.feed.feed_link[3].href,
+ self.assertEqual(self.feed.feed_link[3].count_hint, None)
+ self.assertEqual(self.feed.feed_link[3].href,
'http://gdata.youtube.com/feeds/users/andyland74/playlists')
- self.assertEquals(self.feed.feed_link[3].rel,
+ self.assertEqual(self.feed.feed_link[3].rel,
'http://gdata.youtube.com/schemas/2007#user.playlists')
- self.assertEquals(self.feed.feed_link[4].count_hint, '4')
- self.assertEquals(self.feed.feed_link[4].href,
+ self.assertEqual(self.feed.feed_link[4].count_hint, '4')
+ self.assertEqual(self.feed.feed_link[4].href,
'http://gdata.youtube.com/feeds/users/andyland74/subscriptions')
- self.assertEquals(self.feed.feed_link[4].rel,
+ self.assertEqual(self.feed.feed_link[4].rel,
'http://gdata.youtube.com/schemas/2007#user.subscriptions')
- self.assertEquals(self.feed.feed_link[5].count_hint, '1')
- self.assertEquals(self.feed.feed_link[5].href,
+ self.assertEqual(self.feed.feed_link[5].count_hint, '1')
+ self.assertEqual(self.feed.feed_link[5].href,
'http://gdata.youtube.com/feeds/users/andyland74/uploads')
- self.assertEquals(self.feed.feed_link[5].rel,
+ self.assertEqual(self.feed.feed_link[5].rel,
'http://gdata.youtube.com/schemas/2007#user.uploads')
- self.assertEquals(self.feed.first_name.text, 'andy')
- self.assertEquals(self.feed.last_name.text, 'example')
- self.assertEquals(self.feed.link[0].href,
+ self.assertEqual(self.feed.first_name.text, 'andy')
+ self.assertEqual(self.feed.last_name.text, 'example')
+ self.assertEqual(self.feed.link[0].href,
'http://www.youtube.com/profile?user=andyland74')
- self.assertEquals(self.feed.link[0].rel, 'alternate')
- self.assertEquals(self.feed.link[1].href,
+ self.assertEqual(self.feed.link[0].rel, 'alternate')
+ self.assertEqual(self.feed.link[1].href,
'http://gdata.youtube.com/feeds/users/andyland74')
- self.assertEquals(self.feed.link[1].rel, 'self')
- self.assertEquals(self.feed.location.text, 'US')
- self.assertEquals(self.feed.movies.text, 'Aqua Teen Hungerforce')
- self.assertEquals(self.feed.music.text, 'Elliott Smith')
- self.assertEquals(self.feed.occupation.text, 'Technical Writer')
- self.assertEquals(self.feed.published.text, '2006-10-16T00:09:45.000-07:00')
- self.assertEquals(self.feed.school.text, 'University of North Carolina')
- self.assertEquals(self.feed.statistics.last_web_access,
+RefactoringTool: Refactored ./tests/gdata_tests/youtube/service_test.py
self.assertEqual(self.feed.link[1].rel, 'self')
+ self.assertEqual(self.feed.location.text, 'US')
+ self.assertEqual(self.feed.movies.text, 'Aqua Teen Hungerforce')
+ self.assertEqual(self.feed.music.text, 'Elliott Smith')
+ self.assertEqual(self.feed.occupation.text, 'Technical Writer')
+ self.assertEqual(self.feed.published.text, '2006-10-16T00:09:45.000-07:00')
+ self.assertEqual(self.feed.school.text, 'University of North Carolina')
+ self.assertEqual(self.feed.statistics.last_web_access,
'2008-02-25T16:03:38.000-08:00')
- self.assertEquals(self.feed.statistics.subscriber_count, '1')
- self.assertEquals(self.feed.statistics.video_watch_count, '21')
- self.assertEquals(self.feed.statistics.view_count, '9')
- self.assertEquals(self.feed.thumbnail.url,
+ self.assertEqual(self.feed.statistics.subscriber_count, '1')
+ self.assertEqual(self.feed.statistics.video_watch_count, '21')
+ self.assertEqual(self.feed.statistics.view_count, '9')
+ self.assertEqual(self.feed.thumbnail.url,
'http://i.ytimg.com/vi/YFbSxcdOL-w/default.jpg')
- self.assertEquals(self.feed.title.text, 'andyland74 Channel')
- self.assertEquals(self.feed.updated.text, '2008-02-26T11:48:21.000-08:00')
- self.assertEquals(self.feed.username.text, 'andyland74')
+ self.assertEqual(self.feed.title.text, 'andyland74 Channel')
+ self.assertEqual(self.feed.updated.text, '2008-02-26T11:48:21.000-08:00')
+ self.assertEqual(self.feed.username.text, 'andyland74')
if __name__ == '__main__':
unittest.main()
--- ./tests/gdata_tests/youtube/service_test.py (original)
+++ ./tests/gdata_tests/youtube/service_test.py (refactored)
@@ -18,7 +18,7 @@
import getpass
import time
-import StringIO
+import io
import random
import unittest
import atom
@@ -42,92 +42,92 @@
def testRetrieveVideoFeed(self):
feed = self.client.GetYouTubeVideoFeed(
'https://gdata.youtube.com/feeds/api/standardfeeds/recently_featured');
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
for entry in feed.entry:
- self.assert_(entry.title.text != '')
+ self.assertTrue(entry.title.text != '')
def testRetrieveTopRatedVideoFeed(self):
feed = self.client.GetTopRatedVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveMostViewedVideoFeed(self):
feed = self.client.GetMostViewedVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveRecentlyFeaturedVideoFeed(self):
feed = self.client.GetRecentlyFeaturedVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveWatchOnMobileVideoFeed(self):
feed = self.client.GetWatchOnMobileVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveTopFavoritesVideoFeed(self):
feed = self.client.GetTopFavoritesVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveMostRecentVideoFeed(self):
feed = self.client.GetMostRecentVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveMostDiscussedVideoFeed(self):
feed = self.client.GetMostDiscussedVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveMostLinkedVideoFeed(self):
feed = self.client.GetMostLinkedVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveMostRespondedVideoFeed(self):
feed = self.client.GetMostRespondedVideoFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 10)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 10)
def testRetrieveVideoEntryByUri(self):
entry = self.client.GetYouTubeVideoEntry(
'https://gdata.youtube.com/feeds/videos/Ncakifd_16k')
- self.assert_(isinstance(entry, gdata.youtube.YouTubeVideoEntry))
- self.assert_(entry.title.text != '')
+ self.assertTrue(isinstance(entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertTrue(entry.title.text != '')
def testRetrieveVideoEntryByVideoId(self):
entry = self.client.GetYouTubeVideoEntry(video_id='Ncakifd_16k')
- self.assert_(isinstance(entry, gdata.youtube.YouTubeVideoEntry))
- self.assert_(entry.title.text != '')
+ self.assertTrue(isinstance(entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertTrue(entry.title.text != '')
def testRetrieveUserVideosbyUri(self):
feed = self.client.GetYouTubeUserFeed(
'https://gdata.youtube.com/feeds/users/gdpython/uploads')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveUserVideosbyUsername(self):
feed = self.client.GetYouTubeUserFeed(username='gdpython')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testSearchWithVideoQuery(self):
query = gdata.youtube.service.YouTubeVideoQuery()
query.vq = 'google'
query.max_results = 8
feed = self.client.YouTubeQuery(query)
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assertEquals(len(feed.entry), 8)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertEqual(len(feed.entry), 8)
def testDirectVideoUploadStatusUpdateAndDeletion(self):
- self.assertEquals(self.client.developer_key, developer_key)
- self.assertEquals(self.client.client_id, YOUTUBE_TEST_CLIENT_ID)
- self.assertEquals(self.client.additional_headers['X-GData-Key'],
+ self.assertEqual(self.client.developer_key, developer_key)
+ self.assertEqual(self.client.client_id, YOUTUBE_TEST_CLIENT_ID)
+ self.assertEqual(self.client.additional_headers['X-GData-Key'],
'key=' + developer_key)
- self.assertEquals(self.client.additional_headers['X-Gdata-Client'],
+ self.assertEqual(self.client.additional_headers['X-Gdata-Client'],
YOUTUBE_TEST_CLIENT_ID)
test_video_title = 'my cool video ' + str(random.randint(1000,5000))
@@ -144,7 +144,7 @@
label='Autos'),
player=None
)
- self.assert_(isinstance(my_media_group, gdata.media.Group))
+ self.assertTrue(isinstance(my_media_group, gdata.media.Group))
# Set Geo location to 37,-122 lat, long
where = gdata.geo.Where()
@@ -153,17 +153,17 @@
video_entry = gdata.youtube.YouTubeVideoEntry(media=my_media_group,
geo=where)
- self.assert_(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertTrue(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
new_entry = self.client.InsertVideoEntry(video_entry, video_file_location)
- self.assert_(isinstance(new_entry, gdata.youtube.YouTubeVideoEntry))
- self.assertEquals(new_entry.title.text, test_video_title)
- self.assertEquals(new_entry.media.description.text, test_video_description)
- self.assert_(new_entry.id.text)
+ self.assertTrue(isinstance(new_entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertEqual(new_entry.title.text, test_video_title)
+ self.assertEqual(new_entry.media.description.text, test_video_description)
+ self.assertTrue(new_entry.id.text)
# check upload status also
upload_status = self.client.CheckUploadStatus(new_entry)
- self.assert_(upload_status[0] != '')
+ self.assertTrue(upload_status[0] != '')
# test updating entry meta-data
new_video_description = 'description ' + str(random.randint(1000,5000))
@@ -171,8 +171,8 @@
updated_entry = self.client.UpdateVideoEntry(new_entry)
- self.assert_(isinstance(updated_entry, gdata.youtube.YouTubeVideoEntry))
- self.assertEquals(updated_entry.media.description.text,
+ self.assertTrue(isinstance(updated_entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertEqual(updated_entry.media.description.text,
new_video_description)
# sleep for 10 seconds
@@ -187,14 +187,14 @@
# test to delete the entry
value = self.client.DeleteVideoEntry(updated_entry)
- self.assert_(value == True)
+ self.assertTrue(value == True)
def testDirectVideoUploadWithDeveloperTags(self):
- self.assertEquals(self.client.developer_key, developer_key)
- self.assertEquals(self.client.client_id, YOUTUBE_TEST_CLIENT_ID)
- self.assertEquals(self.client.additional_headers['X-GData-Key'],
+ self.assertEqual(self.client.developer_key, developer_key)
+ self.assertEqual(self.client.client_id, YOUTUBE_TEST_CLIENT_ID)
+ self.assertEqual(self.client.additional_headers['X-GData-Key'],
'key=' + developer_key)
- self.assertEquals(self.client.additional_headers['X-Gdata-Client'],
+ self.assertEqual(self.client.additional_headers['X-Gdata-Client'],
YOUTUBE_TEST_CLIENT_ID)
test_video_title = 'my cool video ' + str(random.randint(1000,5000))
@@ -216,7 +216,7 @@
player=None
)
- self.assert_(isinstance(my_media_group, gdata.media.Group))
+ self.assertTrue(isinstance(my_media_group, gdata.media.Group))
video_entry = gdata.youtube.YouTubeVideoEntry(media=my_media_group)
original_developer_tags = [test_developer_tag_01, test_developer_tag_02,
@@ -225,22 +225,22 @@
dev_tags = video_entry.AddDeveloperTags(original_developer_tags)
for dev_tag in dev_tags:
- self.assert_(dev_tag.text in original_developer_tags)
-
- self.assert_(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertTrue(dev_tag.text in original_developer_tags)
+
+ self.assertTrue(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
new_entry = self.client.InsertVideoEntry(video_entry, video_file_location)
- self.assert_(isinstance(new_entry, gdata.youtube.YouTubeVideoEntry))
- self.assertEquals(new_entry.title.text, test_video_title)
- self.assertEquals(new_entry.media.description.text, test_video_description)
- self.assert_(new_entry.id.text)
+ self.assertTrue(isinstance(new_entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertEqual(new_entry.title.text, test_video_title)
+ self.assertEqual(new_entry.media.description.text, test_video_description)
+ self.assertTrue(new_entry.id.text)
developer_tags_from_new_entry = new_entry.GetDeveloperTags()
for dev_tag in developer_tags_from_new_entry:
- self.assert_(dev_tag.text in original_developer_tags)
-
- self.assertEquals(len(developer_tags_from_new_entry),
+ self.assertTrue(dev_tag.text in original_developer_tags)
+
+ self.assertEqual(len(developer_tags_from_new_entry),
len(original_developer_tags))
# sleep for 10 seconds
@@ -255,14 +255,14 @@
# test to delete the entry
value = self.client.DeleteVideoEntry(new_entry)
- self.assert_(value == True)
+ self.assertTrue(value == True)
def testBrowserBasedVideoUpload(self):
- self.assertEquals(self.client.developer_key, developer_key)
- self.assertEquals(self.client.client_id, YOUTUBE_TEST_CLIENT_ID)
- self.assertEquals(self.client.additional_headers['X-GData-Key'],
+ self.assertEqual(self.client.developer_key, developer_key)
+ self.assertEqual(self.client.client_id, YOUTUBE_TEST_CLIENT_ID)
+ self.assertEqual(self.client.additional_headers['X-GData-Key'],
'key=' + developer_key)
- self.assertEquals(self.client.additional_headers['X-Gdata-Client'],
+ self.assertEqual(self.client.additional_headers['X-Gdata-Client'],
YOUTUBE_TEST_CLIENT_ID)
test_video_title = 'my cool video ' + str(random.randint(1000,5000))
test_video_description = 'description ' + str(random.randint(1000,5000))
@@ -278,49 +278,49 @@
label='Autos'),
player=None
)
- self.assert_(isinstance(my_media_group, gdata.media.Group))
+ self.assertTrue(isinstance(my_media_group, gdata.media.Group))
video_entry = gdata.youtube.YouTubeVideoEntry(media=my_media_group)
- self.assert_(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
+ self.assertTrue(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
response = self.client.GetFormUploadToken(video_entry)
- self.assert_(response[0].startswith(
+ self.assertTrue(response[0].startswith(
'https://uploads.gdata.youtube.com/action/FormDataUpload/'))
- self.assert_(len(response[0]) > 55)
- self.assert_(len(response[1]) > 100)
+ self.assertTrue(len(response[0]) > 55)
+ self.assertTrue(len(response[1]) > 100)
def testRetrieveRelatedVideoFeedByUri(self):
feed = self.client.GetYouTubeRelatedVideoFeed(
'https://gdata.youtube.com/feeds/videos/Ncakifd_16k/related')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveRelatedVideoFeedById(self):
feed = self.client.GetYouTubeRelatedVideoFeed(video_id = 'Ncakifd_16k')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveResponseVideoFeedByUri(self):
feed = self.client.GetYouTubeVideoResponseFeed(
'https://gdata.youtube.com/feeds/videos/Ncakifd_16k/responses')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoResponseFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoResponseFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveResponseVideoFeedById(self):
feed = self.client.GetYouTubeVideoResponseFeed(video_id='Ncakifd_16k')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoResponseFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoResponseFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveVideoCommentFeedByUri(self):
feed = self.client.GetYouTubeVideoCommentFeed(
'https://gdata.youtube.com/feeds/api/videos/Ncakifd_16k/comments')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoCommentFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoCommentFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveVideoCommentFeedByVideoId(self):
feed = self.client.GetYouTubeVideoCommentFeed(video_id='Ncakifd_16k')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoCommentFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoCommentFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testAddComment(self):
video_id = '9g6buYJTt_g'
@@ -333,31 +333,31 @@
for item in comment_feed.entry:
if (item.content.text == random_comment_text):
comment_found = True
- self.assertEquals(comment_found, True)
+ self.assertEqual(comment_found, True)
def testAddRating(self):
video_id_to_rate = 'Ncakifd_16k'
video_entry = self.client.GetYouTubeVideoEntry(video_id=video_id_to_rate)
response = self.client.AddRating(3, video_entry)
- self.assert_(isinstance(response, gdata.GDataEntry))
+ self.assertTrue(isinstance(response, gdata.GDataEntry))
def testRetrievePlaylistFeedByUri(self):
feed = self.client.GetYouTubePlaylistFeed(
'https://gdata.youtube.com/feeds/users/gdpython/playlists')
- self.assert_(isinstance(feed, gdata.youtube.YouTubePlaylistFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubePlaylistFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrievePlaylistListFeedByUsername(self):
feed = self.client.GetYouTubePlaylistFeed(username='gdpython')
- self.assert_(isinstance(feed, gdata.youtube.YouTubePlaylistFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubePlaylistFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrievePlaylistVideoFeed(self):
feed = self.client.GetYouTubePlaylistVideoFeed(
'https://gdata.youtube.com/feeds/api/playlists/BCB3BB96DF51B505')
- self.assert_(isinstance(feed, gdata.youtube.YouTubePlaylistVideoFeed))
- self.assert_(len(feed.entry) > 0)
- self.assert_(isinstance(feed.entry[0],
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubePlaylistVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed.entry[0],
gdata.youtube.YouTubePlaylistVideoEntry))
def testAddUpdateAndDeletePlaylist(self):
@@ -365,7 +365,7 @@
test_playlist_description = 'test playlist '
response = self.client.AddPlaylist(test_playlist_title,
test_playlist_description)
- self.assert_(isinstance(response, gdata.youtube.YouTubePlaylistEntry))
+ self.assertTrue(isinstance(response, gdata.youtube.YouTubePlaylistEntry))
new_playlist_title = 'my updated playlist ' + str(random.randint(1000,4000))
new_playlist_description = 'my updated playlist '
@@ -384,14 +384,14 @@
update_successful = True
break
- self.assertEquals(update_successful, True)
+ self.assertEqual(update_successful, True)
# wait
time.sleep(10)
# delete it
playlist_uri = updated_playlist.id.text
response = self.client.DeletePlaylist(playlist_uri)
- self.assertEquals(response, True)
+ self.assertEqual(response, True)
def testAddUpdateAndDeletePrivatePlaylist(self):
test_playlist_title = 'my test playlist ' + str(random.randint(1000,3000))
@@ -399,7 +399,7 @@
response = self.client.AddPlaylist(test_playlist_title,
test_playlist_description,
playlist_private=True)
- self.assert_(isinstance(response, gdata.youtube.YouTubePlaylistEntry))
+ self.assertTrue(isinstance(response, gdata.youtube.YouTubePlaylistEntry))
new_playlist_title = 'my updated playlist ' + str(random.randint(1000,4000))
new_playlist_description = 'my updated playlist '
@@ -420,22 +420,22 @@
if playlist_entry.private is not None:
playlist_still_private = True
- self.assertEquals(update_successful, True)
- self.assertEquals(playlist_still_private, True)
+ self.assertEqual(update_successful, True)
+ self.assertEqual(playlist_still_private, True)
# wait
time.sleep(10)
# delete it
playlist_uri = updated_playlist.id.text
response = self.client.DeletePlaylist(playlist_uri)
- self.assertEquals(response, True)
+ self.assertEqual(response, True)
def testAddEditAndDeleteVideoFromPlaylist(self):
test_playlist_title = 'my test playlist ' + str(random.randint(1000,3000))
test_playlist_description = 'test playlist '
response = self.client.AddPlaylist(test_playlist_title,
test_playlist_description)
- self.assert_(isinstance(response, gdata.youtube.YouTubePlaylistEntry))
+ self.assertTrue(isinstance(response, gdata.youtube.YouTubePlaylistEntry))
custom_video_title = 'my test video on my test playlist'
custom_video_description = 'this is a test video on my test playlist'
@@ -445,7 +445,7 @@
response = self.client.AddPlaylistVideoEntryToPlaylist(
playlist_uri, video_id, custom_video_title, custom_video_description)
- self.assert_(isinstance(response, gdata.youtube.YouTubePlaylistVideoEntry))
+ self.assertTrue(isinstance(response, gdata.youtube.YouTubePlaylistVideoEntry))
playlist_entry_id = response.id.text.split('/')[-1]
playlist_uri = response.id.text.split(playlist_entry_id)[0][:-1]
@@ -458,25 +458,25 @@
new_video_title,
new_video_description,
1)
- self.assert_(isinstance(response, gdata.youtube.YouTubePlaylistVideoEntry))
+ self.assertTrue(isinstance(response, gdata.youtube.YouTubePlaylistVideoEntry))
time.sleep(10)
playlist_entry_id = response.id.text.split('/')[-1]
# remove video from playlist
response = self.client.DeletePlaylistVideoEntry(playlist_uri,
playlist_entry_id)
- self.assertEquals(response, True)
+ self.assertEqual(response, True)
time.sleep(10)
# delete the playlist
response = self.client.DeletePlaylist(playlist_uri)
- self.assertEquals(response, True)
+ self.assertEqual(response, True)
def testRetrieveSubscriptionFeedByUri(self):
feed = self.client.GetYouTubeSubscriptionFeed(
'https://gdata.youtube.com/feeds/users/gdpython/subscriptions')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeSubscriptionFeed))
- self.assert_(len(feed.entry) == 3)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeSubscriptionFeed))
+ self.assertTrue(len(feed.entry) == 3)
subscription_to_channel_found = False
subscription_to_favorites_found = False
@@ -484,7 +484,7 @@
all_types_found = False
for entry in feed.entry:
- self.assert_(isinstance(entry, gdata.youtube.YouTubeSubscriptionEntry))
+ self.assertTrue(isinstance(entry, gdata.youtube.YouTubeSubscriptionEntry))
subscription_type = entry.GetSubscriptionType()
if subscription_type == 'channel':
subscription_to_channel_found = True
@@ -497,12 +497,12 @@
subscription_to_query_found):
all_types_found = True
- self.assertEquals(all_types_found, True)
+ self.assertEqual(all_types_found, True)
def testRetrieveSubscriptionFeedByUsername(self):
feed = self.client.GetYouTubeSubscriptionFeed(username='gdpython')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeSubscriptionFeed))
- self.assert_(len(feed.entry) == 3)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeSubscriptionFeed))
+ self.assertTrue(len(feed.entry) == 3)
subscription_to_channel_found = False
subscription_to_favorites_found = False
@@ -510,7 +510,7 @@
all_types_found = False
for entry in feed.entry:
- self.assert_(isinstance(entry, gdata.youtube.YouTubeSubscriptionEntry))
+ self.assertTrue(isinstance(entry, gdata.youtube.YouTubeSubscriptionEntry))
subscription_type = entry.GetSubscriptionType()
if subscription_type == 'channel':
subscription_to_channel_found = True
@@ -522,55 +522,55 @@
if (subscription_to_channel_found and subscription_to_favorites_found and
subscription_to_query_found):
all_types_found = True
- self.assertEquals(all_types_found, True)
RefactoringTool: Refactored ./tests/gdata_tests/youtube/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/webmastertools_test.py
+ self.assertEqual(all_types_found, True)
def testRetrieveUserProfileByUri(self):
user = self.client.GetYouTubeUserEntry(
'https://gdata.youtube.com/feeds/users/gdpython')
- self.assert_(isinstance(user, gdata.youtube.YouTubeUserEntry))
- self.assertEquals(user.location.text, 'US')
+ self.assertTrue(isinstance(user, gdata.youtube.YouTubeUserEntry))
+ self.assertEqual(user.location.text, 'US')
def testRetrieveUserProfileByUsername(self):
user = self.client.GetYouTubeUserEntry(username='gdpython')
- self.assert_(isinstance(user, gdata.youtube.YouTubeUserEntry))
- self.assertEquals(user.location.text, 'US')
+ self.assertTrue(isinstance(user, gdata.youtube.YouTubeUserEntry))
+ self.assertEqual(user.location.text, 'US')
def testRetrieveUserFavoritesFeed(self):
feed = self.client.GetUserFavoritesFeed(username='gdpython')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testRetrieveDefaultUserFavoritesFeed(self):
feed = self.client.GetUserFavoritesFeed()
- self.assert_(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeVideoFeed))
+ self.assertTrue(len(feed.entry) > 0)
def testAddAndDeleteVideoFromFavorites(self):
video_id = 'Ncakifd_16k'
video_entry = self.client.GetYouTubeVideoEntry(video_id=video_id)
response = self.client.AddVideoEntryToFavorites(video_entry)
- self.assert_(isinstance(response, gdata.GDataEntry))
+ self.assertTrue(isinstance(response, gdata.GDataEntry))
time.sleep(10)
response = self.client.DeleteVideoEntryFromFavorites(video_id)
- self.assertEquals(response, True)
+ self.assertEqual(response, True)
def testRetrieveContactFeedByUri(self):
feed = self.client.GetYouTubeContactFeed(
'https://gdata.youtube.com/feeds/users/gdpython/contacts')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeContactFeed))
- self.assertEquals(len(feed.entry), 1)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeContactFeed))
+ self.assertEqual(len(feed.entry), 1)
def testRetrieveContactFeedByUsername(self):
feed = self.client.GetYouTubeContactFeed(username='gdpython')
- self.assert_(isinstance(feed, gdata.youtube.YouTubeContactFeed))
- self.assertEquals(len(feed.entry), 1)
+ self.assertTrue(isinstance(feed, gdata.youtube.YouTubeContactFeed))
+ self.assertEqual(len(feed.entry), 1)
if __name__ == '__main__':
print ('NOTE: Please run these tests only with a test account. '
'The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
- developer_key = raw_input('Please enter your developer key: ')
- video_file_location = raw_input(
+ developer_key = input('Please enter your developer key: ')
+ video_file_location = input(
'Please enter the absolute path to a video file: ')
unittest.main()
--- ./tests/gdata_tests/youtube/live_client_test.py (original)
+++ ./tests/gdata_tests/youtube/live_client_test.py (refactored)
@@ -22,8 +22,8 @@
# Python imports.
import unittest
-import urllib
-import urllib2
+import urllib.request, urllib.parse, urllib.error
+import urllib.request, urllib.error, urllib.parse
# Google Data APIs imports.
import gdata.youtube.client
--- ./tests/gdata_tests/webmastertools_test.py (original)
+++ ./tests/gdata_tests/webmastertools_test.py (refactored)
@@ -35,9 +35,9 @@
def testToAndFromString(self):
self.indexed.text = 'true'
- self.assert_(self.indexed.text == 'true')
+ self.assertTrue(self.indexed.text == 'true')
new_indexed = webmastertools.IndexedFromString(self.indexed.ToString())
- self.assert_(self.indexed.text == new_indexed.text)
+ self.assertTrue(self.indexed.text == new_indexed.text)
class CrawledTest(unittest.TestCase):
@@ -47,9 +47,9 @@
def testToAndFromString(self):
self.crawled.text = 'true'
- self.assert_(self.crawled.text == 'true')
+ self.assertTrue(self.crawled.text == 'true')
new_crawled = webmastertools.CrawledFromString(self.crawled.ToString())
- self.assert_(self.crawled.text == new_crawled.text)
+ self.assertTrue(self.crawled.text == new_crawled.text)
class GeoLocationTest(unittest.TestCase):
@@ -59,10 +59,10 @@
def testToAndFromString(self):
self.geolocation.text = 'US'
- self.assert_(self.geolocation.text == 'US')
+ self.assertTrue(self.geolocation.text == 'US')
new_geolocation = webmastertools.GeoLocationFromString(
self.geolocation.ToString())
- self.assert_(self.geolocation.text == new_geolocation.text)
+ self.assertTrue(self.geolocation.text == new_geolocation.text)
class PreferredDomainTest(unittest.TestCase):
@@ -72,10 +72,10 @@
def testToAndFromString(self):
self.preferred_domain.text = 'none'
- self.assert_(self.preferred_domain.text == 'none')
+ self.assertTrue(self.preferred_domain.text == 'none')
new_preferred_domain = webmastertools.PreferredDomainFromString(
self.preferred_domain.ToString())
- self.assert_(self.preferred_domain.text == new_preferred_domain.text)
+ self.assertTrue(self.preferred_domain.text == new_preferred_domain.text)
class CrawlRateTest(unittest.TestCase):
@@ -85,10 +85,10 @@
def testToAndFromString(self):
self.crawl_rate.text = 'normal'
- self.assert_(self.crawl_rate.text == 'normal')
+ self.assertTrue(self.crawl_rate.text == 'normal')
new_crawl_rate = webmastertools.CrawlRateFromString(
self.crawl_rate.ToString())
- self.assert_(self.crawl_rate.text == new_crawl_rate.text)
+ self.assertTrue(self.crawl_rate.text == new_crawl_rate.text)
class EnhancedImageSearchTest(unittest.TestCase):
@@ -98,10 +98,10 @@
def testToAndFromString(self):
self.enhanced_image_search.text = 'true'
- self.assert_(self.enhanced_image_search.text == 'true')
+ self.assertTrue(self.enhanced_image_search.text == 'true')
new_enhanced_image_search = webmastertools.EnhancedImageSearchFromString(
self.enhanced_image_search.ToString())
- self.assert_(self.enhanced_image_search.text ==
+ self.assertTrue(self.enhanced_image_search.text ==
new_enhanced_image_search.text)
@@ -112,9 +112,9 @@
def testToAndFromString(self):
self.verified.text = 'true'
- self.assert_(self.verified.text == 'true')
+ self.assertTrue(self.verified.text == 'true')
new_verified = webmastertools.VerifiedFromString(self.verified.ToString())
- self.assert_(self.verified.text == new_verified.text)
+ self.assertTrue(self.verified.text == new_verified.text)
class VerificationMethodMetaTest(unittest.TestCase):
@@ -125,12 +125,12 @@
def testToAndFromString(self):
self.meta.name = 'verify-vf1'
self.meta.content = 'a2Ai'
- self.assert_(self.meta.name == 'verify-vf1')
- self.assert_(self.meta.content == 'a2Ai')
+ self.assertTrue(self.meta.name == 'verify-vf1')
+ self.assertTrue(self.meta.content == 'a2Ai')
new_meta = webmastertools.VerificationMethodMetaFromString(
self.meta.ToString())
- self.assert_(self.meta.name == new_meta.name)
- self.assert_(self.meta.content == new_meta.content)
+ self.assertTrue(self.meta.name == new_meta.name)
+ self.assertTrue(self.meta.content == new_meta.content)
class VerificationMethodTest(unittest.TestCase):
@@ -142,59 +142,59 @@
self.method = webmastertools.VerificationMethod()
self.method.type = 'metatag'
self.method.in_use = 'false'
- self.assert_(self.method.type == 'metatag')
- self.assert_(self.method.in_use == 'false')
+ self.assertTrue(self.method.type == 'metatag')
+ self.assertTrue(self.method.in_use == 'false')
self.method.meta = webmastertools.VerificationMethodMeta(name='verify-vf1',
content='a2Ai')
- self.assert_(self.method.meta.name == 'verify-vf1')
- self.assert_(self.method.meta.content == 'a2Ai')
+ self.assertTrue(self.method.meta.name == 'verify-vf1')
+ self.assertTrue(self.method.meta.content == 'a2Ai')
new_method = webmastertools.VerificationMethodFromString(
self.method.ToString())
- self.assert_(self.method.type == new_method.type)
- self.assert_(self.method.in_use == new_method.in_use)
- self.assert_(self.method.meta.name == new_method.meta.name)
- self.assert_(self.method.meta.content == new_method.meta.content)
+ self.assertTrue(self.method.type == new_method.type)
+ self.assertTrue(self.method.in_use == new_method.in_use)
+ self.assertTrue(self.method.meta.name == new_method.meta.name)
+ self.assertTrue(self.method.meta.content == new_method.meta.content)
method = webmastertools.VerificationMethod(type='xyz')
self.assertEqual(method.type, 'xyz')
method = webmastertools.VerificationMethod()
- self.assert_(method.type is None)
+ self.assertTrue(method.type is None)
def testHtmlPageToAndFromString(self):
self.method = webmastertools.VerificationMethod()
self.method.type = 'htmlpage'
self.method.in_use = 'false'
self.method.text = '456456-google.html'
- self.assert_(self.method.type == 'htmlpage')
- self.assert_(self.method.in_use == 'false')
- self.assert_(self.method.text == '456456-google.html')
- self.assert_(self.method.meta is None)
+ self.assertTrue(self.method.type == 'htmlpage')
+ self.assertTrue(self.method.in_use == 'false')
+ self.assertTrue(self.method.text == '456456-google.html')
+ self.assertTrue(self.method.meta is None)
new_method = webmastertools.VerificationMethodFromString(
self.method.ToString())
- self.assert_(self.method.type == new_method.type)
- self.assert_(self.method.in_use == new_method.in_use)
- self.assert_(self.method.text == new_method.text)
- self.assert_(self.method.meta is None)
+ self.assertTrue(self.method.type == new_method.type)
+ self.assertTrue(self.method.in_use == new_method.in_use)
+ self.assertTrue(self.method.text == new_method.text)
+ self.assertTrue(self.method.meta is None)
def testConvertActualData(self):
feed = webmastertools.SitesFeedFromString(test_data.SITES_FEED)
- self.assert_(len(feed.entry[0].verification_method) == 2)
+ self.assertTrue(len(feed.entry[0].verification_method) == 2)
check = 0
for method in feed.entry[0].verification_method:
- self.assert_(isinstance(method, webmastertools.VerificationMethod))
+ self.assertTrue(isinstance(method, webmastertools.VerificationMethod))
if method.type == 'metatag':
- self.assert_(method.in_use == 'false')
- self.assert_(method.text is None)
- self.assert_(method.meta.name == 'verify-v1')
- self.assert_(method.meta.content == 'a2Ai')
+ self.assertTrue(method.in_use == 'false')
+ self.assertTrue(method.text is None)
+ self.assertTrue(method.meta.name == 'verify-v1')
+ self.assertTrue(method.meta.content == 'a2Ai')
check = check | 1
elif method.type == 'htmlpage':
- self.assert_(method.in_use == 'false')
- self.assert_(method.text == '456456-google.html')
+ self.assertTrue(method.in_use == 'false')
+ self.assertTrue(method.text == '456456-google.html')
check = check | 2
else:
self.fail('Wrong Verification Method: %s' % method.type)
- self.assert_(check == 2 ** 2 - 1,
+ self.assertTrue(check == 2 ** 2 - 1,
'Should only have two Verification Methods, metatag and htmlpage')
@@ -205,10 +205,10 @@
def testToAndFromString(self):
self.markup_language.text = 'HTML'
- self.assert_(self.markup_language.text == 'HTML')
+ self.assertTrue(self.markup_language.text == 'HTML')
new_markup_language = webmastertools.MarkupLanguageFromString(
self.markup_language.ToString())
- self.assert_(self.markup_language.text == new_markup_language.text)
+ self.assertTrue(self.markup_language.text == new_markup_language.text)
class SitemapMobileTest(unittest.TestCase):
@@ -219,28 +219,28 @@
def testToAndFromString(self):
self.sitemap_mobile.markup_language.append(webmastertools.MarkupLanguage(
text = 'HTML'))
- self.assert_(self.sitemap_mobile.text is None)
- self.assert_(self.sitemap_mobile.markup_language[0].text == 'HTML')
+ self.assertTrue(self.sitemap_mobile.text is None)
+ self.assertTrue(self.sitemap_mobile.markup_language[0].text == 'HTML')
new_sitemap_mobile = webmastertools.SitemapMobileFromString(
self.sitemap_mobile.ToString())
- self.assert_(new_sitemap_mobile.text is None)
- self.assert_(self.sitemap_mobile.markup_language[0].text ==
+ self.assertTrue(new_sitemap_mobile.text is None)
+ self.assertTrue(self.sitemap_mobile.markup_language[0].text ==
new_sitemap_mobile.markup_language[0].text)
def testConvertActualData(self):
feed = webmastertools.SitemapsFeedFromString(test_data.SITEMAPS_FEED)
- self.assert_(feed.sitemap_mobile.text.strip() == '')
- self.assert_(len(feed.sitemap_mobile.markup_language) == 2)
+ self.assertTrue(feed.sitemap_mobile.text.strip() == '')
+ self.assertTrue(len(feed.sitemap_mobile.markup_language) == 2)
check = 0
for markup_language in feed.sitemap_mobile.markup_language:
- self.assert_(isinstance(markup_language, webmastertools.MarkupLanguage))
+ self.assertTrue(isinstance(markup_language, webmastertools.MarkupLanguage))
if markup_language.text == "HTML":
check = check | 1
elif markup_language.text == "WAP":
check = check | 2
else:
self.fail('Unexpected markup language: %s' % markup_language.text)
- self.assert_(check == 2 ** 2 - 1, "Something is wrong with markup language")
+ self.assertTrue(check == 2 ** 2 - 1, "Something is wrong with markup language")
class SitemapMobileMarkupLanguageTest(unittest.TestCase):
@@ -251,11 +251,11 @@
def testToAndFromString(self):
self.sitemap_mobile_markup_language.text = 'HTML'
- self.assert_(self.sitemap_mobile_markup_language.text == 'HTML')
+ self.assertTrue(self.sitemap_mobile_markup_language.text == 'HTML')
new_sitemap_mobile_markup_language =\
webmastertools.SitemapMobileMarkupLanguageFromString(
self.sitemap_mobile_markup_language.ToString())
- self.assert_(self.sitemap_mobile_markup_language.text ==\
+ self.assertTrue(self.sitemap_mobile_markup_language.text ==\
new_sitemap_mobile_markup_language.text)
@@ -266,10 +266,10 @@
def testToAndFromString(self):
self.publication_label.text = 'Value1'
- self.assert_(self.publication_label.text == 'Value1')
+ self.assertTrue(self.publication_label.text == 'Value1')
new_publication_label = webmastertools.PublicationLabelFromString(
self.publication_label.ToString())
- self.assert_(self.publication_label.text == new_publication_label.text)
+ self.assertTrue(self.publication_label.text == new_publication_label.text)
class SitemapNewsTest(unittest.TestCase):
@@ -280,17 +280,17 @@
def testToAndFromString(self):
self.sitemap_news.publication_label.append(webmastertools.PublicationLabel(
text = 'Value1'))
- self.assert_(self.sitemap_news.text is None)
- self.assert_(self.sitemap_news.publication_label[0].text == 'Value1')
+ self.assertTrue(self.sitemap_news.text is None)
+ self.assertTrue(self.sitemap_news.publication_label[0].text == 'Value1')
new_sitemap_news = webmastertools.SitemapNewsFromString(
self.sitemap_news.ToString())
- self.assert_(new_sitemap_news.text is None)
- self.assert_(self.sitemap_news.publication_label[0].text ==
+ self.assertTrue(new_sitemap_news.text is None)
+ self.assertTrue(self.sitemap_news.publication_label[0].text ==
new_sitemap_news.publication_label[0].text)
def testConvertActualData(self):
feed = webmastertools.SitemapsFeedFromString(test_data.SITEMAPS_FEED)
- self.assert_(len(feed.sitemap_news.publication_label) == 3)
+ self.assertTrue(len(feed.sitemap_news.publication_label) == 3)
check = 0
for publication_label in feed.sitemap_news.publication_label:
if publication_label.text == "Value1":
@@ -301,7 +301,7 @@
check = check | 4
else:
self.fail('Unexpected publication label: %s' % markup_language.text)
- self.assert_(check == 2 ** 3 - 1,
+ self.assertTrue(check == 2 ** 3 - 1,
'Something is wrong with publication label')
@@ -313,11 +313,11 @@
def testToAndFromString(self):
self.sitemap_news_publication_label.text = 'LabelValue'
- self.assert_(self.sitemap_news_publication_label.text == 'LabelValue')
+ self.assertTrue(self.sitemap_news_publication_label.text == 'LabelValue')
new_sitemap_news_publication_label =\
webmastertools.SitemapNewsPublicationLabelFromString(
self.sitemap_news_publication_label.ToString())
- self.assert_(self.sitemap_news_publication_label.text ==\
+ self.assertTrue(self.sitemap_news_publication_label.text ==\
new_sitemap_news_publication_label.text)
@@ -328,12 +328,12 @@
def testToAndFromString(self):
self.sitemap_last_downloaded.text = '2006-11-18T19:27:32.543Z'
- self.assert_(self.sitemap_last_downloaded.text ==\
+ self.assertTrue(self.sitemap_last_downloaded.text ==\
'2006-11-18T19:27:32.543Z')
new_sitemap_last_downloaded =\
webmastertools.SitemapLastDownloadedFromString(
self.sitemap_last_downloaded.ToString())
- self.assert_(self.sitemap_last_downloaded.text ==\
+ self.assertTrue(self.sitemap_last_downloaded.text ==\
new_sitemap_last_downloaded.text)
@@ -344,10 +344,10 @@
def testToAndFromString(self):
self.sitemap_type.text = 'WEB'
- self.assert_(self.sitemap_type.text == 'WEB')
+ self.assertTrue(self.sitemap_type.text == 'WEB')
new_sitemap_type = webmastertools.SitemapTypeFromString(
self.sitemap_type.ToString())
- self.assert_(self.sitemap_type.text == new_sitemap_type.text)
+ self.assertTrue(self.sitemap_type.text == new_sitemap_type.text)
class SitemapStatusTest(unittest.TestCase):
@@ -357,10 +357,10 @@
def testToAndFromString(self):
self.sitemap_status.text = 'Pending'
- self.assert_(self.sitemap_status.text == 'Pending')
+ self.assertTrue(self.sitemap_status.text == 'Pending')
new_sitemap_status = webmastertools.SitemapStatusFromString(
self.sitemap_status.ToString())
- self.assert_(self.sitemap_status.text == new_sitemap_status.text)
+ self.assertTrue(self.sitemap_status.text == new_sitemap_status.text)
class SitemapUrlCountTest(unittest.TestCase):
@@ -370,10 +370,10 @@
def testToAndFromString(self):
self.sitemap_url_count.text = '0'
- self.assert_(self.sitemap_url_count.text == '0')
+ self.assertTrue(self.sitemap_url_count.text == '0')
new_sitemap_url_count = webmastertools.SitemapUrlCountFromString(
self.sitemap_url_count.ToString())
- self.assert_(self.sitemap_url_count.text == new_sitemap_url_count.text)
+ self.assertTrue(self.sitemap_url_count.text == new_sitemap_url_count.text)
class SitesEntryTest(unittest.TestCase):
@@ -391,34 +391,34 @@
enhanced_image_search=webmastertools.EnhancedImageSearch(text='true'),
verified=webmastertools.Verified(text='false'),
)
- self.assert_(entry.indexed.text == 'true')
- self.assert_(entry.crawled.text == '2008-09-14T08:59:28.000')
- self.assert_(entry.geolocation.text == 'US')
- self.assert_(entry.preferred_domain.text == 'none')
- self.assert_(entry.crawl_rate.text == 'normal')
- self.assert_(entry.enhanced_image_search.text == 'true')
- self.assert_(entry.verified.text == 'false')
+ self.assertTrue(entry.indexed.text == 'true')
+ self.assertTrue(entry.crawled.text == '2008-09-14T08:59:28.000')
+ self.assertTrue(entry.geolocation.text == 'US')
+ self.assertTrue(entry.preferred_domain.text == 'none')
+ self.assertTrue(entry.crawl_rate.text == 'normal')
+ self.assertTrue(entry.enhanced_image_search.text == 'true')
+ self.assertTrue(entry.verified.text == 'false')
new_entry = webmastertools.SitesEntryFromString(entry.ToString())
- self.assert_(new_entry.indexed.text == 'true')
- self.assert_(new_entry.crawled.text == '2008-09-14T08:59:28.000')
- self.assert_(new_entry.geolocation.text == 'US')
- self.assert_(new_entry.preferred_domain.text == 'none')
- self.assert_(new_entry.crawl_rate.text == 'normal')
- self.assert_(new_entry.enhanced_image_search.text == 'true')
- self.assert_(new_entry.verified.text == 'false')
+ self.assertTrue(new_entry.indexed.text == 'true')
+ self.assertTrue(new_entry.crawled.text == '2008-09-14T08:59:28.000')
+ self.assertTrue(new_entry.geolocation.text == 'US')
+ self.assertTrue(new_entry.preferred_domain.text == 'none')
+ self.assertTrue(new_entry.crawl_rate.text == 'normal')
+ self.assertTrue(new_entry.enhanced_image_search.text == 'true')
+ self.assertTrue(new_entry.verified.text == 'false')
def testConvertActualData(self):
feed = webmastertools.SitesFeedFromString(test_data.SITES_FEED)
- self.assert_(len(feed.entry) == 1)
+ self.assertTrue(len(feed.entry) == 1)
entry = feed.entry[0]
- self.assert_(isinstance(entry, webmastertools.SitesEntry))
- self.assert_(entry.indexed.text == 'true')
- self.assert_(entry.crawled.text == '2008-09-14T08:59:28.000')
- self.assert_(entry.geolocation.text == 'US')
- self.assert_(entry.preferred_domain.text == 'none')
- self.assert_(entry.crawl_rate.text == 'normal')
- self.assert_(entry.enhanced_image_search.text == 'true')
- self.assert_(entry.verified.text == 'false')
+ self.assertTrue(isinstance(entry, webmastertools.SitesEntry))
+ self.assertTrue(entry.indexed.text == 'true')
+ self.assertTrue(entry.crawled.text == '2008-09-14T08:59:28.000')
+ self.assertTrue(entry.geolocation.text == 'US')
+ self.assertTrue(entry.preferred_domain.text == 'none')
+ self.assertTrue(entry.crawl_rate.text == 'normal')
+ self.assertTrue(entry.enhanced_image_search.text == 'true')
+ self.assertTrue(entry.verified.text == 'false')
class SitesFeedTest(unittest.TestCase):
@@ -427,13 +427,13 @@
self.feed = gdata.webmastertools.SitesFeedFromString(test_data.SITES_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 1)
+ self.assertTrue(len(self.feed.entry) == 1)
for entry in self.feed.entry:
- self.assert_(isinstance(entry, webmastertools.SitesEntry))
+ self.assertTrue(isinstance(entry, webmastertools.SitesEntry))
new_feed = webmastertools.SitesFeedFromString(self.feed.ToString())
- self.assert_(len(new_feed.entry) == 1)
+ self.assertTrue(len(new_feed.entry) == 1)
for entry in new_feed.entry:
- self.assert_(isinstance(entry, webmastertools.SitesEntry))
+ self.assertTrue(isinstance(entry, webmastertools.SitesEntry))
class SitemapsEntryTest(unittest.TestCase):
@@ -446,48 +446,48 @@
text='2006-11-18T19:27:32.543Z'),
sitemap_url_count=webmastertools.SitemapUrlCount(text='102'),
)
- self.assert_(entry.sitemap_type.text == 'WEB')
- self.assert_(entry.sitemap_status.text == 'Pending')
- self.assert_(entry.sitemap_last_downloaded.text ==\
+ self.assertTrue(entry.sitemap_type.text == 'WEB')
+ self.assertTrue(entry.sitemap_status.text == 'Pending')
+ self.assertTrue(entry.sitemap_last_downloaded.text ==\
'2006-11-18T19:27:32.543Z')
- self.assert_(entry.sitemap_url_count.text == '102')
+ self.assertTrue(entry.sitemap_url_count.text == '102')
new_entry = webmastertools.SitemapsEntryFromString(entry.ToString())
- self.assert_(new_entry.sitemap_type.text == 'WEB')
- self.assert_(new_entry.sitemap_status.text == 'Pending')
- self.assert_(new_entry.sitemap_last_downloaded.text ==\
+ self.assertTrue(new_entry.sitemap_type.text == 'WEB')
+ self.assertTrue(new_entry.sitemap_status.text == 'Pending')
+ self.assertTrue(new_entry.sitemap_last_downloaded.text ==\
'2006-11-18T19RefactoringTool: Refactored ./tests/gdata_tests/spreadsheets/live_client_test.py
:27:32.543Z')
- self.assert_(new_entry.sitemap_url_count.text == '102')
+ self.assertTrue(new_entry.sitemap_url_count.text == '102')
def testConvertActualData(self):
feed = gdata.webmastertools.SitemapsFeedFromString(test_data.SITEMAPS_FEED)
- self.assert_(len(feed.entry) == 3)
+ self.assertTrue(len(feed.entry) == 3)
for entry in feed.entry:
- self.assert_(entry, webmastertools.SitemapsEntry)
- self.assert_(entry.sitemap_status, webmastertools.SitemapStatus)
- self.assert_(entry.sitemap_last_downloaded,
+ self.assertTrue(entry, webmastertools.SitemapsEntry)
+ self.assertTrue(entry.sitemap_status, webmastertools.SitemapStatus)
+ self.assertTrue(entry.sitemap_last_downloaded,
webmastertools.SitemapLastDownloaded)
- self.assert_(entry.sitemap_url_count, webmastertools.SitemapUrlCount)
- self.assert_(entry.sitemap_status.text == 'StatusValue')
- self.assert_(entry.sitemap_last_downloaded.text ==\
+ self.assertTrue(entry.sitemap_url_count, webmastertools.SitemapUrlCount)
+ self.assertTrue(entry.sitemap_status.text == 'StatusValue')
+ self.assertTrue(entry.sitemap_last_downloaded.text ==\
'2006-11-18T19:27:32.543Z')
- self.assert_(entry.sitemap_url_count.text == '102')
+ self.assertTrue(entry.sitemap_url_count.text == '102')
if entry.id.text == 'http://www.example.com/sitemap-index.xml':
- self.assert_(entry.sitemap_type, webmastertools.SitemapType)
- self.assert_(entry.sitemap_type.text == 'WEB')
- self.assert_(entry.sitemap_mobile_markup_language is None)
- self.assert_(entry.sitemap_news_publication_label is None)
+ self.assertTrue(entry.sitemap_type, webmastertools.SitemapType)
+ self.assertTrue(entry.sitemap_type.text == 'WEB')
+ self.assertTrue(entry.sitemap_mobile_markup_language is None)
+ self.assertTrue(entry.sitemap_news_publication_label is None)
elif entry.id.text == 'http://www.example.com/mobile/sitemap-index.xml':
- self.assert_(entry.sitemap_mobile_markup_language,
+ self.assertTrue(entry.sitemap_mobile_markup_language,
webmastertools.SitemapMobileMarkupLanguage)
- self.assert_(entry.sitemap_mobile_markup_language.text == 'HTML')
- self.assert_(entry.sitemap_type is None)
- self.assert_(entry.sitemap_news_publication_label is None)
+ self.assertTrue(entry.sitemap_mobile_markup_language.text == 'HTML')
+ self.assertTrue(entry.sitemap_type is None)
+ self.assertTrue(entry.sitemap_news_publication_label is None)
elif entry.id.text == 'http://www.example.com/news/sitemap-index.xml':
- self.assert_(entry.sitemap_news_publication_label,
+ self.assertTrue(entry.sitemap_news_publication_label,
webmastertools.SitemapNewsPublicationLabel)
- self.assert_(entry.sitemap_news_publication_label.text == 'LabelValue')
- self.assert_(entry.sitemap_type is None)
- self.assert_(entry.sitemap_mobile_markup_language is None)
+ self.assertTrue(entry.sitemap_news_publication_label.text == 'LabelValue')
+ self.assertTrue(entry.sitemap_type is None)
+ self.assertTrue(entry.sitemap_mobile_markup_language is None)
class SitemapsFeedTest(unittest.TestCase):
@@ -497,13 +497,13 @@
test_data.SITEMAPS_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 3)
+ self.assertTrue(len(self.feed.entry) == 3)
for entry in self.feed.entry:
- self.assert_(isinstance(entry, webmastertools.SitemapsEntry))
+ self.assertTrue(isinstance(entry, webmastertools.SitemapsEntry))
new_feed = webmastertools.SitemapsFeedFromString(self.feed.ToString())
- self.assert_(len(new_feed.entry) == 3)
+ self.assertTrue(len(new_feed.entry) == 3)
for entry in new_feed.entry:
- self.assert_(isinstance(entry, webmastertools.SitemapsEntry))
+ self.assertTrue(isinstance(entry, webmastertools.SitemapsEntry))
if __name__ == '__main__':
--- ./tests/gdata_tests/spreadsheets/live_client_test.py (original)
+++ ./tests/gdata_tests/spreadsheets/live_client_test.py (refactored)
@@ -55,14 +55,14 @@
spreadsheet_id = conf.options.get_value('spreadsheetid')
original_worksheets = self.client.get_worksheets(spreadsheet_id)
- self.assert_(isinstance(original_worksheets,
+ self.assertTrue(isinstance(original_worksheets,
gdata.spreadsheets.data.WorksheetsFeed))
worksheet_count = int(original_worksheets.total_results.text)
# Add a new worksheet to the spreadsheet.
created = self.client.add_worksheet(
spreadsheet_id, 'a test worksheet', 4, 8)
- self.assert_(isinstance(created,
+ self.assertTrue(isinstance(created,
gdata.spreadsheets.data.WorksheetEntry))
self.assertEqual(created.title.text, 'a test worksheet')
self.assertEqual(created.row_count.text, '4')
@@ -93,7 +93,7 @@
test_worksheet = self.client.add_worksheet(
spreadsheet_id, 'worksheet x', rows=30, cols=3)
- self.assert_(isinstance(tables, gdata.spreadsheets.data.TablesFeed))
+ self.assertTrue(isinstance(tables, gdata.spreadsheets.data.TablesFeed))
initial_count = tables.total_results.text
created_table = self.client.add_table(
@@ -112,10 +112,10 @@
table_num = int(created_table.get_table_id())
starting_records = self.client.get_records(spreadsheet_id, table_num)
self.assertEqual(starting_records.total_results.text, '10')
- self.assert_(starting_records.entry[0].field[0].text is None)
- self.assert_(starting_records.entry[0].field[1].text is None)
- self.assert_(starting_records.entry[1].field[0].text is None)
- self.assert_(starting_records.entry[1].field[1].text is None)
+ self.assertTrue(starting_records.entry[0].field[0].text is None)
+ self.assertTrue(starting_records.entry[0].field[1].text is None)
+ self.assertTrue(starting_records.entry[1].field[0].text is None)
+ self.assertTrue(starting_records.entry[1].field[1].text is None)
record1 = self.client.add_record(
spreadsheet_id, table_num,
@@ -130,14 +130,14 @@
self.assertEqual(updated_records.entry[10].value_for_index('A'), '2.99')
self.assertEqual(updated_records.entry[10].value_for_name('Drink'),
'Soda')
- self.assert_(updated_records.entry[11].value_for_name('Price') is None)
+ self.assertTrue(updated_records.entry[11].value_for_name('Price') is None)
self.assertEqual(updated_records.entry[11].value_for_name('Drink'),
'Milk')
self.assertEqual(updated_records.entry[12].value_for_name('Drink'),
'Water')
- self.assert_(updated_records.entry[1].value_for_index('A') is None)
- self.assert_(updated_records.entry[2].value_for_index('B') is None)
- self.assert_(updated_records.entry[3].value_for_index('C') is None)
+ self.assertTrue(updated_records.entry[1].value_for_index('A') is None)
+ self.assertTrue(updated_records.entry[2].value_for_index('B') is None)
+ self.assertTrue(updated_records.entry[3].value_for_index('C') is None)
# Cleanup the table.
self.client.delete(created_table)
@@ -165,13 +165,13 @@
spreadsheet_id, test_worksheet.get_worksheet_id(), 1, 1)
cell_entry.cell.input_value = 'a test'
result = self.client.update(cell_entry)
- self.assertEquals(cell_entry.cell.input_value, result.cell.input_value)
+ self.assertEqual(cell_entry.cell.input_value, result.cell.input_value)
# Verify that the value was set.
cells = self.client.get_cells(
spreadsheet_id, test_worksheet.get_worksheet_id())
- self.assertEquals(len(cells.entry), 1)
- self.assertEquals(cells.entry[0].cell.input_value, 'a test')
+ self.assertEqual(len(cells.entry), 1)
+ self.assertEqual(cells.entry[0].cell.input_value, 'a test')
# Delete the test worksheet.
self.client.delete(test_worksheet, force=True)
@@ -179,9 +179,9 @@
def set_cell(self, spreadsheet_id, worksheet_id, row, column, value):
cell_entry = self.cRefactoringTool: Refactored ./tests/gdata_tests/spreadsheets/data_test.py
RefactoringTool: Refactored ./tests/gdata_tests/spreadsheet_test.py
lient.get_cell(
spreadsheet_id, worksheet_id, row, column)
- self.assert_(cell_entry is not None)
+ self.assertTrue(cell_entry is not None)
cell_entry.cell.input_value = value
- self.assert_(self.client.update(cell_entry) is not None)
+ self.assertTrue(self.client.update(cell_entry) is not None)
def test_batch_set_cells(self):
if not conf.options.get_value('runlive') == 'true':
@@ -227,25 +227,25 @@
entry = gdata.spreadsheets.data.ListEntry()
entry.from_dict({'cola': 'alpha', 'colb': 'beta', 'colc': 'gamma'})
added = self.client.add_list_entry(entry, spreadsheet_id, worksheet_id)
- self.assert_(isinstance(added, gdata.spreadsheets.data.ListEntry))
- self.assertEquals(added.get_value('cola'), 'alpha')
+ self.assertTrue(isinstance(added, gdata.spreadsheets.data.ListEntry))
+ self.assertEqual(added.get_value('cola'), 'alpha')
# Update the row.
added.from_dict({'cola': '1', 'colb': '2', 'colc': '3'})
updated = self.client.update(added)
- self.assert_(isinstance(updated, gdata.spreadsheets.data.ListEntry))
- self.assertEquals(updated.get_value('cola'), '1')
+ self.assertTrue(isinstance(updated, gdata.spreadsheets.data.ListEntry))
+ self.assertEqual(updated.get_value('cola'), '1')
# Check the number of rows.
rows = self.client.get_list_feed(spreadsheet_id, worksheet_id)
- self.assertEquals(len(rows.entry), 1)
+ self.assertEqual(len(rows.entry), 1)
# Remove the row.
self.client.delete(updated)
# Check that it was removed.
rows = self.client.get_list_feed(spreadsheet_id, worksheet_id)
- self.assertEquals(len(rows.entry), 0)
+ self.assertEqual(len(rows.entry), 0)
# Delete the test worksheet.
self.client.delete(test_worksheet, force=True)
--- ./tests/gdata_tests/spreadsheets/data_test.py (original)
+++ ./tests/gdata_tests/spreadsheets/data_test.py (refactored)
@@ -566,16 +566,16 @@
row.set_value('x', 'Test')
self.assertEqual(row.get_value('x'), 'Test')
row_xml = str(row)
- self.assert_(row_xml.find(':x') > -1)
- self.assert_(row_xml.find('>Test') > -1)
- self.assert_(row_xml.find(':hours') > -1)
- self.assert_(row_xml.find('>3') > -1)
- self.assert_(row_xml.find(':ipm') > -1)
- self.assert_(row_xml.find('>1') > -1)
- self.assert_(row_xml.find(':items') > -1)
- self.assert_(row_xml.find('>60') > -1)
- self.assert_(row_xml.find(':name') > -1)
- self.assert_(row_xml.find('>Lizzy') > -1)
+ self.assertTrue(row_xml.find(':x') > -1)
+ self.assertTrue(row_xml.find('>Test') > -1)
+ self.assertTrue(row_xml.find(':hours') > -1)
+ self.assertTrue(row_xml.find('>3') > -1)
+ self.assertTrue(row_xml.find(':ipm') > -1)
+ self.assertTrue(row_xml.find('>1') > -1)
+ self.assertTrue(row_xml.find(':items') > -1)
+ self.assertTrue(row_xml.find('>60') > -1)
+ self.assertTrue(row_xml.find(':name') > -1)
+ self.assertTrue(row_xml.find('>Lizzy') > -1)
self.assertEqual(row_xml.find(':zzz'), -1)
self.assertEqual(row_xml.find('>foo'), -1)
--- ./tests/gdata_tests/spreadsheet_test.py (original)
+++ ./tests/gdata_tests/spreadsheet_test.py (refactored)
@@ -221,9 +221,9 @@
def testToAndFromString(self):
self.col_count.text = '20'
- self.assert_(self.col_count.text == '20')
+ self.assertTrue(self.col_count.text == '20')
new_col_count = gdata.spreadsheet.ColCountFromString(self.col_count.ToString())
- self.assert_(self.col_count.text == new_col_count.text)
+ self.assertTrue(self.col_count.text == new_col_count.text)
class RowCountTest(unittest.TestCase):
@@ -233,9 +233,9 @@
def testToAndFromString(self):
self.row_count.text = '100'
- self.assert_(self.row_count.text == '100')
+ self.assertTrue(self.row_count.text == '100')
new_row_count = gdata.spreadsheet.RowCountFromString(self.row_count.ToString())
- self.assert_(self.row_count.text == new_row_count.text)
+ self.assertTrue(self.row_count.text == new_row_count.text)
class CellTest(unittest.TestCase):
@@ -245,21 +245,21 @@
def testToAndFromString(self):
self.cell.text = 'test cell'
- self.assert_(self.cell.text == 'test cell')
+ self.assertTrue(self.cell.text == 'test cell')
self.cell.row = '1'
- self.assert_(self.cell.row == '1')
+ self.assertTrue(self.cell.row == '1')
self.cell.col = '2'
- self.assert_(self.cell.col == '2')
+ self.assertTrue(self.cell.col == '2')
self.cell.inputValue = 'test input value'
- self.assert_(self.cell.inputValue == 'test input value')
+ self.assertTrue(self.cell.inputValue == 'test input value')
self.cell.numericValue = 'test numeric value'
- self.assert_(self.cell.numericValue == 'test numeric value')
+ self.assertTrue(self.cell.numericValue == 'test numeric value')
new_cell = gdata.spreadsheet.CellFromString(self.cell.ToString())
- self.assert_(self.cell.text == new_cell.text)
- self.assert_(self.cell.row == new_cell.row)
- self.assert_(self.cell.col == new_cell.col)
- self.assert_(self.cell.inputValue == new_cell.inputValue)
- self.assert_(self.cell.numericValue == new_cell.numericValue)
+ self.assertTrue(self.cell.text == new_cell.text)
+ self.assertTrue(self.cell.row == new_cell.row)
+ self.assertTrue(self.cell.col == new_cell.col)
+ self.assertTrue(self.cell.inputValue == new_cell.inputValue)
+ self.assertTrue(self.cell.numericValue == new_cell.numericValue)
class CustomTest(unittest.TestCase):
@@ -270,11 +270,11 @@
def testToAndFromString(self):
self.custom.text = 'value'
self.custom.column = 'column_name'
- self.assert_(self.custom.text == 'value')
- self.assert_(self.custom.column == 'column_name')
+ self.assertTrue(self.custom.text == 'value')
+ self.assertTrue(self.custom.column == 'column_name')
new_custom = gdata.spreadsheet.CustomFromString(self.custom.ToString())
- self.assert_(self.custom.text == new_custom.text)
- self.assert_(self.custom.column == new_custom.column)
+ self.assertTrue(self.custom.text == new_custom.text)
+ self.assertTrue(self.custom.column == new_custom.column)
class SpreadsheetsWorksheetTest(unittest.TestCase):
@@ -284,13 +284,13 @@
def testToAndFromString(self):
self.worksheet.row_count = gdata.spreadsheet.RowCount(text='100')
- self.assert_(self.worksheet.row_count.text == '100')
+ self.assertTrue(self.worksheet.row_count.text == '100')
self.worksheet.col_count = gdata.spreadsheet.ColCount(text='20')
- self.assert_(self.worksheet.col_count.text == '20')
+ self.assertTrue(self.worksheet.col_count.text == '20')
new_worksheet = gdata.spreadsheet.SpreadsheetsWorksheetFromString(
self.worksheet.ToString())
- self.assert_(self.worksheet.row_count.text == new_worksheet.row_count.text)
- self.assert_(self.worksheet.col_count.text == new_worksheet.col_count.text)
+ self.assertTrue(self.worksheet.row_count.text == new_worksheet.row_count.text)
+ self.assertTrue(self.worksheet.col_count.text == new_worksheet.col_count.text)
class SpreadsheetsCellTest(unittest.TestCase):
@@ -301,17 +301,17 @@
def testToAndFromString(self):
self.entry.cell = gdata.spreadsheet.Cell(text='my cell', row='1', col='2',
inputValue='my input value', numericValue='my numeric value')
- self.assert_(self.entry.cell.text == 'my cell')
- self.assert_(self.entry.cell.row == '1')
- self.assert_(self.entry.cell.col == '2')
- self.assert_(self.entry.cell.inputValue == 'my input value')
- self.assert_(self.entry.cell.numericValue == 'my numeric value')
+ self.assertTrue(self.entry.cell.text == 'my cell')
+ self.assertTrue(self.entry.cell.row == '1')
+ self.assertTrue(self.entry.cell.col == '2')
+ self.assertTrue(self.entry.cell.inputValue == 'my input value')
+ self.assertTrue(self.entry.cell.numericValue == 'my numeric value')
new_cell = gdata.spreadsheet.SpreadsheetsCellFromString(self.entry.ToString())
- self.assert_(self.entry.cell.text == new_cell.cell.text)
- self.assert_(self.entry.cell.row == new_cell.cell.row)
- self.assert_(self.entry.cell.col == new_cell.cell.col)
- self.assert_(self.entry.cell.inputValue == new_cell.cell.inputValue)
- self.assert_(self.entry.cell.numericValue == new_cell.cell.numericValue)
+ self.assertTrue(self.entry.cell.text == new_cell.cell.text)
+ self.assertTrue(self.entry.cell.row == new_cell.cell.row)
+ self.assertTrue(self.entry.cell.col == new_cell.cell.col)
+ self.assertTrue(self.entry.cell.inputValue == new_cell.cell.inputValue)
+ self.assertTrue(self.entry.cell.numericValue == new_cell.cell.numericValue)
class SpreadsheetsListTest(unittest.TestCase):
@@ -324,15 +324,15 @@
text='my first column')
self.row.custom['column_2'] = gdata.spreadsheet.Custom(column='column_2',
text='my second column')
- self.assert_(self.row.custom['column_1'].column == 'column_1')
- self.assert_(self.row.custom['column_1'].text == 'my first column')
- self.assert_(self.row.custom['column_2'].column == 'column_2')
- self.assert_(self.row.custom['column_2'].text == 'my second column')
+ self.assertTrue(self.row.custom['column_1'].column == 'column_1')
+ self.assertTrue(self.row.custom['column_1'].text == 'my first column')
+ self.assertTrue(self.row.custom['column_2'].column == 'column_2')
+ self.assertTrue(self.row.custom['column_2'].text == 'my second column')
new_row = gdata.spreadsheet.SpreadsheetsListFromString(self.row.ToString())
- self.assert_(self.row.custom['column_1'].column == new_row.custom['column_1'].column)
- self.assert_(self.row.custom['column_1'].text == new_row.custom['column_1'].text)
- self.assert_(self.row.custom['column_2'].column == new_row.custom['column_2'].column)
- self.assert_(self.row.custom['column_2'].text == new_row.custom['column_2'].text)
+ self.assertTrue(self.row.custom['column_1'].column == new_row.custom['column_1'].column)
+ self.assertTrue(self.row.custom['column_1'].text == new_row.custom['column_1'].text)
+ self.assertTrue(self.row.custom['column_2'].column == new_row.custom['column_2'].column)
+ self.assertTrue(self.row.custom['column_2'].text == new_row.custom['column_2'].text)
class SpreadsheetsSpreadsheetsFeedTest(unittest.TestCase):
@@ -343,13 +343,13 @@
SPREADSHEETS_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 1)
+ self.assertTrue(len(self.feed.entry) == 1)
for an_entry in self.feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsSpreadsheet))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsSpreadsheet))
new_feed = gdata.spreadsheet.SpreadsheetsSpreadsheetsFeedFromString(
str(self.feed))
for an_entry in new_feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsSpreadsheet))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsSpreadsheet))
class SpreadsheetsWorksheetsFeedTest(unittest.TestCase):
@@ -359,13 +359,13 @@
WORKSHEETS_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 1)
+ self.assertTrue(len(self.feed.entry) == 1)
for an_entry in self.feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsWorksheet))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsWorksheet))
new_feed = gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString(
str(self.feed))
for an_entry in new_feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsWorksheet))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsWorksheet))
class SpreadsheetsCellsFeedTest(unittest.TestCase):
@@ -375,18 +375,18 @@
CELLS_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 2)
+ self.assertTrue(len(self.feed.entry) == 2)
for an_entry in self.feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsCell))
+ self.assertTrue(isinstance(an_entry,RefactoringTool: Refactored ./tests/gdata_tests/spreadsheet/text_db_test.py
gdata.spreadsheet.SpreadsheetsCell))
new_feed = gdata.spreadsheet.SpreadsheetsCellsFeedFromString(str(self.feed))
- self.assert_(isinstance(new_feed.row_count,
+ self.assertTrue(isinstance(new_feed.row_count,
gdata.spreadsheet.RowCount))
- self.assert_(new_feed.row_count.text == '100')
- self.assert_(isinstance(new_feed.col_count,
+ self.assertTrue(new_feed.row_count.text == '100')
+ self.assertTrue(isinstance(new_feed.col_count,
gdata.spreadsheet.ColCount))
- self.assert_(new_feed.col_count.text == '20')
+ self.assertTrue(new_feed.col_count.text == '20')
for an_entry in new_feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsCell))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsCell))
class SpreadsheetsListFeedTest(unittest.TestCase):
@@ -396,12 +396,12 @@
LIST_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 2)
+ self.assertTrue(len(self.feed.entry) == 2)
for an_entry in self.feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsList))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsList))
new_feed = gdata.spreadsheet.SpreadsheetsListFeedFromString(str(self.feed))
for an_entry in new_feed.entry:
- self.assert_(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsList))
+ self.assertTrue(isinstance(an_entry, gdata.spreadsheet.SpreadsheetsList))
if __name__ == '__main__':
unittest.main()
--- ./tests/gdata_tests/spreadsheet/text_db_test.py (original)
+++ ./tests/gdata_tests/spreadsheet/text_db_test.py (refactored)
@@ -37,7 +37,7 @@
try:
self.client.SetCredentials('foo', 'bar')
self.fail()
- except gdata.spreadsheet.text_db.Error, e:
+ except gdata.spreadsheet.text_db.Error as e:
pass
def testCreateGetAndDeleteDatabase(self):
@@ -47,13 +47,13 @@
# Test finding the database using the name
time.sleep(5)
db_list = self.client.GetDatabases(name=db_title)
- self.assert_(len(db_list) >= 1)
+ self.assertTrue(len(db_list) >= 1)
if len(db_list) >= 1:
- self.assert_(db_list[0].entry.title.text == db_title)
+ self.assertTrue(db_list[0].entry.title.text == db_title)
# Test finding the database using the spreadsheet key
db_list = self.client.GetDatabases(spreadsheet_key=db.spreadsheet_key)
- self.assert_(len(db_list) == 1)
- self.assert_(db_list[0].entry.title.text == db_title)
+ self.assertTrue(len(db_list) == 1)
+ self.assertTrue(db_list[0].entry.title.text == db_title)
# Delete the test spreadsheet
time.sleep(10)
db.Delete()
@@ -73,12 +73,12 @@
table = self.db.CreateTable('test1', ['1','2','3'])
# Try to get the new table using the worksheet id.
table_list = self.db.GetTables(worksheet_id=table.worksheet_id)
- self.assert_(len(table_list) == 1)
- self.assert_(table_list[0].entry.title.text, 'test1')
+ self.assertTrue(len(table_list) == 1)
+ self.assertTrue(table_list[0].entry.title.text, 'test1')
# Try to get the table using the name
table_list = self.db.GetTables(name='test1')
- self.assert_(len(table_list) == 1)
- self.assert_(table_list[0].entry.title.text, 'test1')
+ self.assertTrue(len(table_list) == 1)
+ self.assertTrue(table_list[0].entry.title.text, 'test1')
# Delete the table
table.Delete()
@@ -98,14 +98,14 @@
new_record = self.table.AddRecord({'a':'test1', 'b':'test2', 'cd':'test3', 'a_2':'test4', 'de':'test5'})
# Test getting record by line number.
record = self.table.GetRecord(row_number=1)
- self.assert_(record is not None)
- self.assert_(record.content['a'] == 'test1')
- self.assert_(record.content['b'] == 'test2')
- self.assert_(record.content['cd'] == 'test3')
- self.assert_(record.content['a_2'] == 'test4')
+ self.assertTrue(record is not None)
+ self.assertTrue(record.content['a'] == 'test1')
+ self.assertTrue(record.content['b'] == 'test2')
+ self.aRefactoringTool: Refactored ./tests/gdata_tests/spreadsheet/service_test.py
ssertTrue(record.content['cd'] == 'test3')
+ self.assertTrue(record.content['a_2'] == 'test4')
# Test getting record using the id.
record_list = self.table.GetRecord(row_id=new_record.row_id)
- self.assert_(record is not None)
+ self.assertTrue(record is not None)
# Delete the record.
time.sleep(10)
new_record.Delete()
@@ -121,14 +121,14 @@
# Try to get the changes before they've been committed
second_copy.Pull()
- self.assert_(second_copy.content['a'] == '1')
- self.assert_(second_copy.content['b'] == '2')
+ self.assertTrue(second_copy.content['a'] == '1')
+ self.assertTrue(second_copy.content['b'] == '2')
# Commit the changes, the content should now be different
first_copy.Push()
second_copy.Pull()
- self.assert_(second_copy.content['a'] == '7')
- self.assert_(second_copy.content['b'] == '9')
+ self.assertTrue(second_copy.content['a'] == '7')
+ self.assertTrue(second_copy.content['b'] == '9')
# Make changes to the second copy, push, then try to push changes from
# the first copy.
@@ -141,7 +141,7 @@
self.fail()
except gdata.spreadsheet.service.RequestError:
pass
- except Exception, error:
+ except Exception as error:
#TODO: Why won't the except RequestError catch this?
pass
@@ -157,18 +157,18 @@
time.sleep(10)
matches = self.table.FindRecords('a == 1')
- self.assert_(len(matches) == 1)
- self.assert_(matches[0].content['a'] == '1')
- self.assert_(matches[0].content['b'] == '2')
+ self.assertTrue(len(matches) == 1)
+ self.assertTrue(matches[0].content['a'] == '1')
+ self.assertTrue(matches[0].content['b'] == '2')
matches = self.table.FindRecords('a > 1 && cd < 20')
- self.assert_(len(matches) == 4)
+ self.assertTrue(len(matches) == 4)
matches = self.table.FindRecords('cd < de')
- self.assert_(len(matches) == 7)
+ self.assertTrue(len(matches) == 7)
matches = self.table.FindRecords('a == b')
- self.assert_(len(matches) == 0)
+ self.assertTrue(len(matches) == 0)
matches = self.table.FindRecords('a == 5')
- self.assert_(len(matches) == 1)
+ self.assertTrue(len(matches) == 1)
def testIterateResultSet(self):
# Populate the table with test data.
@@ -182,27 +182,27 @@
# Get the first two rows.
records = self.table.GetRecords(1, 2)
- self.assert_(len(records) == 2)
- self.assert_(records[0].content['a'] == '1')
- self.assert_(records[1].content['a'] == 'hi')
+ self.assertTrue(len(records) == 2)
+ self.assertTrue(records[0].content['a'] == '1')
+ self.assertTrue(records[1].content['a'] == 'hi')
# Then get the next two rows.
next_records = records.GetNext()
- self.assert_(len(next_records) == 2)
- self.assert_(next_records[0].content['a'] == '2')
- self.assert_(next_records[0].content['cd'] == '3')
- self.assert_(next_records[1].content['cd'] == '15')
- self.assert_(next_records[1].content['de'] == '7')
+ self.assertTrue(len(next_records) == 2)
+ self.assertTrue(next_records[0].content['a'] == '2')
+ self.assertTrue(next_records[0].content['cd'] == '3')
+ self.assertTrue(next_records[1].content['cd'] == '15')
+ self.assertTrue(next_records[1].content['de'] == '7')
def testLookupFieldsOnPreexistingTable(self):
existing_table = self.db.GetTables(name='test1')[0]
existing_table.LookupFields()
- self.assertEquals(existing_table.fields, ['a', 'b', 'cd', 'a_2', 'de'])
+ self.assertEqual(existing_table.fields, ['a', 'b', 'cd', 'a_2', 'de'])
if __name__ == '__main__':
if not username:
- username = raw_input('Spreadsheets API | Text DB Tests\n'
+ username = input('Spreadsheets API | Text DB Tests\n'
'Please enter your username: ')
if not password:
password = getpass.getpass()
--- ./tests/gdata_tests/spreadsheet/service_test.py (original)
+++ ./tests/gdata_tests/spreadsheet/service_test.py (refactored)
@@ -42,13 +42,13 @@
def testTitle(self):
self.query['title'] = 'my title'
- self.assert_(self.query['title'] == 'my title')
- self.assert_(self.query.ToUri() == '?title=my+title')
+ self.assertTrue(self.query['title'] == 'my title')
+ self.assertTrue(self.query.ToUri() == '?title=my+title')
def testTitleExact(self):
self.query['title-exact'] = 'true'
- self.assert_(self.query['title-exact'] == 'true')
- self.assert_(self.query.ToUri() == '?title-exact=true')
+ self.assertTrue(self.query['title-exact'] == 'true')
+ self.assertTrue(self.query.ToUri() == '?title-exact=true')
class CellQueryTest(unittest.TestCase):
@@ -58,33 +58,33 @@
def testMinRow(self):
self.query['min-row'] = '1'
- self.assert_(self.query['min-row'] == '1')
- self.assert_(self.query.ToUri() == '?min-row=1')
+ self.assertTrue(self.query['min-row'] == '1')
+ self.assertTrue(self.query.ToUri() == '?min-row=1')
def testMaxRow(self):
self.query['max-row'] = '100'
- self.assert_(self.query['max-row'] == '100')
- self.assert_(self.query.ToUri() == '?max-row=100')
+ self.assertTrue(self.query['max-row'] == '100')
+ self.assertTrue(self.query.ToUri() == '?max-row=100')
def testMinCol(self):
self.query['min-col'] = '2'
- self.assert_(self.query['min-col'] == '2')
- self.assert_(self.query.ToUri() == '?min-col=2')
+ self.assertTrue(self.query['min-col'] == '2')
+ self.assertTrue(self.query.ToUri() == '?min-col=2')
def testMaxCol(self):
self.query['max-col'] = '20'
- self.assert_(self.query['max-col'] == '20')
- self.assert_(self.query.ToUri() == '?max-col=20')
+ self.assertTrue(self.query['max-col'] == '20')
+ self.assertTrue(self.query.ToUri() == '?max-col=20')
def testRange(self):
self.query['range'] = 'A1:B4'
- self.assert_(self.query['range'] == 'A1:B4')
- self.assert_(self.query.ToUri() == '?range=A1%3AB4')
+ self.assertTrue(self.query['range'] == 'A1:B4')
+ self.assertTrue(self.query.ToUri() == '?range=A1%3AB4')
def testReturnEmpty(self):
self.query['return-empty'] = 'false'
- self.assert_(self.query['return-empty'] == 'false')
- self.assert_(self.query.ToUri() == '?return-empty=false')
+ self.assertTrue(self.query['return-empty'] == 'false')
+ self.assertTrue(self.query.ToUri() == '?return-empty=false')
class ListQueryTest(unittest.TestCase):
@@ -94,18 +94,18 @@
def testSpreadsheetQuery(self):
self.query['sq'] = 'first=john&last=smith'
- self.assert_(self.query['sq'] == 'first=john&last=smith')
- self.assert_(self.query.ToUri() == '?sq=first%3Djohn%26last%3Dsmith')
+ self.assertTrue(self.query['sq'] == 'first=john&last=smith')
+ self.assertTrue(self.query.ToUri() == '?sq=first%3Djohn%26last%3Dsmith')
def testOrderByQuery(self):
self.query['orderby'] = 'column:first'
- self.assert_(self.query['orderby'] == 'column:first')
- self.assert_(self.query.ToUri() == '?orderby=column%3Afirst')
+ self.assertTrue(self.query['orderby'] == 'column:first')
+ self.assertTrue(self.query.ToUri() == '?orderby=column%3Afirst')
def testReverseQuery(self):
self.query['reverse'] = 'true'
- self.assert_(self.query['reverse'] == 'true')
- self.assert_(self.query.ToUri() == '?reverse=true')
+ self.assertTrue(self.query['reverse'] == 'true')
+ self.assertTrue(self.query.ToUri() == '?reverse=true')
class SpreadsheetsServiceTest(unittest.TestCase):
@@ -121,25 +121,25 @@
def testGetSpreadsheetsFeed(self):
entry = self.gd_client.GetSpreadsheetsFeed(self.key)
- self.assert_(isinstance(entry, gdata.spreadsheet.SpreadsheetsSpreadsheet))
+ self.assertTrue(isinstance(entry, gdata.spreadsheet.SpreadsheetsSpreadsheet))
def testGetWorksheetsFeed(self):
feed = self.gd_client.GetWorksheetsFeed(self.key)
- self.assert_(isinstance(feed, gdata.spreadsheet.SpreadsheetsWorksheetsFeed))
+ self.assertTrue(isinstance(feed, gdata.spreadsheet.SpreadsheetsWorksheetsFeed))
entry = self.gd_client.GetWorksheetsFeed(self.key, self.worksheet)
- self.assert_(isinstance(entry, gdata.spreadsheet.SpreadsheetsWorksheet))
+ self.assertTrue(isinstance(entry, gdata.spreadsheet.SpreadsheetsWorksheet))
def testGetCellsFeed(self):
feed = self.gd_client.GetCellsFeed(self.key)
- self.assert_(isinstance(feed, gdata.spreadsheet.SpreadsheetsCellsFeed))
+ self.assertTrue(isinstance(feed, gdata.spreadsheet.SpreadsheetsCellsFeed))
entry = self.gd_client.GetCellsFeed(self.key, cell='R5C1')
- self.assert_(isinstance(entry, gdata.spreadsheet.SpreadsheetsCell))
+ self.assertTrue(isinstance(entry, gdata.spreadsheet.SpreadsheetsCell))
def testGetListFeed(self):
feed = self.gd_client.GetListFeed(self.key)
- self.assert_(isinstance(feed, gdata.spreadsheet.SpreadsheetsListFeed))
+ self.assertTrue(isinstance(feed, gdata.spreadsheet.SpreadsheetsListFeed))
entry = self.gd_client.GetListFeed(self.key, row_id='cpzh4')
- self.assert_(isinstance(entry, gdata.spreadsheet.SpreadsheetsList))
+ self.assertTrue(isinstance(entry, gdata.spreadsheet.SpreadsheetsList))
def testUpdateCell(self):
self.gd_client.UpdateCell(row='5', col='1', inputValue='', key=self.key)
@@ -157,8 +157,8 @@
batch_feed.AddUpdate(edit_cell)
result = self.gd_client.ExecuteBatch(batch_feed,
url=cell_feed.GetBatchLink().href)
- self.assertEquals(len(result.entry), 1)
- self.assertEquals(result.entry[0].cell.inputValue, 'New Value')
+ self.assertEqual(len(result.entry), 1)
+ self.assertEqual(result.entry[0].cell.inputValue, 'New Value')
# Make a second batch request to change the cell's value back.
edit_cell = result.entry[0]
@@ -167,8 +167,8 @@
batch_feed.AddUpdate(edit_cell)
restored = self.gd_client.ExecuteBatch(batch_feed,
url=cell_feed.GetBatchLink().href)
- self.assertEquals(len(restored.entry), 1)
- self.assertEquals(restored.entry[0].cell.inputValue, old_cell_value)
+ self.assertEqual(len(restored.entry), 1)
+ self.assertEqual(restored.entry[0].cell.inputValue, old_cell_value)
def testInsertUpdateRow(self):
entry = self.gd_client.InsertRow({'a1':'new', 'b1':'row', 'c1':'was',
@@ -182,21 +182,21 @@
# Add a new worksheet.
new_worksheet = self.gd_client.AddWorksheet('worksheet_title_test_12', '2',
3, self.key)
- self.assertEquals(new_worksheet.col_count.text, '3')
- self.assertEquals(new_worksheet.row_count.text, '2')
- self.assertEquals(new_worksheet.title.text, 'worksheet_title_test_12')
+ self.assertEqual(new_worksheet.col_count.text, '3')
+ self.assertEqual(new_worksheet.row_count.text, '2')
+ self.assertEqual(new_worksheet.title.text, 'worksheet_title_test_12')
# Change the dimensions and title of the new worksheet.
new_worksheet.col_count.text = '1'
new_worksheet.title.text = 'edited worksheet test12'
edited_worksheet = self.gd_client.UpdateWorksheet(new_worksheet)
- self.assertEquals(edited_worksheet.col_count.text, '1')
- self.assertEquals(edited_worksheet.row_count.text, '2')
- self.assertEquals(edited_worksheet.title.text, 'edited worksheet test12')
+ self.assertEqual(edited_worksheet.col_count.text, '1')
+ self.assertEqual(edited_worksheet.row_count.text, '2')
+ self.assertEqual(edited_worksheet.title.text, 'edited worksheet test12')
# Delete the new worksheet.
result = self.gd_client.DeleteWorksheet(edited_worksheet)
- self.assertEquals(result, True)
+ self.assertEqual(result, True)
@@ -207,8 +207,8 @@
print ('These tests must be run on a sheet with this data:\n'
'a1,b1,c1,d1\n'
'1,2,3,4')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
- ss_key = raw_input('Please enter your spreadsheet key: ')
- ws_key = raw_input('Please enter your worksheet key (usually od6): ')
+ ss_key = input('Please enter youRefactoringTool: Refactored ./tests/gdata_tests/sites/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/sites/data_test.py
r spreadsheet key: ')
+ ws_key = input('Please enter your worksheet key (usually od6): ')
unittest.main()
--- ./tests/gdata_tests/sites/live_client_test.py (original)
+++ ./tests/gdata_tests/sites/live_client_test.py (refactored)
@@ -61,7 +61,7 @@
self.assertEqual(new_entry.title.text, 'Title Of Page')
self.assertEqual(new_entry.page_name.text, 'title-of-page')
- self.assert_(new_entry.GetAlternateLink().href is not None)
+ self.assertTrue(new_entry.GetAlternateLink().href is not None)
self.assertEqual(new_entry.Kind(), 'webpage')
# Change the title of the webpage we just added.
@@ -70,7 +70,7 @@
self.assertEqual(updated_entry.title.text, 'Edited')
self.assertEqual(updated_entry.page_name.text, 'title-of-page')
- self.assert_(isinstance(updated_entry, gdata.sites.data.ContentEntry))
+ self.assertTrue(isinstance(updated_entry, gdata.sites.data.ContentEntry))
# Delete the test webpage from the Site.
self.client.delete(updated_entry)
@@ -88,7 +88,7 @@
self.assertEqual(filecabinet.title.text, 'FilesGoHere')
self.assertEqual(filecabinet.page_name.text, 'diff-pagename-than-title')
- self.assert_(filecabinet.GetAlternateLink().href is not None)
+ self.assertTrue(filecabinet.GetAlternateLink().href is not None)
self.assertEqual(filecabinet.Kind(), 'filecabinet')
# Upload a file to the filecabinet
--- ./tests/gdata_tests/sites/data_test.py (original)
+++ ./tests/gdata_tests/sites/data_test.py (refactored)
@@ -39,7 +39,7 @@
def testToAndFromStringCommentEntry(self):
self.assertEqual(self.entry.Kind(), 'comment')
- self.assert_(isinstance(self.entry.in_reply_to, gdata.sites.data.InReplyTo))
+ self.assertTrue(isinstance(self.entry.in_reply_to, gdata.sites.data.InReplyTo))
self.assertEqual(self.entry.in_reply_to.type, 'text/html')
self.assertEqual(
self.entry.FindParentLink(),
@@ -62,7 +62,7 @@
gdata.sites.data.ContentEntry)
def testToAndFromStringWithData(self):
- self.assert_(isinstance(self.entry, gdata.sites.data.ContentEntry))
+ self.assertTrue(isinstance(self.entry, gdata.sites.data.ContentEntry))
self.assertEqual(self.entry.title.text, 'ListPagesTitle')
self.assertEqual(len(self.entry.author), 1)
self.assertEqual(self.entry.author[0].name.text, 'Test User')
@@ -71,15 +71,15 @@
self.assertEqual(self.entry.header.row, '1')
self.assertEqual(self.entry.data.startRow, '2')
self.assertEqual(len(self.entry.data.column), 5)
- self.assert_(isinstance(self.entry.data.column[0], gdata.sites.data.Column))
+ self.assertTrue(isinstance(self.entry.data.column[0], gdata.sites.data.Column))
self.assertEqual(self.entry.data.column[0].index, 'A')
self.assertEqual(self.entry.data.column[0].name, 'Owner')
- self.assert_(isinstance(self.entry.feed_link, gdata.data.FeedLink))
+ self.assertTrue(isinstance(self.entry.feed_link, gdata.data.FeedLink))
self.assertEqual(
self.entry.feed_link.href,
'http:///sites.google.com/feeds/content/site/gdatatestsite?parent=abc')
- self.assert_(isinstance(self.entry.content, gdata.sites.data.Content))
- self.assert_(isinstance(self.entry.content.html, atom.core.XmlElement))
+ self.assertTrue(isinstance(self.entry.content, gdata.sites.data.Content))
+ self.assertTrue(isinstance(self.entry.content.html, atom.core.XmlElement))
self.assertEqual(self.entry.content.type, 'xhtml')
@@ -90,9 +90,9 @@
gdata.sites.data.ContentEntry)
def testToAndFromStringWithData(self):
- self.assert_(isinstance(self.entry, gdata.sites.data.ContentEntry))
+ self.assertTrue(isinstance(self.entry, gdata.sites.data.ContentEntry))
self.assertEqual(len(self.entry.field), 5)
- self.assert_(isinstance(self.entry.field[0], gdata.sites.data.Field))
+ self.assertTrue(isinstance(self.entry.field[0], gdata.sites.data.Field))
self.assertEqual(self.entry.field[0].index, 'A')
self.assertEqual(self.entry.field[0].name, 'Owner')
self.assertEqual(self.entry.field[0].text, 'test value')
@@ -135,21 +135,21 @@
gdata.sites.data.ContentFeed)
def testToAndFromStringContentFeed(self):
- self.assert_(isinstance(self.feed, gdata.sites.data.ContentFeed))
+ self.assertTrue(isinstance(self.feed, gdata.sites.data.ContentFeed))
self.assertEqual(len(self.feed.entry), 8)
- self.assert_(isinstance(self.feed.entry[0].revision,
+ self.assertTrue(isinstance(self.feed.entry[0].revision,
gdata.sites.data.Revision))
self.assertEqual(int(self.feed.entry[0].revision.text), 2)
self.assertEqual(self.feed.entry[0].GetNodeId(), '1712987567114738703')
- self.assert_(isinstance(self.feed.entry[0].page_name,
+ self.assertTrue(isinstance(self.feed.entry[0].page_name,
gdata.sites.data.PageName))
self.assertEqual(self.feed.entry[0].page_name.text, 'home')
self.assertEqual(self.feed.entry[0].FindRevisionLink(),
'http:///sites.google.com/feeds/content/site/gdatatestsite/12345')
for entry in self.feed.entry:
- self.assert_(isinstance(entry, gdata.sites.data.ContentEntry))
+ self.assertTrue(isinstance(entry, gdata.sites.data.ContentEntry))
if entry.deleted is not None:
- self.assert_(isinstance(entry.deleted, gdata.sites.data.Deleted))
+ self.assertTrue(isinstance(entry.deleted, gdata.sites.data.Deleted))
self.assertEqual(entry.IsDeleted(), True)
else:
self.assertEqual(entry.IsDeleted(), False)
@@ -158,16 +158,16 @@
new_entry = gdata.sites.data.ContentEntry()
new_entry.content = gdata.sites.data.Content()
new_entry.content.html = '
'
- self.assert_(isinstance(new_entry, gdata.sites.data.ContentEntry))
- self.assert_(isinstance(new_entry.content, gdata.sites.data.Content))
- self.assert_(isinstance(new_entry.content.html, atom.core.XmlElement))
+ self.assertTrue(isinstance(new_entry, gdata.sites.data.ContentEntry))
+ self.assertTrue(isinstance(new_entry.content, gdata.sites.data.Content))
+ self.assertTrue(isinstance(new_entry.content.html, atom.core.XmlElement))
new_entry2 = gdata.sites.data.ContentEntry()
new_entry2.content = gdata.sites.data.Content(
html='')
- self.assert_(isinstance(new_entry2, gdata.sites.data.ContentEntry))
- self.assert_(isinstance(new_entry2.content, gdata.sites.data.Content))
- self.assert_(isinstance(new_entry2.content.html, atom.core.XmlElement))
+ self.assertTrue(isinstance(new_entry2, gdata.sites.data.ContentEntry))
+ self.assertTrue(isinstance(new_entry2.content, gdata.sites.data.Content))
+ self.assertTrue(isinstance(new_entry2.content.html, atom.core.XmlElement))
def testGetHelpers(self):
kinds = {'announcement': self.feed.GetAnnouncements,
@@ -179,7 +179,7 @@
'listpage': self.feed.GetListPages,
'webpage': self.feed.GetWebpages}
- for k, v in kinds.iteritems():
+ for k, v in kinds.items():
entries = v()
self.assertEqual(len(entries), 1)
for entry in entries:
@@ -196,12 +196,12 @@
gdata.sites.data.ActivityFeed)
def testToAndFromStringActivityFeed(self):
- self.assert_(isinstance(self.feed, gdata.sites.data.ActivityFeed))
+ self.assertTrue(isinstance(self.feed, gdata.sites.data.ActivityFeed))
self.assertEqual(len(self.feed.entry), 2)
for entry in self.feed.entry:
- self.assert_(isinstance(entry.summary, gdata.sites.data.Summary))
+ self.assertTrue(isinstance(entry.summary, gdata.sites.data.Summary))
self.assertEqual(entry.summary.type, 'xhtml')
- self.assert_(isinstance(entry.summary.html, atom.core.XmlElement))
+ self.assertTrue(isinstance(entry.summary.html, atom.core.XmlElement))
class RevisionFeedTest(unittest.TestCase):
@@ -211,11 +211,11 @@
gdata.sites.data.RevisionFeed)
def testToAndFromStringRevisionFeed(self):
- self.assert_(isinstance(self.feed, gdata.sites.data.RevRefactoringTool: Refactored ./tests/gdata_tests/service_test.py
isionFeed))
+ self.assertTrue(isinstance(self.feed, gdata.sites.data.RevisionFeed))
self.assertEqual(len(self.feed.entry), 1)
entry = self.feed.entry[0]
- self.assert_(isinstance(entry.content, gdata.sites.data.Content))
- self.assert_(isinstance(entry.content.html, atom.core.XmlElement))
+ self.assertTrue(isinstance(entry.content, gdata.sites.data.Content))
+ self.assertTrue(isinstance(entry.content.html, atom.core.XmlElement))
self.assertEqual(entry.content.type, 'xhtml')
self.assertEqual(
entry.FindParentLink(),
@@ -229,10 +229,10 @@
gdata.sites.data.SiteFeed)
def testToAndFromStringSiteFeed(self):
- self.assert_(isinstance(self.feed, gdata.sites.data.SiteFeed))
+ self.assertTrue(isinstance(self.feed, gdata.sites.data.SiteFeed))
self.assertEqual(len(self.feed.entry), 2)
entry = self.feed.entry[0]
- self.assert_(isinstance(entry.site_name, gdata.sites.data.SiteName))
+ self.assertTrue(isinstance(entry.site_name, gdata.sites.data.SiteName))
self.assertEqual(entry.title.text, 'New Test Site')
self.assertEqual(entry.site_name.text, 'new-test-site')
self.assertEqual(
@@ -251,14 +251,14 @@
gdata.sites.data.AclFeed)
def testToAndFromStringAclFeed(self):
- self.assert_(isinstance(self.feed, gdata.sites.data.AclFeed))
+ self.assertTrue(isinstance(self.feed, gdata.sites.data.AclFeed))
self.assertEqual(len(self.feed.entry), 1)
entry = self.feed.entry[0]
- self.assert_(isinstance(entry, gdata.sites.data.AclEntry))
- self.assert_(isinstance(entry.scope, gdata.acl.data.AclScope))
+ self.assertTrue(isinstance(entry, gdata.sites.data.AclEntry))
+ self.assertTrue(isinstance(entry.scope, gdata.acl.data.AclScope))
self.assertEqual(entry.scope.type, 'user')
self.assertEqual(entry.scope.value, 'user@example.com')
- self.assert_(isinstance(entry.role, gdata.acl.data.AclRole))
+ self.assertTrue(isinstance(entry.role, gdata.acl.data.AclRole))
self.assertEqual(entry.role.value, 'owner')
self.assertEqual(
entry.GetSelfLink().href,
--- ./tests/gdata_tests/service_test.py (original)
+++ ./tests/gdata_tests/service_test.py (refactored)
@@ -73,7 +73,7 @@
def testSourceGeneratesUserAgentHeader(self):
self.gd_client.source = 'GoogleInc-ServiceUnitTest-1'
- self.assert_(self.gd_client.additional_headers['User-Agent'].startswith(
+ self.assertTrue(self.gd_client.additional_headers['User-Agent'].startswith(
'GoogleInc-ServiceUnitTest-1 GData-Python'))
def testMedia1(self):
@@ -82,9 +82,9 @@
ms.setFile(test_image_location, 'image/jpeg')
media_entry = self.gd_client.Post(None,
self.album_entry.GetFeedLink().href, media_source = ms)
- self.assert_(media_entry is not None)
- self.assert_(isinstance(media_entry, gdata.GDataEntry))
- self.assert_(media_entry.IsMedia())
+ self.assertTrue(media_entry is not None)
+ self.assertTrue(isinstance(media_entry, gdata.GDataEntry))
+ self.assertTrue(media_entry.IsMedia())
# Update media & metadata
ms = gdata.MediaSource()
@@ -92,23 +92,23 @@
media_entry.summary = atom.Summary(text='Test Image')
media_entry2 = self.gd_client.Put(media_entry,
media_entry.GetEditLink().href, media_source = ms)
- self.assert_(media_entry2 is not None)
- self.assert_(isinstance(media_entry2, gdata.GDataEntry))
- self.assert_(media_entry2.IsMedia())
- self.assert_(media_entry2.summary.text == 'Test Image')
+ self.assertTrue(media_entry2 is not None)
+ self.assertTrue(isinstance(media_entry2, gdata.GDataEntry))
+ self.assertTrue(media_entry2.IsMedia())
+ self.assertTrue(media_entry2.summary.text == 'Test Image')
# Read media binary
imageSource = self.gd_client.GetMedia(media_entry2.GetMediaURL())
- self.assert_(isinstance(imageSource, gdata.MediaSource))
- self.assert_(imageSource.content_type == 'image/jpeg')
- self.assert_(imageSource.content_length)
+ self.assertTrue(isinstance(imageSource, gdata.MediaSource))
+ self.assertTrue(imageSource.content_type == 'image/jpeg')
+ self.assertTrue(imageSource.content_length)
imageData = imageSource.file_handle.read()
- self.assert_(imageData)
+ self.assertTrue(imageData)
# Delete entry
response = self.gd_client.Delete(media_entry2.GetEditLink().href)
- self.assert_(response)
+ self.assertTrue(response)
def testMedia2(self):
# Create media & metadata
@@ -122,43 +122,43 @@
'http://schemas.google.com/photos/2007#photo'))
media_entry = self.gd_client.Post(new_media_entry,
self.album_entry.GetFeedLink().href, media_source = ms)
- self.assert_(media_entry is not None)
- self.assert_(isinstance(media_entry, gdata.GDataEntry))
- self.assert_(media_entry.IsMedia())
- self.assert_(media_entry.summary.text == 'Test Image')
+ self.assertTrue(media_entry is not None)
+ self.assertTrue(isinstance(media_entry, gdata.GDataEntry))
+ self.assertTrue(media_entry.IsMedia())
+ self.assertTrue(media_entry.summary.text == 'Test Image')
# Update media only
ms = gdata.MediaSource()
ms.setFile(test_image_location, 'image/jpeg')
media_entry = self.gd_client.Put(None, media_entry.GetEditMediaLink().href,
media_source = ms)
- self.assert_(media_entry is not None)
- self.assert_(isinstance(media_entry, gdata.GDataEntry))
- self.assert_(media_entry.IsMedia())
+ self.assertTrue(media_entry is not None)
+ self.assertTrue(isinstance(media_entry, gdata.GDataEntry))
+ self.assertTrue(media_entry.IsMedia())
# Delete entry
response = self.gd_client.Delete(media_entry.GetEditLink().href)
- self.assert_(response)
+ self.assertTrue(response)
def testMediaConstructorDefaults(self):
ms = gdata.MediaSource()
ms.setFile(test_image_location, 'image/jpeg')
- self.assert_(ms is not None)
- self.assert_(isinstance(ms, gdata.MediaSource))
- self.assertEquals(ms.file_name, test_image_name)
- self.assertEquals(ms.content_type, 'image/jpeg')
+ self.assertTrue(ms is not None)
+ self.assertTrue(isinstance(ms, gdata.MediaSource))
+ self.assertEqual(ms.file_name, test_image_name)
+ self.assertEqual(ms.content_type, 'image/jpeg')
def testMediaConstructorWithFilePath(self):
ms = gdata.MediaSource(file_path=test_image_location,
content_type='image/jpeg')
- self.assert_(ms is not None)
- self.assert_(isinstance(ms, gdata.MediaSource))
- self.assertEquals(ms.file_name, test_image_name)
- self.assertEquals(ms.content_type, 'image/jpeg')
+ self.assertTrue(ms is not None)
+ self.assertTrue(isinstance(ms, gdata.MediaSource))
+ self.assertEqual(ms.file_name, test_image_name)
+ self.assertEqual(ms.content_type, 'image/jpeg')
def testMediaConstructorWithFileHandle(self):
@@ -166,10 +166,10 @@
len = os.path.getsize(test_image_location)
ms = gdata.MediaSource(fh, 'image/jpeg', len, file_name=test_image_location)
- self.assert_(ms is not None)
- self.assert_(isinstance(ms, gdata.MediaSource))
- self.assertEquals(ms.file_name, test_image_location)
- self.assertEquals(ms.content_type, 'image/jpeg')
+ self.assertTrue(ms is not None)
+ self.assertTrue(isinstance(ms, gdata.MediaSource))
+ self.assertEqual(ms.file_name, test_image_location)
+ self.assertEqual(ms.content_type, 'image/jpeg')
class GDataServiceUnitTest(unittest.TestCase):
@@ -186,24 +186,24 @@
password_string = 'Passwd'
self.gd_client.email = email_string
- self.assertEquals(self.gd_client.email, email_string)
+ self.assertEqual(self.gd_client.email, email_string)
self.gd_client.password = password_string
- self.assertEquals(self.gd_client.password, password_string)
+ self.assertEqual(self.gd_client.password, password_string)
def testCorrectLogin(self):
try:
self.gd_client.ProgrammaticLogin()
- self.assert_(isinstance(
+ self.assertTrue(isinstance(
self.gd_client.token_store.find_token(
'http://base.google.com/base/feeds/'),
gdata.auth.ClientLoginToken))
- self.assert_(self.gd_client.captcha_token is None)
- self.assert_(self.gd_client.captcha_url is None)
+ self.assertTrue(self.gd_client.captcha_token is None)
+ self.assertTrue(self.gd_client.captcha_url is None)
except gdata.service.CaptchaRequired:
self.fail('Required Captcha')
def testDefaultHttpClient(self):
- self.assert_(isinstance(self.gd_client.http_client,
+ self.assertTrue(isinstance(self.gd_client.http_client,
atom.http.HttpClient))
@@ -223,8 +223,8 @@
'VKlVrNhQ'}
self.gd_client.server = 'base.google.com'
result = self.gd_client.Get('/base/feeds/snippets?bq=digital+camera')
- self.assert_(result is not None)
- self.assert_(isinstance(result, atom.Feed))
+ self.assertTrue(result is not None)
+ self.assertTrue(isinstance(result, atom.Feed))
def testGetWithAuthentication(self):
try:
@@ -242,8 +242,8 @@
'VKlVrNhQ'}
self.gd_client.server = 'base.google.com'
result = self.gd_client.Get('/base/feeds/items?bq=digital+camera')
- self.assert_(result is not None)
- self.assert_(isinstance(result, atom.Feed))
+ self.assertTrue(result is not None)
+ self.assertTrue(isinstance(result, atom.Feed))
def testGetEntry(self):
try:
@@ -273,15 +273,15 @@
self.fail('Login Error')
self.gd_client.server = 'base.google.com'
result = self.gd_client.GetFeed('/base/feeds/items?bq=digital+camera')
- self.assert_(result is not None)
- self.assert_(isinstance(result, atom.Feed))
+ self.assertTrue(result is not None)
+ self.assertTrue(isinstance(result, atom.Feed))
def testGetWithResponseTransformer(self):
# Query Google Base and interpret the results as a GBaseSnippetFeed.
feed = self.gd_client.Get(
'http://www.google.com/base/feeds/snippets?bq=digital+camera',
converter=gdata.base.GBaseSnippetFeedFromString)
- self.assertEquals(isinstance(feed, gdata.base.GBaseSnippetFeed), True)
+ self.assertEqual(isinstance(feed, gdata.base.GBaseSnippetFeed), True)
def testPostPutAndDelete(self):
try:
@@ -302,14 +302,14 @@
# Insert a new item
response = self.gd_client.Post(test_data.TEST_BASE_ENTRY,
'/base/feeds/items')
- self.assert_(response is not None)
- self.assert_(isinstance(response, atom.Entry))
- self.assert_(response.category[0].term == 'products')
+ self.assertTrue(response is not None)
+ self.assertTrue(isinstance(response, atom.Entry))
+ self.assertTrue(response.category[0].term == 'products')
# Find the item id of the created item
item_id = response.id.text.lstrip(
'http://www.google.com/base/feeds/items/')
- self.assert_(item_id is not None)
+ self.assertTrue(item_id is not None)
updated_xml = gdata.base.GBaseItemFromString(test_data.TEST_BASE_ENTRY)
# Change one of the labels in the item
@@ -317,13 +317,13 @@
# Update the item
response = self.gd_client.Put(updated_xml,
'/base/feeds/items/%s' % item_id)
- self.assert_(response is not None)
+ self.assertTrue(response is not None)
new_base_item = gdata.base.GBaseItemFromString(str(response))
- self.assert_(isinstance(new_base_item, atom.Entry))
+ self.assertTrue(isinstance(new_base_item, atom.Entry))
# Delete the item the test just created.
response = self.gd_client.Delete('/base/feeds/items/%s' % item_id)
- self.assert_(response)
+ self.assertTrue(response)
def testPostPutAndDeleteWithConverters(self):
try:
@@ -344,10 +344,10 @@
# Insert a new item
response = self.gd_client.Post(test_data.TEST_BASE_ENTRY,
'/base/feeds/items', converter=gdata.base.GBaseItemFromString)
- self.assert_(response is not None)
- self.assert_(isinstance(response, atom.Entry))
- self.assert_(isinstance(response, gdata.base.GBaseItem))
- self.assert_(response.category[0].term == 'products')
+ self.assertTrue(response is not None)
+ self.assertTrue(isinstance(response, atom.Entry))
+ self.assertTrue(isinstance(response, gdata.base.GBaseItem))
+ self.assertTrue(response.category[0].term == 'products')
updated_xml = gdata.base.GBaseItemFromString(test_data.TEST_BASE_ENTRY)
# Change one of the labels in the item
@@ -356,12 +356,12 @@
response = self.gd_client.Put(updated_xml,
response.id.text,
converter=gdata.base.GBaseItemFromString)
- self.assertEquals(response is not None, True)
- self.assertEquals(isinstance(response, gdata.base.GBaseItem), True)
+ self.assertEqual(response is not None, True)
+ self.assertEqual(isinstance(response, gdata.base.GBaseItem), True)
# Delete the item the test just created.
response = self.gd_client.Delete(response.id.text)
- self.assert_(response)
+ self.assertTrue(response)
def testCaptchaUrlGeneration(self):
# Populate the mock server with a pairing for a ClientLogin request to a
@@ -383,8 +383,8 @@
try:
self.gd_client.ProgrammaticLogin()
self.fail('Login attempt should have caused a CAPTCHA challenge.')
- except gdata.service.CaptchaRequired, error:
- self.assertEquals(self.gd_client.captcha_url,
+ except gdata.service.CaptchaRequired as error:
+ self.assertEqual(self.gd_client.captcha_url,
('https://www.google.com/accounts/Captcha?ctoken=HiteT4b0Bk5Xg18_'
'AcVoP6-yFkHPibe7O9EqxeiI7lUSN'))
@@ -398,7 +398,7 @@
atom.mock_http_core.SettableHttpClient(200, 'OK', '', {}))
def testDeleteWithUrlParams(self):
- self.assert_(self.gd_client.Delete('http://example.com/test',
+ self.assertTrue(self.gd_client.Delete('http://example.com/test',
{'TestHeader': '123'}, {'urlParam1': 'a', 'urlParam2': 'test'}))
request = self.gd_client.http_client.v2_http_client.last_request
self.assertEqual(request.uri.host, 'example.com')
@@ -408,7 +408,7 @@
def testDeleteWithSessionId(self):
self.gd_client._SetSessionId('test_session_id')
- self.assert_(self.gd_client.Delete('http://example.com/test',
+ self.assertTrue(self.gd_client.Delete('http://example.com/test',
{'TestHeader': '123'}, {'urlParam1': 'a', 'urlParam2': 'test'}))
request = self.gd_client.http_client.v2_http_client.last_request
self.assertEqual(request.uri.host, 'example.com')
@@ -429,61 +429,61 @@
except KeyError:
pass
self.query['zap'] = 'x'
- self.assert_(self.query['zap'] == 'x')
+ self.assertTrue(self.query['zap'] == 'x')
def testContructorShouldRejectBadInputs(self):
test_q = gdata.service.Query(params=[1,2,3,4])
- self.assert_(len(test_q.keys()) == 0)
+ self.assertTrue(len(list(test_q.keys())) == 0)
def testTextQueryProperty(self):
- self.assert_(self.query.text_query is None)
+ self.assertTrue(self.query.text_query is None)
self.query['q'] = 'test1'
- self.assert_(self.query.text_query == 'test1')
+ self.assertTrue(self.query.text_query == 'test1')
self.query.text_query = 'test2'
- self.assert_(self.query.text_query == 'test2')
+ self.assertTrue(self.query.text_query == 'test2')
def testOrderByQueryProperty(self):
- self.assert_(self.query.orderby is None)
+ self.assertTrue(self.query.orderby is None)
self.query['orderby'] = 'updated'
- self.assert_(self.query.orderby == 'updated')
+ self.assertTrue(self.query.orderby == 'updated')
self.query.orderby = 'starttime'
- self.assert_(self.query.orderby == 'starttime')
+ self.assertTrue(self.query.orderby == 'starttime')
def testQueryShouldProduceExampleUris(self):
self.query.feed = '/base/feeds/snippets'
self.query.text_query = 'This is a test'
- self.assert_(self.query.ToUri() == '/base/feeds/snippets?q=This+is+a+test')
+ self.assertTrue(self.query.ToUri() == '/base/feeds/snippets?q=This+is+a+test')
def testCategoriesFormattedCorrectly(self):
self.query.feed = '/x'
self.query.categories.append('Fritz')
self.query.categories.append('Laurie')
- self.assert_(self.query.ToUri() == '/x/-/Fritz/Laurie')
+ self.assertTrue(self.query.ToUri() == '/x/-/Fritz/Laurie')
# The query's feed should not have been changed
- self.assert_(self.query.feed == '/x')
- self.assert_(self.query.ToUri() == '/x/-/Fritz/Laurie')
+ self.assertTrue(self.query.feed == '/x')
+ self.assertTrue(self.query.ToUri() == '/x/-/Fritz/Laurie')
def testCategoryQueriesShouldEscapeOrSymbols(self):
self.query.feed = '/x'
self.query.categories.append('Fritz|Laurie')
- self.assert_(self.query.ToUri() == '/x/-/Fritz%7CLaurie')
+ self.assertTrue(self.query.ToUri() == '/x/-/Fritz%7CLaurie')
def testTypeCoercionOnIntParams(self):
self.query.feed = '/x'
self.query.max_results = 10
self.query.start_index = 5
- self.assert_(isinstance(self.query.max_results, str))
- self.assert_(isinstance(self.query.start_index, str))
- self.assertEquals(self.query['max-results'], '10')
- self.assertEquals(self.query['start-index'], '5')
+ self.assertTrue(isinstance(self.query.max_results, str))
+ self.assertTrue(isinstance(self.query.start_index, str))
+ self.assertEqual(self.query['max-results'], '10')
+ self.assertEqual(self.query['start-index'], '5')
def testPassInCategoryListToConstructor(self):
query = gdata.service.Query(feed='/feed/sample', categories=['foo', 'bar',
'eggs|spam'])
url = query.ToUri()
- self.assert_(url.find('/foo') > -1)
- self.assert_(url.find('/bar') > -1)
- self.assert_(url.find('/eggs%7Cspam') > -1)
+ self.assertTrue(url.find('/foo') > -1)
+ self.assertTrue(url.find('/bar') > -1)
+ self.assertTrue(url.find('/eggs%7Cspam') > -1)
class GetNextPageInFeedTest(unittest.TestCase):
@@ -495,24 +495,24 @@
feed = self.gd_client.Get(
'http://www.google.com/base/feeds/snippets?max-results=2',
converter=gdata.base.GBaseSnippetFeedFromString)
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(len(feed.entry) > 0)
first_id = feed.entry[0].id.text
feed2 = self.gd_client.GetNext(feed)
- self.assert_(len(feed2.entry) > 0)
+ self.assertTrue(len(feed2.entry) > 0)
next_id = feed2.entry[0].id.text
- self.assert_(first_id != next_id)
- self.assert_(feed2.__class__ == feed.__class__)
+ self.assertTrue(first_id != next_id)
+ self.assertTrue(feed2.__class__ == feed.__class__)
class ScopeLookupTest(unittest.TestCase):
def testLookupScopes(self):
scopes = gdata.service.lookup_scopes('cl')
- self.assertEquals(scopes, gdata.service.CLIENT_LOGIN_SCOPES['cl'])
+ self.assertEqual(scopes, gdata.service.CLIENT_LOGIN_SCOPES['cl'])
scopes = gdata.service.lookup_scopes(None)
- self.assert_(scopes is None)
+ self.assertTrue(scopes is None)
scopes = gdata.service.lookup_scopes('UNKNOWN_SERVICE')
- self.assert_(scopes is None)
+ self.assertTrue(scopes is None)
class TokenLookupTest(unittest.TestCase):
@@ -521,36 +521,36 @@
self.client = gdata.service.GDataService()
def testSetAndGetClientLoginTokenWithNoService(self):
- self.assert_(self.client.auth_token is None)
+ self.assertTrue(self.client.auth_token is None)
self.client.SetClientLoginToken('foo')
- self.assert_(self.client.auth_token is None)
- self.assert_(self.client.token_store.find_token(
+ self.assertTrue(self.client.auth_token is None)
+ self.assertTrue(self.client.token_store.find_token(
atom.token_store.SCOPE_ALL) is not None)
- self.assertEquals(self.client.GetClientLoginToken(), 'foo')
+ self.assertEqual(self.client.GetClientLoginToken(), 'foo')
self.client.SetClientLoginToken('foo2')
- self.assertEquals(self.client.GetClientLoginToken(), 'foo2')
+ self.assertEqual(self.client.GetClientLoginToken(), 'foo2')
def testSetAndGetClientLoginTokenWithService(self):
self.client.service = 'cp'
self.client.SetClientLoginToken('bar')
- self.assertEquRefactoringTool: Refactored ./tests/gdata_tests/sample_util_test.py
RefactoringTool: Refactored ./tests/gdata_tests/resumable_upload_test.py
als(self.client.GetClientLoginToken(), 'bar')
+ self.assertEqual(self.client.GetClientLoginToken(), 'bar')
# Changing the service should cause the token to no longer be found.
self.client.service = 'gbase'
self.client.current_token = None
- self.assert_(self.client.GetClientLoginToken() is None)
+ self.assertTrue(self.client.GetClientLoginToken() is None)
def testSetAndGetClientLoginTokenWithScopes(self):
scopes = gdata.service.CLIENT_LOGIN_SCOPES['cl'][:]
scopes.extend(gdata.service.CLIENT_LOGIN_SCOPES['gbase'])
self.client.SetClientLoginToken('baz', scopes=scopes)
self.client.current_token = None
- self.assert_(self.client.GetClientLoginToken() is None)
+ self.assertTrue(self.client.GetClientLoginToken() is None)
self.client.service = 'cl'
- self.assertEquals(self.client.GetClientLoginToken(), 'baz')
+ self.assertEqual(self.client.GetClientLoginToken(), 'baz')
self.client.service = 'gbase'
- self.assertEquals(self.client.GetClientLoginToken(), 'baz')
+ self.assertEqual(self.client.GetClientLoginToken(), 'baz')
self.client.service = 'wise'
- self.assert_(self.client.GetClientLoginToken() is None)
+ self.assertTrue(self.client.GetClientLoginToken() is None)
def testLookupUsingTokenStore(self):
scopes = gdata.service.CLIENT_LOGIN_SCOPES['cl'][:]
@@ -558,20 +558,20 @@
self.client.SetClientLoginToken('baz', scopes=scopes)
token = self.client.token_store.find_token(
'http://www.google.com/calendar/feeds/foo')
- self.assertEquals(token.get_token_string(), 'baz')
- self.assertEquals(token.auth_header, '%s%s' % (
+ self.assertEqual(token.get_token_string(), 'baz')
+ self.assertEqual(token.auth_header, '%s%s' % (
gdata.auth.PROGRAMMATIC_AUTH_LABEL, 'baz'))
token = self.client.token_store.find_token(
'http://www.google.com/calendar/')
- self.assert_(isinstance(token, gdata.auth.ClientLoginToken) == False)
+ self.assertTrue(isinstance(token, gdata.auth.ClientLoginToken) == False)
token = self.client.token_store.find_token(
'http://www.google.com/base/feeds/snippets')
- self.assertEquals(token.get_token_string(), 'baz')
+ self.assertEqual(token.get_token_string(), 'baz')
if __name__ == '__main__':
print ('GData Service Media Unit Tests\nNOTE: Please run these tests only '
'with a test account. The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/sample_util_test.py (original)
+++ ./tests/gdata_tests/sample_util_test.py (refactored)
@@ -32,18 +32,18 @@
self.settings = gdata.sample_util.SettingsUtil()
def test_get_param(self):
- self.assert_(self.settings.get_param('missing', ask=False) is None)
+ self.assertTrue(self.settings.get_param('missing', ask=False) is None)
self.settings.prefs['x'] = 'something'
self.assertEqual(self.settings.get_param('x'), 'something')
def test_get_param_from_command_line_arg(self):
- self.assert_('x' not in self.settings.prefs)
- self.assert_(self.settings.get_param('x', ask=False) is None)
+ self.assertTrue('x' not in self.settings.prefs)
+ self.assertTrue(self.settings.get_param('x', ask=False) is None)
sys.argv.append('--x=something')
self.assertEqual(self.settings.get_param('x'), 'something')
- self.assert_('x' not in self.settings.prefs)
- self.assert_('y' not in self.settings.prefs)
- self.assert_(self.settings.get_param('y', ask=False) is None)
+ self.assertTrue('x' not in self.settings.prefs)
+ self.assertTrue('y' not in self.settings.prefs)
+ self.assertTrue(self.settings.get_param('y', ask=False) is None)
sys.argv.append('--y')
sys.argv.append('other')
self.assertEqual(self.settings.get_param('y', reuse=True), 'other')
--- ./tests/gdata_tests/resumable_upload_test.py (original)
+++ ./tests/gdata_tests/resumable_upload_test.py (refactored)
@@ -8RefactoringTool: Refactored ./tests/gdata_tests/projecthosting/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/projecthosting/data_test.py
7,7 +87,7 @@
# Verify upload has really completed.
self.assertEqual(uploader.QueryUploadStatus(), True)
- self.assert_(isinstance(entry, gdata.docs.data.DocsEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.data.DocsEntry))
self.assertEqual(entry.title.text, 'MyResumableTitleEntireFile')
self.assertEqual(entry.GetDocumentType(), 'document')
self.assertEqual(entry.writers_can_invite.value, 'false')
@@ -120,7 +120,7 @@
# Verify upload has really completed.
self.assertEqual(uploader.QueryUploadStatus(), True)
- self.assert_(isinstance(entry, gdata.docs.data.DocsEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.data.DocsEntry))
self.assertEqual(entry.title.text, 'MyManualChunksNoAtomTitle')
self.assertEqual(entry.GetDocumentType(), 'document')
self.client.Delete(entry, force=True)
--- ./tests/gdata_tests/projecthosting/live_client_test.py (original)
+++ ./tests/gdata_tests/projecthosting/live_client_test.py (refactored)
@@ -99,14 +99,14 @@
self.assertEqual(updates.status.text, 'Accepted')
# Make sure it got all our label change requests.
- self.assertEquals(len(updates.label), 2)
- self.assertEquals(updates.label[0].text, '-label0')
- self.assertEquals(updates.label[1].text, 'label1')
+ self.assertEqual(len(updates.label), 2)
+ self.assertEqual(updates.label[0].text, '-label0')
+ self.assertEqual(updates.label[1].text, 'label1')
# Be sure it saw our CC change. We can't check the specific values (yet)
# because ccUpdate and ownerUpdate responses are mungled.
- self.assertEquals(len(updates.ccUpdate), 1)
- self.assert_(updates.ownerUpdate.text)
+ self.assertEqual(len(updates.ccUpdate), 1)
+ self.assertTrue(updates.ownerUpdate.text)
def test_get_issues(self):
if not conf.options.get_value('runlive') == 'true':
@@ -126,11 +126,11 @@
feed = self.client.get_issues(self.project_name, query=query)
# Make sure we at least find the entry we created with that label.
- self.assert_(len(feed.entry) > 0)
+ self.assertTrue(len(feed.entry) > 0)
for issue in feed.entry:
label_texts = [label.text for label in issue.label]
- self.assert_('label0' in label_texts, 'Issue does not have label label0')
+ self.assertTrue('label0' in label_texts, 'Issue does not have label label0')
def test_get_comments(self):
if not conf.options.get_value('runlive') == 'true':
@@ -212,14 +212,14 @@
"""Retrieve all the issues in a project."""
feed = client.get_issues(project_name)
for issue in feed.entry:
- self.assert_(issue.title.text is not None)
+ self.assertTrue(issue.title.text is not None)
def retrieving_issues_using_query_parameters(self, client, project_name):
"""Retrieve a set of issues in a project."""
query = gdata.projecthosting.client.Query(label='label0', max_results=1000)
feed = client.get_issues(project_name, query=query)
for issue in feed.entry:
- self.assert_(issue.title.text is not None)
+ self.assertTrue(issue.title.text is not None)
return feed
def retrieving_issues_comments_for_an_issue(self, client, project_name,
@@ -227,7 +227,7 @@
"""Retrieve all issue comments for an issue."""
comments_feed = client.get_comments(project_name, issue_id)
for comment in comments_feed.entry:
- self.assert_(comment.content is not None)
+ self.assertTrue(comment.content is not None)
return comments_feed
def modifying_an_issue_or_creating_issue_comments(self, client, project_name,
--- ./tests/gdata_tests/projecthosting/data_test.py (original)
+++ ./tests/gdata_tests/projecthosting/data_test.py (refactored)
@@ -111,20 +111,20 @@
updates = entry.updates
- self.assertEquals(updates.summary.text, 'This is updated issue summary')
- self.assertEquals(updates.status.text, 'Started')
- self.assertEquals(updates.ownerUpdate.text, 'charlotte.lucas')
+ self.assertEqual(updates.summary.text, 'This is updated issue summary')
+ self.assertEqual(updates.status.texRefactoringTool: Refactored ./tests/gdata_tests/photos_test.py
t, 'Started')
+ self.assertEqual(updates.ownerUpdate.text, 'charlotte.lucas')
- self.assertEquals(len(updates.label), 5)
- self.assertEquals(updates.label[0].text, '-Type-Defect')
- self.assertEquals(updates.label[1].text, 'Type-Enhancement')
- self.assertEquals(updates.label[2].text, '-Milestone-2009')
- self.assertEquals(updates.label[3].text, '-Priority-Medium')
- self.assertEquals(updates.label[4].text, 'Priority-Low')
+ self.assertEqual(len(updates.label), 5)
+ self.assertEqual(updates.label[0].text, '-Type-Defect')
+ self.assertEqual(updates.label[1].text, 'Type-Enhancement')
+ self.assertEqual(updates.label[2].text, '-Milestone-2009')
+ self.assertEqual(updates.label[3].text, '-Priority-Medium')
+ self.assertEqual(updates.label[4].text, 'Priority-Low')
- self.assertEquals(len(updates.ccUpdate), 2)
- self.assertEquals(updates.ccUpdate[0].text, '-fitzwilliam.darcy')
- self.assertEquals(updates.ccUpdate[1].text, 'marialucas@domain.com')
+ self.assertEqual(len(updates.ccUpdate), 2)
+ self.assertEqual(updates.ccUpdate[0].text, '-fitzwilliam.darcy')
+ self.assertEqual(updates.ccUpdate[1].text, 'marialucas@domain.com')
class IssueEntryTest(unittest.TestCase):
@@ -132,24 +132,24 @@
def testParsing(self):
entry = atom.core.parse(ISSUE_ENTRY, gdata.projecthosting.data.IssueEntry)
- self.assertEquals(entry.owner.uri.text, '/u/charlotte.lucas/')
+ self.assertEqual(entry.owner.uri.text, '/u/charlotte.lucas/')
self.assertEqual(entry.owner.username.text, 'charlotte.lucas')
- self.assertEquals(len(entry.cc), 2)
+ self.assertEqual(len(entry.cc), 2)
cc_0 = entry.cc[0]
- self.assertEquals(cc_0.uri.text, '/u/@UBhTQl1UARRAVga7/')
- self.assertEquals(cc_0.username.text, 'mar...@domain.com')
+ self.assertEqual(cc_0.uri.text, '/u/@UBhTQl1UARRAVga7/')
+ self.assertEqual(cc_0.username.text, 'mar...@domain.com')
cc_1 = entry.cc[1]
- self.assertEquals(cc_1.uri.text, '/u/fitzwilliam.darcy/')
- self.assertEquals(cc_1.username.text, 'fitzwilliam.darcy')
+ self.assertEqual(cc_1.uri.text, '/u/fitzwilliam.darcy/')
+ self.assertEqual(cc_1.username.text, 'fitzwilliam.darcy')
- self.assertEquals(len(entry.label), 2)
- self.assertEquals(entry.label[0].text, 'Type-Enhancement')
- self.assertEquals(entry.label[1].text, 'Priority-Low')
+ self.assertEqual(len(entry.label), 2)
+ self.assertEqual(entry.label[0].text, 'Type-Enhancement')
+ self.assertEqual(entry.label[1].text, 'Priority-Low')
- self.assertEquals(entry.stars.text, '0')
- self.assertEquals(entry.state.text, 'open')
- self.assertEquals(entry.status.text, 'Started')
+ self.assertEqual(entry.stars.text, '0')
+ self.assertEqual(entry.state.text, 'open')
+ self.assertEqual(entry.status.text, 'Started')
class DataClassSanityTest(unittest.TestCase):
--- ./tests/gdata_tests/photos_test.py (original)
+++ ./tests/gdata_tests/photos_test.py (refactored)
@@ -29,12 +29,12 @@
self.album_feed = gdata.photos.AlbumFeedFromString(test_data.ALBUM_FEED)
def testCorrectXmlParsing(self):
- self.assert_(self.album_feed.id.text == 'http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1')
- self.assert_(self.album_feed.gphoto_id.text == '1')
- self.assert_(len(self.album_feed.entry) == 4)
+ self.assertTrue(self.album_feed.id.text == 'http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1')
+ self.assertTrue(self.album_feed.gphoto_id.text == '1')
+ self.assertTrue(len(self.album_feed.entry) == 4)
for entry in self.album_feed.entry:
if entry.id.text == 'http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2':
- self.assert_(entry.summary.text == 'Blue')
+ self.assertTrue(entry.summary.text == 'Blue')
class PhotoFeedTest(unittest.TestCase):
@@ -45,12 +45,12 @@
def testCorrectXmlParsing(self):
for entry in self.feed.entry:
if entry.id.text == 'http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1/photoid/2':
- RefactoringTool: Refactored ./tests/gdata_tests/photos/service_test.py
RefactoringTool: Refactored ./tests/gdata_tests/oauth/data_test.py
RefactoringTool: No changes to ./tests/gdata_tests/marketplace/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/live_client_test.py
self.assert_(entry.gphoto_id.text == '2')
- self.assert_(entry.albumid.text == '1')
- self.assert_(entry.exif.flash.text == 'true')
- self.assert_(entry.media.title.type == 'plain')
- self.assert_(entry.media.title.text == 'Aqua Blue.jpg')
- self.assert_(len(entry.media.thumbnail) == 3)
+ self.assertTrue(entry.gphoto_id.text == '2')
+ self.assertTrue(entry.albumid.text == '1')
+ self.assertTrue(entry.exif.flash.text == 'true')
+ self.assertTrue(entry.media.title.type == 'plain')
+ self.assertTrue(entry.media.title.text == 'Aqua Blue.jpg')
+ self.assertTrue(len(entry.media.thumbnail) == 3)
@@ -62,7 +62,7 @@
def testEntryTypeConversion(self):
for entry in self.feed.entry:
if entry.id.text == 'http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/':
- self.assert_(isinstance(entry, gdata.photos.PhotoEntry))
+ self.assertTrue(isinstance(entry, gdata.photos.PhotoEntry))
if __name__ == '__main__':
--- ./tests/gdata_tests/photos/service_test.py (original)
+++ ./tests/gdata_tests/photos/service_test.py (refactored)
@@ -19,7 +19,7 @@
import getpass
import time
import unittest
-import StringIO
+import io
import gdata.photos.service
import gdata.photos
import atom
@@ -49,9 +49,9 @@
def testUploadGetAndDeletePhoto(self):
image_entry = self.client.InsertPhotoSimple(self.test_album,
'test', 'a pretty testing picture', test_image_location)
- self.assert_(image_entry.title.text == 'test')
+ self.assertTrue(image_entry.title.text == 'test')
results_feed = self.client.SearchUserPhotos('test')
- self.assert_(len(results_feed.entry) > 0)
+ self.assertTrue(len(results_feed.entry) > 0)
self.client.Delete(image_entry)
def testInsertPhotoUpdateBlobAndDelete(self):
@@ -63,9 +63,9 @@
term='http://schemas.google.com/photos/2007#photo'))
entry = self.client.InsertPhoto(self.test_album, new_entry,
test_image_location, content_type='image/jpeg')
- self.assert_(entry.id.text)
+ self.assertTrue(entry.id.text)
updated_entry = self.client.UpdatePhotoBlob(entry, test_image_location)
- self.assert_(entry.GetEditLink().href != updated_entry.GetEditLink().href)
+ self.assertTrue(entry.GetEditLink().href != updated_entry.GetEditLink().href)
self.client.Delete(updated_entry)
def tearDown(self):
@@ -77,6 +77,6 @@
if __name__ == '__main__':
print ('Google Photos test\nNOTE: Please run these tests only with a test '
'account. The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/oauth/data_test.py (original)
+++ ./tests/gdata_tests/oauth/data_test.py (refactored)
@@ -170,8 +170,8 @@
def test_get_nonoauth_parameters(self):
non_oauth_params = self.oauth_request.get_nonoauth_parameters()
- self.assertTrue(non_oauth_params.has_key(self.non_oauth_param_message))
- self.assertFalse(non_oauth_params.has_key(OAuthParameters.CONSUMER_KEY))
+ self.assertTrue(self.non_oauth_param_message in non_oauth_params)
+ self.assertFalse(OAuthParameters.CONSUMER_KEY in non_oauth_params)
def test_to_header(self):
realm = 'google'
@@ -185,7 +185,7 @@
self.assertTrue(header_with_realm.find(k) > -1)
def check_for_params_in_string(self, params, s):
- for k, v in params.iteritems():
+ for k, v in params.items():
self.assertTrue(s.find(oauth.escape(k)) > -1)
self.assertTrue(s.find(oauth.escape(v)) > -1)
@@ -209,7 +209,7 @@
key_values = [tuple(kv.split('=')) for kv in normalized_params.split('&')]
del _params[OAuthParameters.SIGNATURE]
- expected_key_values = _params.items()
+ expected_key_values = list(_params.items())
expected_key_values.sort()
for k, v in expected_key_values:
--- ./tests/gdata_tests/live_client_test.py (original)
+++ ./tests/gdata_tesRefactoringTool: Refactored ./tests/gdata_tests/health_test.py
ts/live_client_test.py (refactored)
@@ -62,8 +62,8 @@
http_request.add_body_part(str(blog_post), 'application/atom+xml')
def entry_from_string_wrapper(response):
- self.assert_(response.getheader('content-type') is not None)
- self.assert_(response.getheader('gdata-version') is not None)
+ self.assertTrue(response.getheader('content-type') is not None)
+ self.assertTrue(response.getheader('gdata-version') is not None)
return atom.EntryFromString(response.read())
entry = self.client.request('POST',
@@ -137,8 +137,8 @@
found_tags[0] = True
elif category.get_attributes('term')[0].value == 'Mr. Darcy':
found_tags[1] = True
- self.assert_(found_tags[0])
- self.assert_(found_tags[1])
+ self.assertTrue(found_tags[0])
+ self.assertTrue(found_tags[1])
# Find the blog post on the blog.
self_link = None
@@ -148,8 +148,8 @@
self_link = link.get_attributes('href')[0].value
elif link.get_attributes('rel')[0].value == 'edit':
edit_link = link.get_attributes('href')[0].value
- self.assert_(self_link is not None)
- self.assert_(edit_link is not None)
+ self.assertTrue(self_link is not None)
+ self.assertTrue(edit_link is not None)
queried = self.client.request('GET', self_link,
converter=element_from_string)
@@ -157,7 +157,7 @@
# Test queries using ETags.
entry = self.client.get_entry(self_link)
- self.assert_(entry.etag is not None)
+ self.assertTrue(entry.etag is not None)
self.assertRaises(gdata.client.NotModified, self.client.get_entry,
self_link, etag=entry.etag)
@@ -205,12 +205,12 @@
self_link = link.get_attributes('href')[0].value
elif link.get_attributes('rel')[0].value == 'edit':
edit_link = link.get_attributes('href')[0].value
- self.assert_(self_link is not None)
- self.assert_(edit_link is not None)
+ self.assertTrue(self_link is not None)
+ self.assertTrue(edit_link is not None)
etag = posted.get_attributes('etag')[0].value
- self.assert_(etag is not None)
- self.assert_(len(etag) > 0)
+ self.assertTrue(etag is not None)
+ self.assertTrue(len(etag) > 0)
# Delete the test contact.
http_request = atom.http_core.HttpRequest()
@@ -250,14 +250,14 @@
# Create the test contact.
posted = self.client.post(entry,
'https://www.google.com/m8/feeds/contacts/default/full')
- self.assert_(isinstance(posted, gdata.data.GDEntry))
+ self.assertTrue(isinstance(posted, gdata.data.GDEntry))
self.assertEqual(posted.get_elements('title')[0].text, 'Test')
self.assertEqual(posted.get_elements('email')[0].get_attributes(
'address')[0].value, 'test@example.com')
posted.get_elements('title')[0].text = 'Doug'
edited = self.client.update(posted)
- self.assert_(isinstance(edited, gdata.data.GDEntry))
+ self.assertTrue(isinstance(edited, gdata.data.GDEntry))
self.assertEqual(edited.get_elements('title')[0].text, 'Doug')
self.assertEqual(edited.get_elements('email')[0].get_attributes(
'address')[0].value, 'test@example.com')
@@ -266,10 +266,10 @@
self.client.delete(edited)
def notest_crud_over_https_proxy(self):
- import urllib
+ import urllib.request, urllib.parse, urllib.error
PROXY_ADDR = '98.192.125.23'
try:
- response = urllib.urlopen('http://' + PROXY_ADDR)
+ response = urllib.request.urlopen('http://' + PROXY_ADDR)
except IOError:
return
# Only bother running the test if the proxy is up
--- ./tests/gdata_tests/health_test.py (original)
+++ ./tests/gdata_tests/health_test.py (refactored)
@@ -33,8 +33,8 @@
def testToAndFromStringWithData(self):
entry = gdata.health.ProfileEntryFromString(str(self.profile_entry))
- self.assert_(isinstance(entry, gdata.health.ProfileEntry))
- self.assert_(isinstance(entry.ccr, gdata.health.Ccr))
+ self.assertTrue(isinstance(entry, gdata.health.ProfileEntry))
+ self.assertTrue(isinstance(entry.ccr, gdata.heaRefactoringTool: Refactored ./tests/gdata_tests/health/service_test.py
lth.Ccr))
self.assertEqual(len(entry.ccr.GetMedications()), 3)
self.assertEqual(len(entry.ccr.GetImmunizations()), 1)
self.assertEqual(len(entry.ccr.GetAlerts()), 2)
@@ -85,7 +85,7 @@
test_data.HEALTH_PROFILE_LIST_ENTRY)
def testToAndFromString(self):
- self.assert_(isinstance(self.entry, gdata.health.ProfileListEntry))
+ self.assertTrue(isinstance(self.entry, gdata.health.ProfileListEntry))
self.assertEqual(self.entry.GetProfileId(), 'vndCn5sdfwdEIY')
self.assertEqual(self.entry.GetProfileName(), 'profile name')
@@ -97,16 +97,16 @@
test_data.HEALTH_PROFILE_FEED)
def testToAndFromString(self):
- self.assert_(len(self.feed.entry) == 15)
+ self.assertTrue(len(self.feed.entry) == 15)
for an_entry in self.feed.entry:
- self.assert_(isinstance(an_entry, gdata.health.ProfileEntry))
+ self.assertTrue(isinstance(an_entry, gdata.health.ProfileEntry))
new_profile_feed = gdata.health.ProfileFeedFromString(str(self.feed))
for an_entry in new_profile_feed.entry:
- self.assert_(isinstance(an_entry, gdata.health.ProfileEntry))
+ self.assertTrue(isinstance(an_entry, gdata.health.ProfileEntry))
def testConvertActualData(self):
for an_entry in self.feed.entry:
- self.assert_(an_entry.ccr is not None)
+ self.assertTrue(an_entry.ccr is not None)
class HealthProfileQueryTest(unittest.TestCase):
--- ./tests/gdata_tests/health/service_test.py (original)
+++ ./tests/gdata_tests/health/service_test.py (refactored)
@@ -33,14 +33,14 @@
self.profile_list_feed = self.health.GetProfileListFeed()
def testGetProfileListFeed(self):
- self.assert_(isinstance(self.profile_list_feed,
+ self.assertTrue(isinstance(self.profile_list_feed,
gdata.health.ProfileListFeed))
self.assertEqual(self.profile_list_feed.id.text,
'https://www.google.com/health/feeds/profile/list')
first_entry = self.profile_list_feed.entry[0]
- self.assert_(isinstance(first_entry, gdata.health.ProfileListEntry))
- self.assert_(first_entry.GetProfileId() is not None)
- self.assert_(first_entry.GetProfileName() is not None)
+ self.assertTrue(isinstance(first_entry, gdata.health.ProfileListEntry))
+ self.assertTrue(first_entry.GetProfileId() is not None)
+ self.assertTrue(first_entry.GetProfileName() is not None)
query = gdata.health.service.HealthProfileListQuery()
profile_list = self.health.GetProfileListFeed(query)
@@ -58,14 +58,14 @@
self.profile_list_feed = self.h9.GetProfileListFeed()
def testGetProfileListFeed(self):
- self.assert_(isinstance(self.profile_list_feed,
+ self.assertTrue(isinstance(self.profile_list_feed,
gdata.health.ProfileListFeed))
self.assertEqual(self.profile_list_feed.id.text,
'https://www.google.com/h9/feeds/profile/list')
first_entry = self.profile_list_feed.entry[0]
- self.assert_(isinstance(first_entry, gdata.health.ProfileListEntry))
- self.assert_(first_entry.GetProfileId() is not None)
- self.assert_(first_entry.GetProfileName() is not None)
+ self.assertTrue(isinstance(first_entry, gdata.health.ProfileListEntry))
+ self.assertTrue(first_entry.GetProfileId() is not None)
+ self.assertTrue(first_entry.GetProfileName() is not None)
query = gdata.health.service.HealthProfileListQuery()
profile_list = self.h9.GetProfileListFeed(query)
@@ -85,15 +85,15 @@
def testGetProfileFeed(self):
feed = self.health.GetProfileFeed(profile_id=self.profile_id)
- self.assert_(isinstance(feed, gdata.health.ProfileFeed))
- self.assert_(isinstance(feed.entry[0].ccr, gdata.health.Ccr))
+ self.assertTrue(isinstance(feed, gdata.health.ProfileFeed))
+ self.assertTrue(isinstance(feed.entry[0].ccr, gdata.health.Ccr))
def testGetProfileFeedByQuery(self):
query = gdata.health.service.HealthProfileQuery(
projection='ui', profile_id=self.profile_id)
feed = self.health.GetProfileFeed(query=query)
- self.assertRefactoringTool: Refactored ./tests/gdata_tests/gauth_test.py
_(isinstance(feed, gdata.health.ProfileFeed))
- self.assert_(feed.entry[0].ccr is not None)
+ self.assertTrue(isinstance(feed, gdata.health.ProfileFeed))
+ self.assertTrue(feed.entry[0].ccr is not None)
def testGetProfileDigestFeed(self):
query = gdata.health.service.HealthProfileQuery(
@@ -109,11 +109,11 @@
feed = self.health.GetProfileFeed(query=query)
self.assertEqual(len(feed.entry), 1)
if feed.entry[0].ccr.GetMedications() is not None:
- self.assert_(feed.entry[0].ccr.GetMedications()[0] is not None)
- self.assert_(feed.entry[0].ccr.GetConditions()[0] is not None)
- self.assert_(feed.entry[0].ccr.GetAllergies() is None)
- self.assert_(feed.entry[0].ccr.GetAlerts() is None)
- self.assert_(feed.entry[0].ccr.GetResults() is None)
+ self.assertTrue(feed.entry[0].ccr.GetMedications()[0] is not None)
+ self.assertTrue(feed.entry[0].ccr.GetConditions()[0] is not None)
+ self.assertTrue(feed.entry[0].ccr.GetAllergies() is None)
+ self.assertTrue(feed.entry[0].ccr.GetAlerts() is None)
+ self.assertTrue(feed.entry[0].ccr.GetResults() is None)
class H9QueryProfileTest(unittest.TestCase):
@@ -126,15 +126,15 @@
def testGetProfileFeed(self):
feed = self.h9.GetProfileFeed(profile_id=self.profile_id)
- self.assert_(isinstance(feed, gdata.health.ProfileFeed))
- self.assert_(feed.entry[0].ccr is not None)
+ self.assertTrue(isinstance(feed, gdata.health.ProfileFeed))
+ self.assertTrue(feed.entry[0].ccr is not None)
def testGetProfileFeedByQuery(self):
query = gdata.health.service.HealthProfileQuery(
service='h9', projection='ui', profile_id=self.profile_id)
feed = self.h9.GetProfileFeed(query=query)
- self.assert_(isinstance(feed, gdata.health.ProfileFeed))
- self.assert_(feed.entry[0].ccr is not None)
+ self.assertTrue(isinstance(feed, gdata.health.ProfileFeed))
+ self.assertTrue(feed.entry[0].ccr is not None)
class HealthNoticeTest(unittest.TestCase):
@@ -190,6 +190,6 @@
if __name__ == '__main__':
print ('Health API Tests\nNOTE: Please run these tests only with a test '
'account. The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/gauth_test.py (original)
+++ ./tests/gdata_tests/gauth_test.py (refactored)
@@ -54,7 +54,7 @@
def test_generate_request_url(self):
url = gdata.gauth.generate_auth_sub_url('http://example.com',
['http://example.net/scope1'])
- self.assert_(isinstance(url, atom.http_core.Uri))
+ self.assertTrue(isinstance(url, atom.http_core.Uri))
self.assertEqual(url.query['secure'], '0')
self.assertEqual(url.query['session'], '1')
self.assertEqual(url.query['scope'], 'http://example.net/scope1')
@@ -86,7 +86,7 @@
def test_create_and_upgrade_tokens(self):
token = gdata.gauth.AuthSubToken.from_url(
'http://example.com/?token=123abc')
- self.assert_(isinstance(token, gdata.gauth.AuthSubToken))
+ self.assertTrue(isinstance(token, gdata.gauth.AuthSubToken))
self.assertEqual(token.token_string, '123abc')
self.assertEqual(token.scopes, [])
token._upgrade_token('Token=456def')
@@ -123,19 +123,19 @@
token = gdata.gauth.ClientLoginToken('test|key')
copy = gdata.gauth.token_from_blob(gdata.gauth.token_to_blob(token))
self.assertEqual(token.token_string, copy.token_string)
- self.assert_(isinstance(copy, gdata.gauth.ClientLoginToken))
+ self.assertTrue(isinstance(copy, gdata.gauth.ClientLoginToken))
def test_authsub_conversion(self):
token = gdata.gauth.AuthSubToken('test|key')
copy = gdata.gauth.token_from_blob(gdata.gauth.token_to_blob(token))
self.assertEqual(token.token_string, copy.token_string)
- self.assert_(isinstance(copy, gdata.gauth.AuthSubToken))
+ self.assertTrue(isinstance(copy, gdata.gauth.AuthSubToken))
scopes = ['http://example.com', 'http://other||test', 'thir|d']
token = gdata.gauth.AuthSubToken('key-=', scopes)
copy = gdata.gauth.token_from_blob(gdata.gauth.token_to_blob(token))
self.assertEqual(token.token_string, copy.token_string)
- self.assert_(isinstance(copy, gdata.gauth.AuthSubToken))
+ self.assertTrue(isinstance(copy, gdata.gauth.AuthSubToken))
self.assertEqual(token.scopes, scopes)
def test_join_and_split(self):
@@ -146,8 +146,8 @@
self.assertEqual(token_type, '1x')
self.assertEqual(a, 'test|string')
self.assertEqual(b, '%x%')
- self.assert_(c is None)
- self.assert_(d is None)
+ self.assertTrue(c is None)
+ self.assertTrue(d is None)
def test_secure_authsub_conversion(self):
token = gdata.gauth.SecureAuthSubToken(
@@ -189,8 +189,8 @@
self.assertEqual(
blob, '1s|||http%3A%2F%2Fexample.net|http%3A%2F%2Fgoogle.com')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(copy.token_string is None)
- self.assert_(copy.rsa_private_key is None)
+ self.assertTrue(copy.token_string is None)
+ self.assertTrue(copy.rsa_private_key is None)
self.assertEqual(copy.scopes, ['http://example.net', 'http://google.com'])
def test_oauth_rsa_conversion(self):
@@ -203,13 +203,13 @@
blob, '1r|consumerKey|myRsa|t|secret|2|http%3A%2F%2Fexample.com'
'%2Fnext|verifier')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuthRsaToken))
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuthRsaToken))
self.assertEqual(copy.consumer_key, token.consumer_key)
self.assertEqual(copy.rsa_private_key, token.rsa_private_key)
self.assertEqual(copy.token, token.token)
self.assertEqual(copy.token_secret, token.token_secret)
self.assertEqual(copy.auth_state, token.auth_state)
- self.assertEqual(copy.next, token.next)
+ self.assertEqual(copy.__next__, token.__next__)
self.assertEqual(copy.verifier, token.verifier)
token = gdata.gauth.OAuthRsaToken(
@@ -217,17 +217,17 @@
blob = gdata.gauth.token_to_blob(token)
self.assertEqual(blob, '1r||myRsa|t|secret|0||')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuthRsaToken))
- self.assert_(copy.consumer_key != token.consumer_key)
- self.assert_(copy.consumer_key is None)
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuthRsaToken))
+ self.assertTrue(copy.consumer_key != token.consumer_key)
+ self.assertTrue(copy.consumer_key is None)
self.assertEqual(copy.rsa_private_key, token.rsa_private_key)
self.assertEqual(copy.token, token.token)
self.assertEqual(copy.token_secret, token.token_secret)
self.assertEqual(copy.auth_state, token.auth_state)
- self.assertEqual(copy.next, token.next)
- self.assert_(copy.next is None)
+ self.assertEqual(copy.__next__, token.__next__)
+ self.assertTrue(copy.__next__ is None)
self.assertEqual(copy.verifier, token.verifier)
- self.assert_(copy.verifier is None)
+ self.assertTrue(copy.verifier is None)
token = gdata.gauth.OAuthRsaToken(
rsa_private_key='myRsa', token='t', token_secret='secret',
@@ -236,13 +236,13 @@
self.assertEqual(blob, '1r||myRsa|t|secret|3||v')
copy = gdata.gauth.token_from_blob(blob)
self.assertEqual(copy.consumer_key, token.consumer_key)
- self.assert_(copy.consumer_key is None)
+ self.assertTrue(copy.consumer_key is None)
self.assertEqual(copy.rsa_private_key, token.rsa_private_key)
self.assertEqual(copy.token, token.token)
self.assertEqual(copy.token_secret, token.token_secret)
self.assertEqual(copy.auth_state, token.auth_state)
- self.assertEqual(copy.next, token.next)
- self.assert_(copy.next is None)
+ self.assertEqual(copy.__next__, token.__next__)
+ self.assertTrue(copy.__next__ is None)
self.assertEqual(copy.verifier, token.verifier)
def test_oauth_hmac_conversion(self):
@@ -254,13 +254,13 @@
blob, '1h|consumerKey|consumerSecret|t|secret|1|http%3A%2F%2F'
'example.com%2Fnext|verifier')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuthHmacToken))
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuthHmacToken))
self.assertEqual(copy.consumer_key, token.consumer_key)
self.assertEqual(copy.consumer_secret, token.consumer_secret)
self.assertEqual(copy.token, token.token)
self.assertEqual(copy.token_secret, token.token_secret)
self.assertEqual(copy.auth_state, token.auth_state)
- self.assertEqual(copy.next, token.next)
+ self.assertEqual(copy.__next__, token.__next__)
self.assertEqual(copy.verifier, token.verifier)
token = gdata.gauth.OAuthHmacToken(
@@ -269,15 +269,15 @@
blob = gdata.gauth.token_to_blob(token)
self.assertEqual(blob, '1h||c%2Cs|t|secret|7||v')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuthHmacToken))
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuthHmacToken))
self.assertEqual(copy.consumer_key, token.consumer_key)
- self.assert_(copy.consumer_key is None)
+ self.assertTrue(copy.consumer_key is None)
self.assertEqual(copy.consumer_secret, token.consumer_secret)
self.assertEqual(copy.token, token.token)
self.assertEqual(copy.token_secret, token.token_secret)
self.assertEqual(copy.auth_state, token.auth_state)
- self.assertEqual(copy.next, token.next)
- self.assert_(copy.next is None)
+ self.assertEqual(copy.__next__, token.__next__)
+ self.assertTrue(copy.__next__ is None)
self.assertEqual(copy.verifier, token.verifier)
def test_oauth2_conversion(self):
@@ -293,7 +293,7 @@
'o%2Foauth2%2Fauth|https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2'
'%2Ftoken|accessToken|refreshToken')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuth2Token))
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuth2Token))
self.assertEqual(copy.client_id, token.client_id)
self.assertEqual(copy.client_secret, token.client_secret)
@@ -316,16 +316,16 @@
'o%2Foauth2%2Fauth|https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2'
'%2Ftoken||')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuth2Token))
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuth2Token))
self.assertEqual(copy.client_id, token.client_id)
self.assertEqual(copy.client_secret, token.client_secret)
self.assertEqual(copy.scope, token.scope)
- self.assert_(copy.user_agent is None)
+ self.assertTrue(copy.user_agent is None)
self.assertEqual(copy.auth_uri, token.auth_uri)
self.assertEqual(copy.token_uri, token.token_uri)
- self.assert_(copy.access_token is None)
- self.assert_(copy.refresh_token is None)
+ self.assertTrue(copy.access_token is None)
+ self.assertTrue(copy.refresh_token is None)
token = gdata.gauth.OAuth2Token(
'clientId', 'clientSecret', 'https://www.google.com/calendar/feeds',
@@ -338,16 +338,16 @@
'o%2Foauth2%2Fauth|https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2'
'%2Ftoken||')
copy = gdata.gauth.token_from_blob(blob)
- self.assert_(isinstance(copy, gdata.gauth.OAuth2Token))
+ self.assertTrue(isinstance(copy, gdata.gauth.OAuth2Token))
self.assertEqual(copy.client_id, token.client_id)
self.assertEqual(copy.client_secret, token.client_secret)
self.assertEqual(copy.scope, token.scope)
- self.assert_(copy.user_agent is None)
+ self.assertTrue(copy.user_agent is None)
self.assertEqual(copy.auth_uri, token.auth_uri)
self.assertEqual(copy.token_uri, token.token_uri)
- self.assert_(copy.access_token is None)
- self.assert_(copy.refresh_token is None)
+ self.assertTrue(copy.access_token is None)
+ self.assertTrue(copy.refresh_token is None)
def test_illegal_token_types(self):
class MyToken(object):
@@ -600,7 +600,7 @@
proxy_keys = ['client_id', 'client_secret', 'user_agent', 'token_uri',
'access_token', 'refresh_token', 'token_expiry', '_invalid']
for key in proxy_keys:
- self.assertFalse(self.token.__dict__.has_key(key))
+ self.assertFalse(key in self.token.__dict__)
def test_get_proxied_values_change_credentials(self):
new_value = 'NEW_VALUE'
@@ -612,8 +612,8 @@
def test_get_proxied_values_change_credentials(self):
# Make sure scope is not a valid attribute (ignored in this subclass)
- self.assertFalse(self.token.__dict__.has_key('scope'))
- self.assertFalse(self.token.__class__.__dict__.has_key('scope'))
+ self.assertFalse('scope' in self.token.__dict__)
+ self.assertFalse('scope' in self.token.__class__.__dict__)
# Make sure attribute lookup fails as it should
self.assertRaises(AttributeError, getattr, self.token, 'scope')
self.assertRaises(AttributeError, lambda: self.token.scope)
@@ -638,8 +638,8 @@
self._check_all_values()
def test_set_proxied_values_nonprotected_attribute(self):
- self.assertFalse(self.token.__dict__.has_key('scope'))
- self.assertFalse(self.token.__class__.__dict__.has_key('scope'))
+ self.assertFalse('scope' in self.token.__dict__)
+ self.assertFalse('scope' in self.token.__class__.__dict__)
self.token.scope = 'value'
self.assertEqual(self.token.scope, 'value')
self.assertFalse(hasattr(self.credentials, 'scope'))
@@ -663,21 +663,21 @@
def test_generate_auth_header(self):
header = gdata.gauth.generate_auth_header(
'consumerkey', 1234567890, 'mynonce', 'unknown_sig_type', 'sig')
- self.assert_(header.startswith('OAuth'))
- self.assert_(header.find('oauth_nonce="mynonce"') > -1)
- self.assert_(header.find('oauth_timestamp="1234567890"') > -1)
- self.assert_(header.find('oauth_consumer_key="consumerkey"') > -1)
- self.assert_(
+ self.assertTrue(header.startswith('OAuth'))
+ self.assertTrue(header.find('oauth_nonce="mynonce"') > -1)
+ self.assertTrue(header.find('oauth_timestamp="1234567890"') > -1)
+ self.assertTrue(header.find('oauth_consumer_key="consumerkey"') > -1)
+ self.assertTrue(
header.find('oauth_signature_method="unknown_sig_type"') > -1)
- self.assert_(header.find('oauth_version="1.0"') > -1)
- self.assert_(header.find('oauth_signature="sig"') > -1)
+ self.assertTrue(header.find('oauth_version="1.0"') > -1)
+ self.assertTrue(header.find('oauth_signature="sig"') > -1)
header = gdata.gauth.generate_auth_header(
'consumer/key', 1234567890, 'ab%&33', '', 'ab/+-_=')
- self.assert_(header.find('oauth_nonce="ab%25%2633"') > -1)
- self.assert_(header.find('oauth_consumer_key="consumer%2Fkey"') > -1)
- self.assert_(header.find('oauth_signature_method=""') > -1)
- self.assert_(header.find('oauth_signature="ab%2F%2B-_%3D"') > -1)
+ self.assertTrue(header.find('oauth_nonce="ab%25%2633"') > -1)
+ self.assertTrue(header.find('oauth_consumer_key="consumer%2Fkey"') > -1)
+ self.assertTrue(header.find('oauth_signature_method=""') > -1)
+ self.assertTrue(header.find('oauth_signature="ab%2F%2B-_%3D"') > -1)
class OAuthGetRequestToken(unittest.TestCase):
@@ -689,16 +689,16 @@
'http://www.google.com/calendar/feeds/'],
consumer_secret='anonymous')
request_uri = str(request.uri)
- self.assert_('http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F' in request_uri)
- self.assert_(
+ self.assertTrue('http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F' in request_uri)
+ self.assertTrue(
'http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F' in request_uri)
auth_header = request.headers['Authorization']
- self.assert_('oauth_consumer_key="anonymous"' in auth_header)
- self.assert_('oauth_signature_method="HMAC-SHA1"' in auth_header)
- self.assert_('oauth_version="1.0"' in auth_header)
- self.assert_('oauth_signature="' in auth_header)
- self.assert_('oauth_nonce="' in auth_header)
- self.assert_('oauth_timestamp="' in auth_header)
+ self.assertTrue('oauth_consumer_key="anonymous"' in auth_header)
+ self.assertTrue('oauth_signature_method="HMAC-SHA1"' in auth_header)
+ selRefactoringTool: Refactored ./tests/gdata_tests/docs_test.py
f.assertTrue('oauth_version="1.0"' in auth_header)
+ self.assertTrue('oauth_signature="' in auth_header)
+ self.assertTrue('oauth_nonce="' in auth_header)
+ self.assertTrue('oauth_timestamp="' in auth_header)
def test_request_rsa_request_token(self):
request = gdata.gauth.generate_request_for_request_token(
@@ -707,16 +707,16 @@
'http://www.google.com/calendar/feeds/'],
rsa_key=PRIVATE_TEST_KEY)
request_uri = str(request.uri)
- self.assert_('http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F' in request_uri)
- self.assert_(
+ self.assertTrue('http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F' in request_uri)
+ self.assertTrue(
'http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F' in request_uri)
auth_header = request.headers['Authorization']
- self.assert_('oauth_consumer_key="anonymous"' in auth_header)
- self.assert_('oauth_signature_method="RSA-SHA1"' in auth_header)
- self.assert_('oauth_version="1.0"' in auth_header)
- self.assert_('oauth_signature="' in auth_header)
- self.assert_('oauth_nonce="' in auth_header)
- self.assert_('oauth_timestamp="' in auth_header)
+ self.assertTrue('oauth_consumer_key="anonymous"' in auth_header)
+ self.assertTrue('oauth_signature_method="RSA-SHA1"' in auth_header)
+ self.assertTrue('oauth_version="1.0"' in auth_header)
+ self.assertTrue('oauth_signature="' in auth_header)
+ self.assertTrue('oauth_nonce="' in auth_header)
+ self.assertTrue('oauth_timestamp="' in auth_header)
def test_extract_token_from_body(self):
body = ('oauth_token=4%2F5bNFM_efIu3yN-E9RrF1KfZzOAZG&oauth_token_secret='
@@ -752,9 +752,9 @@
def test_generate_authorization_url(self):
url = gdata.gauth.generate_oauth_authorization_url('/+=aosdpikk')
- self.assert_(str(url).startswith(
+ self.assertTrue(str(url).startswith(
'https://www.google.com/accounts/OAuthAuthorizeToken'))
- self.assert_('oauth_token=%2F%2B%3Daosdpikk' in str(url))
+ self.assertTrue('oauth_token=%2F%2B%3Daosdpikk' in str(url))
def test_extract_auth_token(self):
url = ('http://www.example.com/test?oauth_token='
@@ -768,7 +768,7 @@
def test_find_all_scopes(self):
count = 0
- for key, scopes in gdata.gauth.AUTH_SCOPES.iteritems():
+ for key, scopes in gdata.gauth.AUTH_SCOPES.items():
count += len(scopes)
self.assertEqual(count, len(gdata.gauth.find_scopes_for_services()))
--- ./tests/gdata_tests/docs_test.py (original)
+++ ./tests/gdata_tests/docs_test.py (refactored)
@@ -53,12 +53,12 @@
test_data.DOCUMENT_LIST_FEED)
def testToAndFromString(self):
- self.assert_(len(self.dl_feed.entry) == 2)
+ self.assertTrue(len(self.dl_feed.entry) == 2)
for an_entry in self.dl_feed.entry:
- self.assert_(isinstance(an_entry, gdata.docs.DocumentListEntry))
+ self.assertTrue(isinstance(an_entry, gdata.docs.DocumentListEntry))
new_dl_feed = gdata.docs.DocumentListFeedFromString(str(self.dl_feed))
for an_entry in new_dl_feed.entry:
- self.assert_(isinstance(an_entry, gdata.docs.DocumentListEntry))
+ self.assertTrue(isinstance(an_entry, gdata.docs.DocumentListEntry))
def testConvertActualData(self):
for an_entry in self.dl_feed.entry:
@@ -78,10 +78,10 @@
def testLinkFinderFindsLinks(self):
for entry in self.dl_feed.entry:
# All Document List entries should have a self link
- self.assert_(entry.GetSelfLink() is not None)
+ self.assertTrue(entry.GetSelfLink() is not None)
# All Document List entries should have an HTML link
- self.assert_(entry.GetHtmlLink() is not None)
- self.assert_(entry.feedLink.href is not None)
+ self.assertTrue(entry.GetHtmlLink() is not None)
+ self.assertTrue(entry.feedLink.href is not None)
class DocumentListAclEntryTest(unittest.TestCase):
@@ -92,18 +92,18 @@
def testToAndFromString(self):
- self.assert_(isinstance(self.acl_entry, gdata.docs.DocumentListAclEntry))
- self.assert_(isinstance(self.acl_entry.role, gdata.docs.Role))
- self.assert_(isinstRefactoringTool: Refactored ./tests/gdata_tests/docs/service_test.py
ance(self.acl_entry.scope, gdata.docs.Scope))
+ self.assertTrue(isinstance(self.acl_entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(self.acl_entry.role, gdata.docs.Role))
+ self.assertTrue(isinstance(self.acl_entry.scope, gdata.docs.Scope))
self.assertEqual(self.acl_entry.scope.value, 'user@gmail.com')
self.assertEqual(self.acl_entry.scope.type, 'user')
self.assertEqual(self.acl_entry.role.value, 'writer')
acl_entry_str = str(self.acl_entry)
new_acl_entry = gdata.docs.DocumentListAclEntryFromString(acl_entry_str)
- self.assert_(isinstance(new_acl_entry, gdata.docs.DocumentListAclEntry))
- self.assert_(isinstance(new_acl_entry.role, gdata.docs.Role))
- self.assert_(isinstance(new_acl_entry.scope, gdata.docs.Scope))
+ self.assertTrue(isinstance(new_acl_entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(new_acl_entry.role, gdata.docs.Role))
+ self.assertTrue(isinstance(new_acl_entry.scope, gdata.docs.Scope))
self.assertEqual(new_acl_entry.scope.value, self.acl_entry.scope.value)
self.assertEqual(new_acl_entry.scope.type, self.acl_entry.scope.type)
self.assertEqual(new_acl_entry.role.value, self.acl_entry.role.value)
@@ -115,9 +115,9 @@
acl_entry = gdata.docs.DocumentListAclEntry(category=[cat])
acl_entry.scope = gdata.docs.Scope(value='user@gmail.com', type='user')
acl_entry.role = gdata.docs.Role(value='writer')
- self.assert_(isinstance(acl_entry, gdata.docs.DocumentListAclEntry))
- self.assert_(isinstance(acl_entry.role, gdata.docs.Role))
- self.assert_(isinstance(acl_entry.scope, gdata.docs.Scope))
+ self.assertTrue(isinstance(acl_entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(acl_entry.role, gdata.docs.Role))
+ self.assertTrue(isinstance(acl_entry.scope, gdata.docs.Scope))
self.assertEqual(acl_entry.scope.value, 'user@gmail.com')
self.assertEqual(acl_entry.scope.type, 'user')
self.assertEqual(acl_entry.role.value, 'writer')
@@ -130,29 +130,29 @@
def testToAndFromString(self):
for entry in self.feed.entry:
- self.assert_(isinstance(entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.DocumentListAclEntry))
feed = gdata.docs.DocumentListAclFeedFromString(str(self.feed))
for entry in feed.entry:
- self.assert_(isinstance(entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.DocumentListAclEntry))
def testConvertActualData(self):
entries = self.feed.entry
- self.assert_(len(entries) == 2)
+ self.assertTrue(len(entries) == 2)
self.assertEqual(entries[0].title.text,
'Document Permission - user@gmail.com')
self.assertEqual(entries[0].role.value, 'owner')
self.assertEqual(entries[0].scope.type, 'user')
self.assertEqual(entries[0].scope.value, 'user@gmail.com')
- self.assert_(entries[0].GetSelfLink() is not None)
- self.assert_(entries[0].GetEditLink() is not None)
+ self.assertTrue(entries[0].GetSelfLink() is not None)
+ self.assertTrue(entries[0].GetEditLink() is not None)
self.assertEqual(entries[1].title.text,
'Document Permission - user2@google.com')
self.assertEqual(entries[1].role.value, 'writer')
self.assertEqual(entries[1].scope.type, 'domain')
self.assertEqual(entries[1].scope.value, 'google.com')
- self.assert_(entries[1].GetSelfLink() is not None)
- self.assert_(entries[1].GetEditLink() is not None)
+ self.assertTrue(entries[1].GetSelfLink() is not None)
+ self.assertTrue(entries[1].GetEditLink() is not None)
if __name__ == '__main__':
unittest.main()
--- ./tests/gdata_tests/docs/service_test.py (original)
+++ ./tests/gdata_tests/docs/service_test.py (refactored)
@@ -20,7 +20,7 @@
import getpass
import os
import re
-import StringIO
+import io
import time
import unittest
@@ -55,12 +55,12 @@
self.feed = self.client.GetDocumentListFeed()
def testGetDocumentsListFeed(self):
- self.assert_(isinstance(self.feed, gdata.docs.DocumentListFeed))
+ self.assertTrue(isinstance(self.feed, gdata.docs.DocumentListFeed))
uri = 'http://docs.google.com/feeds/documents/private/full/?max-results=1'
# Query using GetDocumentListFeed()
feed = self.client.GetDocumentListFeed(uri)
- self.assert_(isinstance(feed, gdata.docs.DocumentListFeed))
+ self.assertTrue(isinstance(feed, gdata.docs.DocumentListFeed))
self.assertEqual(len(feed.entry), 1)
self.assertEqual(self.feed.entry[0].id.text, feed.entry[0].id.text)
self.assertEqual(self.feed.entry[0].title.text, feed.entry[0].title.text)
@@ -74,13 +74,13 @@
def testGetDocumentsListEntry(self):
self_link = self.feed.entry[0].GetSelfLink().href
entry = self.client.GetDocumentListEntry(self_link)
- self.assert_(isinstance(entry, gdata.docs.DocumentListEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.DocumentListEntry))
self.assertEqual(self.feed.entry[0].id.text, entry.id.text)
self.assertEqual(self.feed.entry[0].title.text, entry.title.text)
- self.assert_(self.feed.entry[0].resourceId.text is not None)
- self.assert_(self.feed.entry[0].lastModifiedBy is not None)
- self.assert_(self.feed.entry[0].lastViewed is not None)
+ self.assertTrue(self.feed.entry[0].resourceId.text is not None)
+ self.assertTrue(self.feed.entry[0].lastModifiedBy is not None)
+ self.assertTrue(self.feed.entry[0].lastViewed is not None)
def testGetDocumentsListAclFeed(self):
uri = ('http://docs.google.com/feeds/documents/private/full/'
@@ -88,10 +88,10 @@
feed = self.client.GetDocumentListFeed(uri)
feed_link = feed.entry[0].GetAclLink().href
acl_feed = self.client.GetDocumentListAclFeed(feed_link)
- self.assert_(isinstance(acl_feed, gdata.docs.DocumentListAclFeed))
- self.assert_(isinstance(acl_feed.entry[0], gdata.docs.DocumentListAclEntry))
- self.assert_(acl_feed.entry[0].scope is not None)
- self.assert_(acl_feed.entry[0].role is not None)
+ self.assertTrue(isinstance(acl_feed, gdata.docs.DocumentListAclFeed))
+ self.assertTrue(isinstance(acl_feed.entry[0], gdata.docs.DocumentListAclEntry))
+ self.assertTrue(acl_feed.entry[0].scope is not None)
+ self.assertTrue(acl_feed.entry[0].role is not None)
class DocumentListAclTest(DocumentsListServiceTest):
@@ -115,7 +115,7 @@
gdata.docs.DocumentListAclEntry(scope=scope, role=role),
self.feed.entry[0].GetAclLink().href,
converter=gdata.docs.DocumentListAclEntryFromString)
- self.assert_(isinstance(acl_entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(acl_entry, gdata.docs.DocumentListAclEntry))
self.assertEqual(acl_entry.scope.value, self.EMAIL)
self.assertEqual(acl_entry.scope.type, self.SCOPE_TYPE)
self.assertEqual(acl_entry.role.value, self.ROLE_VALUE)
@@ -139,7 +139,7 @@
acl_feed = self.client.GetDocumentListAclFeed(
self.feed.entry[0].GetAclLink().href)
for acl_entry in acl_feed.entry:
- self.assert_(acl_entry.scope.value != self.EMAIL)
+ self.assertTrue(acl_entry.scope.value != self.EMAIL)
class DocumentListCreateAndDeleteTest(DocumentsListServiceTest):
@@ -253,7 +253,7 @@
for category in moved_entry.category:
starts_with_folder__prefix = category.scheme.startswith(
gdata.docs.service.FOLDERS_SCHEME_PREFIX)
- self.assert_(not starts_with_folder__prefix)
+ self.assertTrue(not starts_with_folder__prefix)
created_entry = self.client.Get(created_entry.GetSelfLink().href)
self.editClient.Delete(created_entry.GetEditLink().href)
@@ -269,7 +269,7 @@
if category.term == dest_folder_name:
folder_was_moved = True
break
- self.assert_(folder_was_moved)
+ self.assertTrue(folder_was_moved)
#cleanup
dest_folder = self.client.Get(dest_folder.GetSelfLink().href)
@@ -284,7 +284,7 @@
entry = self.client.Upload(ms, 'test doc')
self.assertEqual(entry.title.text, 'test doc')
self.assertEqual(entry.category[0].label, 'document')
-RefactoringTool: Refactored ./tests/gdata_tests/docs/live_client_test.py
self.assert_(isinstance(entry, gdata.docs.DocumentListEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.DocumentListEntry))
self.editClient.Delete(entry.GetEditLink().href)
def testUploadAndDeletePresentation(self):
@@ -294,17 +294,17 @@
self.assertEqual(entry.title.text, 'test preso')
self.assertEqual(entry.category[0].label, 'viewed')
self.assertEqual(entry.category[1].label, 'presentation')
- self.assert_(isinstance(entry, gdata.docs.DocumentListEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.DocumentListEntry))
self.editClient.Delete(entry.GetEditLink().href)
def testUploadAndDeleteSpreadsheet(self):
ms = gdata.MediaSource(file_path='test.csv',
content_type='text/csv')
entry = self.client.Upload(ms, 'test spreadsheet')
- self.assert_(entry.title.text == 'test spreadsheet')
+ self.assertTrue(entry.title.text == 'test spreadsheet')
self.assertEqual(entry.category[0].label, 'viewed')
self.assertEqual(entry.category[1].label, 'spreadsheet')
- self.assert_(isinstance(entry, gdata.docs.DocumentListEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.DocumentListEntry))
self.editClient.Delete(entry.GetEditLink().href)
@@ -341,7 +341,7 @@
# Append content to document
data = 'data to append'
- ms = gdata.MediaSource(file_handle=StringIO.StringIO(data),
+ ms = gdata.MediaSource(file_handle=io.StringIO(data),
content_type='text/plain',
content_length=len(data))
uri = updated_entry.GetEditMediaLink().href + '?append=true'
@@ -360,8 +360,8 @@
'./downloadedTest.txt', './downloadedTest.zip']
for path in file_paths:
self.client.Export(feed.entry[0], path)
- self.assert_(os.path.exists(path))
- self.assert_(os.path.getsize(path))
+ self.assertTrue(os.path.exists(path))
+ self.assertTrue(os.path.getsize(path))
os.remove(path)
def testExportPresentation(self):
@@ -372,8 +372,8 @@
'./downloadedTest.swf', './downloadedTest.txt']
for path in file_paths:
self.client.Export(feed.entry[0].resourceId.text, path)
- self.assert_(os.path.exists(path))
- self.assert_(os.path.getsize(path))
+ self.assertTrue(os.path.exists(path))
+ self.assertTrue(os.path.getsize(path))
os.remove(path)
def testExportSpreadsheet(self):
@@ -387,8 +387,8 @@
self.client.SetClientLoginToken(self.spreadsheets.GetClientLoginToken())
for path in file_paths:
self.client.Export(feed.entry[0], path)
- self.assert_(os.path.exists(path))
- self.assert_(os.path.getsize(path) > 0)
+ self.assertTrue(os.path.exists(path))
+ self.assertTrue(os.path.getsize(path) > 0)
os.remove(path)
self.client.SetClientLoginToken(docs_token)
@@ -397,15 +397,15 @@
exception_raised = False
try:
self.client.Export('non_existent_doc', path)
- except Exception, e: # expected
+ except Exception as e: # expected
exception_raised = True
- self.assert_(exception_raised)
- self.assert_(not os.path.exists(path))
+ self.assertTrue(exception_raised)
+ self.assertTrue(not os.path.exists(path))
if __name__ == '__main__':
print ('DocList API Tests\nNOTE: Please run these tests only with a test '
'account. The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
if client.GetClientLoginToken() is None:
client.ClientLogin(username, password,
--- ./tests/gdata_tests/docs/live_client_test.py (original)
+++ ./tests/gdata_tests/docs/live_client_test.py (refactored)
@@ -168,43 +168,43 @@
def testGetAllResources(self):
results = self.client.GetAllResources(
'/feeds/default/private/full?showfolders=true')
- self.assert_(all(isinstance(item, gdata.docs.data.Resource) \
+ self.assertTrue(all(isinstance(item, gdata.docs.data.Resource) \
for item in results))
self.assertEqual(len(results), 1)
def testGetResources(self):
feed = self.client.GetResources(
'/feeds/default/private/full?showfolders=true', limit=1)
- self.assert_(isinstance(feed, gdata.docs.data.ResourceFeed))
+ self.assertTrue(isinstance(feed, gdata.docs.data.ResourceFeed))
self.assertEqual(len(feed.entry), 1)
def testGetResource(self):
entry = self.client.GetResource(self.resource)
- self.assert_(isinstance(entry, gdata.docs.data.Resource))
- self.assert_(entry.id.text is not None)
- self.assert_(entry.title.text is not None)
- self.assert_(entry.resource_id.text is not None)
- self.assert_(entry.title.text is not None)
+ self.assertTrue(isinstance(entry, gdata.docs.data.Resource))
+ self.assertTrue(entry.id.text is not None)
+ self.assertTrue(entry.title.text is not None)
+ self.assertTrue(entry.resource_id.text is not None)
+ self.assertTrue(entry.title.text is not None)
entry = self.client.GetResourceById(self.resource.resource_id.text)
- self.assert_(isinstance(entry, gdata.docs.data.Resource))
- self.assert_(entry.id.text is not None)
- self.assert_(entry.title.text is not None)
- self.assert_(entry.resource_id.text is not None)
- self.assert_(entry.title.text is not None)
+ self.assertTrue(isinstance(entry, gdata.docs.data.Resource))
+ self.assertTrue(entry.id.text is not None)
+ self.assertTrue(entry.title.text is not None)
+ self.assertTrue(entry.resource_id.text is not None)
+ self.assertTrue(entry.title.text is not None)
entry = self.client.GetResourceById(
self.resource.resource_id.text.split(':')[1])
- self.assert_(isinstance(entry, gdata.docs.data.Resource))
- self.assert_(entry.id.text is not None)
- self.assert_(entry.title.text is not None)
- self.assert_(entry.resource_id.text is not None)
- self.assert_(entry.title.text is not None)
+ self.assertTrue(isinstance(entry, gdata.docs.data.Resource))
+ self.assertTrue(entry.id.text is not None)
+ self.assertTrue(entry.title.text is not None)
+ self.assertTrue(entry.resource_id.text is not None)
+ self.assertTrue(entry.title.text is not None)
entry = self.client.GetResourceBySelfLink(
self.resource.GetSelfLink().href)
- self.assert_(isinstance(entry, gdata.docs.data.Resource))
- self.assert_(entry.id.text is not None)
- self.assert_(entry.title.text is not None)
- self.assert_(entry.resource_id.text is not None)
- self.assert_(entry.title.text is not None)
+ self.assertTrue(isinstance(entry, gdata.docs.data.Resource))
+ self.assertTrue(entry.id.text is not None)
+ self.assertTrue(entry.title.text is not None)
+ self.assertTrue(entry.resource_id.text is not None)
+ self.assertTrue(entry.title.text is not None)
def testMoveResource(self):
entry = gdata.docs.data.Resource(
@@ -290,17 +290,17 @@
class AclTest(DocsTestCase):
def testGetAcl(self):
acl_feed = self.client.GetResourceAcl(self.resource)
- self.assert_(isinstance(acl_feed, gdata.docs.data.AclFeed))
+ self.assertTrue(isinstance(acl_feed, gdata.docs.data.AclFeed))
self.assertEqual(len(acl_feed.entry), 1)
- self.assert_(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
- self.assert_(acl_feed.entry[0].scope is not None)
- self.assert_(acl_feed.entry[0].role is not None)
+ self.assertTrue(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
+ self.assertTrue(acl_feed.entry[0].scope is not None)
+ self.assertTrue(acl_feed.entry[0].role is not None)
def testGetAclEntry(self):
acl_feed = self.client.GetResourceAcl(self.resource)
acl_entry = acl_feed.entry[0]
same_acl_entry = self.client.GetAclEntry(acl_entry)
- self.assert_(isinstance(same_acl_entry, gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(same_acl_entry, gdata.docs.data.AclEntry))
self.assertEqual(acl_entry.GetSelfLink().href,
same_acl_entry.GetSelfLink().href)
self.assertEqual(acl_entry.title.text, same_acl_entry.title.text)
@@ -316,9 +316,9 @@
self.assertEqual(acl_entry_to_add.with_key.role.value,
new_acl_entry.with_key.role.value)
acl_feed = self.client.GetResourceAcl(self.resource)
- self.assert_(isinstance(acl_feed, gdata.docs.data.AclFeed))
- self.assert_(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
- self.assert_(isinstance(acl_feed.entry[1], gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(acl_feed, gdata.docs.data.AclFeed))
+ self.assertTrue(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(acl_feed.entry[1], gdata.docs.data.AclEntry))
def testUpdateAclEntry(self):
acl_entry_to_add = gdata.docs.data.AclEntry.GetInstance(
@@ -349,17 +349,17 @@
new_acl_entry = self.client.AddAclEntry(self.resource, acl_entry_to_add)
acl_feed = self.client.GetResourceAcl(self.resource)
- self.assert_(isinstance(acl_feed, gdata.docs.data.AclFeed))
+ self.assertTrue(isinstance(acl_feed, gdata.docs.data.AclFeed))
self.assertEqual(len(acl_feed.entry), 2)
- self.assert_(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
- self.assert_(isinstance(acl_feed.entry[1], gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(acl_feed.entry[1], gdata.docs.data.AclEntry))
self.client.DeleteAclEntry(new_acl_entry)
acl_feed = self.client.GetResourceAcl(self.resource)
- self.assert_(isinstance(acl_feed, gdata.docs.data.AclFeed))
+ self.assertTrue(isinstance(acl_feed, gdata.docs.data.AclFeed))
self.assertEqual(len(acl_feed.entry), 1)
- self.assert_(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(acl_feed.entry[0], gdata.docs.data.AclEntry))
class RevisionsTest(DocsTestCase):
@@ -367,8 +367,8 @@
# There are no revisions of collections
if self.resource_type != 'collection':
revisions = self.client.GetRevisions(self.resource)
- self.assert_(isinstance(revisions, gdata.docs.data.RevisionFeed))
- self.assert_(isinstance(revisions.entry[0], gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revisions, gdata.docs.data.RevisionFeed))
+ self.assertTrue(isinstance(revisions.entry[0], gdata.docs.data.Revision))
# Currently, there is a bug where new presentations have 2 revisions.
if self.resource_type != 'presentation':
self.assertEqual(len(revisions.entry), 1)
@@ -410,14 +410,14 @@
if self.resource_type != 'collection':
revisions = self.client.GetRevisions(entry)
- self.assert_(isinstance(revisions, gdata.docs.data.RevisionFeed))
+ self.assertTrue(isinstance(revisions, gdata.docs.data.RevisionFeed))
if self.resource_type == 'presentation':
self.assertEqual(len(revisions.entry), 3)
- self.assert_(isinstance(revisions.entry[2], gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revisions.entry[2], gdata.docs.data.Revision))
else:
self.assertEqual(len(revisions.entry), 2)
- self.assert_(isinstance(revisions.entry[0], gdata.docs.data.Revision))
- self.assert_(isinstance(revisions.entry[1], gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revisions.entry[0], gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revisions.entry[1], gdata.docs.data.Revision))
def testPublishRevision(self):
if self.resource_type in ['file', 'pdf', 'collection']:
@@ -434,7 +434,7 @@
if self.resource_type == 'presentation':
revisions = self.client.GetRevisions(entry)
revision = revisions.entry[2]
- self.assert_(isinstance(revision, gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revision, gdata.docs.data.Revision))
self.assertEqual(revision.publish.value, 'true')
self.assertEqual(revision.publish_auto.value, 'false')
@@ -457,7 +457,7 @@
revisions.entry[1], publish_auto=True, publish_outside_domain=True)
if self.resource_type ==RefactoringTool: Refactored ./tests/gdata_tests/docs/data_test.py
'spreadsheet':
revision = client.GetRevisions(entry).entry[1]
- self.assert_(isinstance(revision, gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revision, gdata.docs.data.Revision))
self.assertEqual(revision.publish.value, 'true')
self.assertEqual(revision.publish_auto.value, 'true')
self.assertEqual(revision.publish_outside_domain.value, 'true')
@@ -486,8 +486,8 @@
revisions = self.client.GetRevisions(entry)
self.assertEqual(len(revisions.entry), 2)
self.client.DeleteRevision(revisions.entry[1])
- self.assert_(isinstance(revisions, gdata.docs.data.RevisionFeed))
- self.assert_(isinstance(revisions.entry[0], gdata.docs.data.Revision))
+ self.assertTrue(isinstance(revisions, gdata.docs.data.RevisionFeed))
+ self.assertTrue(isinstance(revisions.entry[0], gdata.docs.data.Revision))
revisions = self.client.GetRevisions(entry)
self.assertEqual(len(revisions.entry), 1)
@@ -498,14 +498,14 @@
# being used already has a number of changes
changes = self.client.GetChanges(max_results=5)
- self.assert_(isinstance(changes, gdata.docs.data.ChangeFeed))
- self.assert_(len(changes.entry) <= 5)
- self.assert_(isinstance(changes.entry[0], gdata.docs.data.Change))
+ self.assertTrue(isinstance(changes, gdata.docs.data.ChangeFeed))
+ self.assertTrue(len(changes.entry) <= 5)
+ self.assertTrue(isinstance(changes.entry[0], gdata.docs.data.Change))
self._update()
changes = self.client.GetChanges(changes.entry[0].changestamp.value, 5)
- self.assert_(isinstance(changes, gdata.docs.data.ChangeFeed))
- self.assert_(len(changes.entry) <= 5)
- self.assert_(isinstance(changes.entry[0], gdata.docs.data.Change))
+ self.assertTrue(isinstance(changes, gdata.docs.data.ChangeFeed))
+ self.assertTrue(len(changes.entry) <= 5)
+ self.assertTrue(isinstance(changes.entry[0], gdata.docs.data.Change))
def testDeleteResourceCreatesNewChange(self):
"""Ensure that deleting a resource causes a new change entry."""
@@ -515,7 +515,7 @@
self._delete(self.resource)
time.sleep(10)
changes = self.client.GetChanges(max_results=1)
- self.assert_(latest < changes.entry[0].changestamp.value)
+ self.assertTrue(latest < changes.entry[0].changestamp.value)
class MetadataTest(DocsTestCase):
@@ -536,7 +536,7 @@
def testMetadata(self):
metadata = self.client.GetMetadata()
- self.assert_(isinstance(metadata, gdata.docs.data.Metadata))
+ self.assertTrue(isinstance(metadata, gdata.docs.data.Metadata))
self.assertNotEqual(int(metadata.quota_bytes_total.text), 0)
self.assertEqual(int(metadata.quota_bytes_used.text), 0)
self.assertEqual(int(metadata.quota_bytes_used_in_trash.text), 0)
@@ -548,7 +548,7 @@
def suite():
suite = unittest.TestSuite()
- for key, value in RESOURCES.iteritems():
+ for key, value in RESOURCES.items():
for case in [ResourcesTest, AclTest, RevisionsTest, ChangesTest]:
tests = unittest.TestLoader().loadTestsFromTestCase(case)
for test in tests:
--- ./tests/gdata_tests/docs/data_test.py (original)
+++ ./tests/gdata_tests/docs/data_test.py (refactored)
@@ -33,26 +33,26 @@
gdata.docs.data.Resource)
def testToAndFromStringDocsEntry(self):
- self.assert_(isinstance(self.entry, gdata.docs.data.Resource))
+ self.assertTrue(isinstance(self.entry, gdata.docs.data.Resource))
self.assertEqual(self.entry.GetResourceType(), 'spreadsheet')
- self.assert_(isinstance(self.entry.last_viewed, gdata.docs.data.LastViewed))
+ self.assertTrue(isinstance(self.entry.last_viewed, gdata.docs.data.LastViewed))
self.assertEqual(self.entry.last_viewed.text, '2009-03-05T07:48:21.493Z')
- self.assert_(
+ self.assertTrue(
isinstance(self.entry.last_modified_by, gdata.docs.data.LastModifiedBy))
self.assertEqual(
self.entry.last_modified_by.email.text, 'test.user@gmail.com')
self.assertEqual(self.entry.last_modified_by.name.text, 'test.user')
- self.assert_(isinstance(self.entry.resource_id, gdata.docs.data.ResourceId))
+ self.assertTrue(isinstance(self.entry.resource_id, gdata.docs.data.ResourceId))
self.assertEqual(self.entry.resource_id.text,
'spreadsheet:supercalifragilisticexpealidocious')
- self.assert_(isinstance(self.entry.writers_can_invite,
+ self.assertTrue(isinstance(self.entry.writers_can_invite,
gdata.docs.data.WritersCanInvite))
self.assertEqual(self.entry.writers_can_invite.value, 'true')
- self.assert_(isinstance(self.entry.quota_bytes_used,
+ self.assertTrue(isinstance(self.entry.quota_bytes_used,
gdata.docs.data.QuotaBytesUsed))
self.assertEqual(self.entry.quota_bytes_used.text, '1000')
self.assertEqual(len(self.entry.feed_link), 2)
- self.assert_(isinstance(self.entry.feed_link[0], gdata.data.FeedLink))
+ self.assertTrue(isinstance(self.entry.feed_link[0], gdata.data.FeedLink))
self.assertEqual(
self.entry.GetAclFeedLink().href,
@@ -79,30 +79,30 @@
gdata.docs.data.AclEntry)
def testToAndFromString(self):
- self.assert_(isinstance(self.acl_entry, gdata.docs.data.AclEntry))
- self.assert_(isinstance(self.acl_entry.role, gdata.acl.data.AclRole))
- self.assert_(isinstance(self.acl_entry.scope, gdata.acl.data.AclScope))
+ self.assertTrue(isinstance(self.acl_entry, gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(self.acl_entry.role, gdata.acl.data.AclRole))
+ self.assertTrue(isinstance(self.acl_entry.scope, gdata.acl.data.AclScope))
self.assertEqual(self.acl_entry.scope.value, 'user@gmail.com')
self.assertEqual(self.acl_entry.scope.type, 'user')
self.assertEqual(self.acl_entry.role.value, 'writer')
acl_entry_str = str(self.acl_entry)
new_acl_entry = atom.core.parse(acl_entry_str, gdata.docs.data.AclEntry)
- self.assert_(isinstance(new_acl_entry, gdata.docs.data.AclEntry))
- self.assert_(isinstance(new_acl_entry.role, gdata.acl.data.AclRole))
- self.assert_(isinstance(new_acl_entry.scope, gdata.acl.data.AclScope))
+ self.assertTrue(isinstance(new_acl_entry, gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(new_acl_entry.role, gdata.acl.data.AclRole))
+ self.assertTrue(isinstance(new_acl_entry.scope, gdata.acl.data.AclScope))
self.assertEqual(new_acl_entry.scope.value, self.acl_entry.scope.value)
self.assertEqual(new_acl_entry.scope.type, self.acl_entry.scope.type)
self.assertEqual(new_acl_entry.role.value, self.acl_entry.role.value)
def testToAndFromStringWithKey(self):
- self.assert_(isinstance(self.acl_entry_withkey, gdata.docs.data.AclEntry))
- self.assert_(self.acl_entry_withkey.role is None)
- self.assert_(isinstance(self.acl_entry_withkey.with_key,
+ self.assertTrue(isinstance(self.acl_entry_withkey, gdata.docs.data.AclEntry))
+ self.assertTrue(self.acl_entry_withkey.role is None)
+ self.assertTrue(isinstance(self.acl_entry_withkey.with_key,
gdata.acl.data.AclWithKey))
- self.assert_(isinstance(self.acl_entry_withkey.with_key.role,
+ self.assertTrue(isinstance(self.acl_entry_withkey.with_key.role,
gdata.acl.data.AclRole))
- self.assert_(isinstance(self.acl_entry_withkey.scope,
+ self.assertTrue(isinstance(self.acl_entry_withkey.scope,
gdata.acl.data.AclScope))
self.assertEqual(self.acl_entry_withkey.with_key.key, 'somekey')
self.assertEqual(self.acl_entry_withkey.with_key.role.value, 'writer')
@@ -112,13 +112,13 @@
acl_entry_withkey_str = str(self.acl_entry_withkey)
new_acl_entry_withkey = atom.core.parse(acl_entry_withkey_str,
gdata.docs.data.AclEntry)
- self.assert_(isinstance(new_acl_entry_withkey, gdata.docs.data.AclEntry))
- self.assert_(new_acl_entry_withkey.role is None)
- self.assert_(isinstance(new_acl_entry_withkey.with_key,
+ self.assertTrue(isinstance(new_acl_entry_withkey, gdata.docs.data.AclEntry))
+ self.assertTrue(new_acl_entrRefactoringTool: Refactored ./tests/gdata_tests/data_test.py
y_withkey.role is None)
+ self.assertTrue(isinstance(new_acl_entry_withkey.with_key,
gdata.acl.data.AclWithKey))
- self.assert_(isinstance(new_acl_entry_withkey.with_key.role,
+ self.assertTrue(isinstance(new_acl_entry_withkey.with_key.role,
gdata.acl.data.AclRole))
- self.assert_(isinstance(new_acl_entry_withkey.scope,
+ self.assertTrue(isinstance(new_acl_entry_withkey.scope,
gdata.acl.data.AclScope))
self.assertEqual(new_acl_entry_withkey.with_key.key,
self.acl_entry_withkey.with_key.key)
@@ -136,9 +136,9 @@
acl_entry = gdata.docs.DocumentListAclEntry(category=[cat])
acl_entry.scope = gdata.docs.Scope(value='user@gmail.com', type='user')
acl_entry.role = gdata.docs.Role(value='writer')
- self.assert_(isinstance(acl_entry, gdata.docs.DocumentListAclEntry))
- self.assert_(isinstance(acl_entry.role, gdata.docs.Role))
- self.assert_(isinstance(acl_entry.scope, gdata.docs.Scope))
+ self.assertTrue(isinstance(acl_entry, gdata.docs.DocumentListAclEntry))
+ self.assertTrue(isinstance(acl_entry.role, gdata.docs.Role))
+ self.assertTrue(isinstance(acl_entry.scope, gdata.docs.Scope))
self.assertEqual(acl_entry.scope.value, 'user@gmail.com')
self.assertEqual(acl_entry.scope.type, 'user')
self.assertEqual(acl_entry.role.value, 'writer')
@@ -160,29 +160,29 @@
def testToAndFromString(self):
for entry in self.feed.entry:
- self.assert_(isinstance(entry, gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.data.AclEntry))
feed = atom.core.parse(str(self.feed), gdata.docs.data.AclFeed)
for entry in feed.entry:
- self.assert_(isinstance(entry, gdata.docs.data.AclEntry))
+ self.assertTrue(isinstance(entry, gdata.docs.data.AclEntry))
def testConvertActualData(self):
entries = self.feed.entry
- self.assert_(len(entries) == 2)
+ self.assertTrue(len(entries) == 2)
self.assertEqual(entries[0].title.text,
'Document Permission - user@gmail.com')
self.assertEqual(entries[0].role.value, 'owner')
self.assertEqual(entries[0].scope.type, 'user')
self.assertEqual(entries[0].scope.value, 'user@gmail.com')
- self.assert_(entries[0].GetSelfLink() is not None)
- self.assert_(entries[0].GetEditLink() is not None)
+ self.assertTrue(entries[0].GetSelfLink() is not None)
+ self.assertTrue(entries[0].GetEditLink() is not None)
self.assertEqual(entries[1].title.text,
'Document Permission - user2@google.com')
self.assertEqual(entries[1].role.value, 'writer')
self.assertEqual(entries[1].scope.type, 'domain')
self.assertEqual(entries[1].scope.value, 'google.com')
- self.assert_(entries[1].GetSelfLink() is not None)
- self.assert_(entries[1].GetEditLink() is not None)
+ self.assertTrue(entries[1].GetSelfLink() is not None)
+ self.assertTrue(entries[1].GetEditLink() is not None)
class RevisionFeedTest(unittest.TestCase):
@@ -193,15 +193,15 @@
def testToAndFromString(self):
for entry in self.feed.entry:
- self.assert_(isinstance(entry, gdata.docs.data.Revision))
+ self.assertTrue(isinstance(entry, gdata.docs.data.Revision))
feed = atom.core.parse(str(self.feed), gdata.docs.data.RevisionFeed)
for entry in feed.entry:
- self.assert_(isinstance(entry, gdata.docs.data.Revision))
+ self.assertTrue(isinstance(entry, gdata.docs.data.Revision))
def testConvertActualData(self):
entries = self.feed.entry
- self.assert_(len(entries) == 1)
+ self.assertTrue(len(entries) == 1)
self.assertEqual(entries[0].title.text, 'Revision 2')
self.assertEqual(entries[0].publish.value, 'true')
self.assertEqual(entries[0].publish_auto.value, 'true')
--- ./tests/gdata_tests/data_test.py (original)
+++ ./tests/gdata_tests/data_test.py (refactored)
@@ -86,10 +86,10 @@
def testToAndFromString(self):
self.start_index.text = '1'
- self.assert_(self.start_index.text == '1')
+ self.assertTrue(self.start_index.text == '1')
new_start_index = parse(self.start_index.ToString(),
gdata.data.StartIndex)
- self.assert_(self.start_index.text == new_start_index.text)
+ self.assertTrue(self.start_index.text == new_start_index.text)
class ItemsPerPageTest(unittest.TestCase):
@@ -99,10 +99,10 @@
def testToAndFromString(self):
self.items_per_page.text = '10'
- self.assert_(self.items_per_page.text == '10')
+ self.assertTrue(self.items_per_page.text == '10')
new_items_per_page = parse(self.items_per_page.ToString(),
gdata.data.ItemsPerPage)
- self.assert_(self.items_per_page.text == new_items_per_page.text)
+ self.assertTrue(self.items_per_page.text == new_items_per_page.text)
class GDataEntryTest(unittest.TestCase):
@@ -110,14 +110,14 @@
def testIdShouldBeCleaned(self):
entry = parse(XML_ENTRY_1, gdata.data.GDEntry)
tree = parse(XML_ENTRY_1, atom.core.XmlElement)
- self.assert_(tree.get_elements('id',
+ self.assertTrue(tree.get_elements('id',
'http://www.w3.org/2005/Atom')[0].text != entry.get_id())
self.assertEqual(entry.get_id(), 'http://www.google.com/test/id/url')
def testGeneratorShouldBeCleaned(self):
feed = parse(test_data.GBASE_FEED, gdata.data.GDFeed)
tree = parse(test_data.GBASE_FEED, atom.core.XmlElement)
- self.assert_(tree.get_elements('generator',
+ self.assertTrue(tree.get_elements('generator',
'http://www.w3.org/2005/Atom')[0].text != feed.get_generator())
self.assertEqual(feed.get_generator(), 'GoogleBase')
@@ -134,20 +134,20 @@
self.entry = parse(XML_ENTRY_1, gdata.data.GDEntry)
def testLinkFinderGetsLicenseLink(self):
- self.assertEquals(isinstance(self.entry.FindLicenseLink(), str),
+ self.assertEqual(isinstance(self.entry.FindLicenseLink(), str),
True)
- self.assertEquals(self.entry.FindLicenseLink(),
+ self.assertEqual(self.entry.FindLicenseLink(),
'http://creativecommons.org/licenses/by-nc/2.5/rdf')
def testLinkFinderGetsAlternateLink(self):
- self.assert_(isinstance(self.entry.FindAlternateLink(), str))
- self.assertEquals(self.entry.FindAlternateLink(),
+ self.assertTrue(isinstance(self.entry.FindAlternateLink(), str))
+ self.assertEqual(self.entry.FindAlternateLink(),
'http://www.provider-host.com/123456789')
def testFindAclLink(self):
entry = gdata.data.GDEntry()
- self.assert_(entry.get_acl_link() is None)
- self.assert_(entry.find_acl_link() is None)
+ self.assertTrue(entry.get_acl_link() is None)
+ self.assertTrue(entry.find_acl_link() is None)
entry.link.append(atom.data.Link(
rel=gdata.data.ACL_REL, href='http://example.com/acl'))
@@ -155,8 +155,8 @@
self.assertEqual(entry.find_acl_link(), 'http://example.com/acl')
del entry.link[0]
- self.assert_(entry.get_acl_link() is None)
- self.assert_(entry.find_acl_link() is None)
+ self.assertTrue(entry.get_acl_link() is None)
+ self.assertTrue(entry.find_acl_link() is None)
# We should also find an ACL link which is a feed_link.
entry.feed_link = [gdata.data.FeedLink(
@@ -169,10 +169,10 @@
def testCorrectConversionToElementTree(self):
test_feed = parse(test_data.GBASE_FEED, gdata.data.GDFeed)
- self.assert_(test_feed.total_results is not None)
- self.assert_(test_feed.get_elements('totalResults',
+ self.assertTrue(test_feed.total_results is not None)
+ self.assertTrue(test_feed.get_elements('totalResults',
'http://a9.com/-/spec/opensearchrss/1.0/') is not None)
- self.assert_(len(test_feed.get_elements('totalResults',
+ self.assertTrue(len(test_feed.get_elements('totalResults',
'http://a9.com/-/spec/opensearchrss/1.0/')) > 0)
def testAllowsEmptyId(self):
@@ -188,23 +188,23 @@
def testCorrectConversionFromAndToString(self):
batch_entry = parse(test_data.BATCH_ENTRY, gdata.data.BatchEntry)
- self.assertEquals(batch_entry.batch_id.text, 'itemB')
- self.assertEquals(batch_entry.id.text,
+ self.assertEqual(batch_entry.batch_id.text, 'itemB')
+ self.assertEqual(batch_entry.id.text,
'http://www.google.com/base/feeds/items/'
'2173859253842813008')
- self.assertEquals(batch_entry.batch_operation.type, 'insert')
- self.assertEquals(batch_entry.batch_status.code, '201')
- self.assertEquals(batch_entry.batch_status.reason, 'Created')
+ self.assertEqual(batch_entry.batch_operation.type, 'insert')
+ self.assertEqual(batch_entry.batch_status.code, '201')
+ self.assertEqual(batch_entry.batch_status.reason, 'Created')
new_entry = parse(str(batch_entry), gdata.data.BatchEntry)
- self.assertEquals(batch_entry.batch_id.text, new_entry.batch_id.text)
- self.assertEquals(batch_entry.id.text, new_entry.id.text)
- self.assertEquals(batch_entry.batch_operation.type,
+ self.assertEqual(batch_entry.batch_id.text, new_entry.batch_id.text)
+ self.assertEqual(batch_entry.id.text, new_entry.id.text)
+ self.assertEqual(batch_entry.batch_operation.type,
new_entry.batch_operation.type)
- self.assertEquals(batch_entry.batch_status.code,
+ self.assertEqual(batch_entry.batch_status.code,
new_entry.batch_status.code)
- self.assertEquals(batch_entry.batch_status.reason,
+ self.assertEqual(batch_entry.batch_status.reason,
new_entry.batch_status.reason)
@@ -218,44 +218,44 @@
def testConvertRequestFeed(self):
batch_feed = parse(test_data.BATCH_FEED_REQUEST, gdata.data.BatchFeed)
- self.assertEquals(len(batch_feed.entry), 4)
+ self.assertEqual(len(batch_feed.entry), 4)
for entry in batch_feed.entry:
- self.assert_(isinstance(entry, gdata.data.BatchEntry))
- self.assertEquals(batch_feed.title.text, 'My Batch Feed')
+ self.assertTrue(isinstance(entry, gdata.data.BatchEntry))
+ self.assertEqual(batch_feed.title.text, 'My Batch Feed')
new_feed = parse(batch_feed.to_string(), gdata.data.BatchFeed)
- self.assertEquals(len(new_feed.entry), 4)
+ self.assertEqual(len(new_feed.entry), 4)
for entry in new_feed.entry:
- self.assert_(isinstance(entry, gdata.data.BatchEntry))
- self.assertEquals(new_feed.title.text, 'My Batch Feed')
+ self.assertTrue(isinstance(entry, gdata.data.BatchEntry))
+ self.assertEqual(new_feed.title.text, 'My Batch Feed')
def testConvertResultFeed(self):
batch_feed = parse(test_data.BATCH_FEED_RESULT, gdata.data.BatchFeed)
- self.assertEquals(len(batch_feed.entry), 4)
+ self.assertEqual(len(batch_feed.entry), 4)
for entry in batch_feed.entry:
- self.assert_(isinstance(entry, gdata.data.BatchEntry))
+ self.assertTrue(isinstance(entry, gdata.data.BatchEntry))
if entry.id.text == ('http://www.google.com/base/feeds/items/'
'2173859253842813008'):
- self.assertEquals(entry.batch_operation.type, 'insert')
- self.assertEquals(entry.batch_id.text, 'itemB')
- self.assertEquals(entry.batch_status.code, '201')
- self.assertEquals(entry.batch_status.reason, 'Created')
- self.assertEquals(batch_feed.title.text, 'My Batch')
+ self.assertEqual(entry.batch_operation.type, 'insert')
+ self.assertEqual(entry.batch_id.text, 'itemB')
+ self.assertEqual(entry.batch_status.code, '201')
+ self.assertEqual(entry.batch_status.reason, 'Created')
+ self.assertEqual(batch_feed.title.text, 'My Batch')
new_feed = parse(str(batch_feed), gdata.data.BatchFeed)
- self.assertEquals(len(new_feed.entry), 4)
+ self.assertEqual(len(new_feed.entry), 4)
for entry in new_feed.entry:
- self.assert_(isinstance(entry, gdata.data.BatchEntry))
+ self.assertTrue(isinstance(entry, gdata.data.BatchEntry))
if entry.id.text == ('http://www.google.com/base/feeds/items/'
'2173859253842813008'):
- self.assertEquals(entry.batch_operation.type, 'insert')
- self.assertEquals(entry.batch_id.text, 'itemB')
- self.assertEquals(entry.batch_status.code, '201')
- self.assertEquals(entry.batch_status.reason, 'Created')
- self.assertEquals(new_feed.title.text, 'My Batch')
+ self.assertEqual(entry.batch_operation.type, 'insert')
+ self.assertEqual(entry.batch_id.text, 'itemB')
+ self.assertEqual(entry.batch_status.code, '201')
+ self.assertEqual(entry.batch_status.reason, 'Created')
+ self.assertEqual(new_feed.title.text, 'My Batch')
def testAddBatchEntry(self):
try:
@@ -266,59 +266,59 @@
new_entry = self.batch_feed.AddBatchEntry(
id_url_string='http://example.com/1')
- self.assertEquals(len(self.batch_feed.entry), 1)
- self.assertEquals(self.batch_feed.entry[0].get_id(),
+ self.assertEqual(len(self.batch_feed.entry), 1)
+ self.assertEqual(self.batch_feed.entry[0].get_id(),
'http://example.com/1')
- self.assertEquals(self.batch_feed.entry[0].batch_id.text, '0')
- self.assertEquals(new_entry.id.text, 'http://example.com/1')
- self.assertEquals(new_entry.batch_id.text, '0')
+ self.assertEqual(self.batch_feed.entry[0].batch_id.text, '0')
+ self.assertEqual(new_entry.id.text, 'http://example.com/1')
+ self.assertEqual(new_entry.batch_id.text, '0')
to_add = gdata.data.BatchEntry(id=atom.data.Id(text='originalId'))
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
batch_id_string='foo')
- self.assertEquals(new_entry.batch_id.text, 'foo')
- self.assertEquals(new_entry.id.text, 'originalId')
+ self.assertEqual(new_entry.batch_id.text, 'foo')
+ self.assertEqual(new_entry.id.text, 'originalId')
to_add = gdata.data.BatchEntry(id=atom.data.Id(text='originalId'),
batch_id=gdata.data.BatchId(text='bar'))
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
id_url_string='newId',
batch_id_string='foo')
- self.assertEquals(new_entry.batch_id.text, 'foo')
- self.assertEquals(new_entry.id.text, 'originalId')
+ self.assertEqual(new_entry.batch_id.text, 'foo')
+ self.assertEqual(new_entry.id.text, 'originalId')
to_add = gdata.data.BatchEntry(id=atom.data.Id(text='originalId'),
batch_id=gdata.data.BatchId(text='bar'))
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
id_url_string='newId')
- self.assertEquals(new_entry.batch_id.text, 'bar')
- self.assertEquals(new_entry.id.text, 'originalId')
+ self.assertEqual(new_entry.batch_id.text, 'bar')
+ self.assertEqual(new_entry.id.text, 'originalId')
to_add = gdata.data.BatchEntry(id=atom.data.Id(text='originalId'),
batch_id=gdata.data.BatchId(text='bar'),
batch_operation=gdata.data.BatchOperation(
type=gdata.data.BATCH_INSERT))
- self.assertEquals(to_add.batch_operation.type, gdata.data.BATCH_INSERT)
+ self.assertEqual(to_add.batch_operation.type, gdata.data.BATCH_INSERT)
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
id_url_string='newId', batch_id_string='foo',
operation_string=gdata.data.BATCH_UPDATE)
- self.assertEquals(new_entry.batch_operation.type, gdata.data.BATCH_UPDATE)
+ self.assertEqual(new_entry.batch_operation.type, gdata.data.BATCH_UPDATE)
def testAddInsert(self):
first_entry = gdata.data.BatchEntry(
id=atom.data.Id(text='http://example.com/1'), text='This is a test1')
self.batch_feed.AddInsert(first_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.data.BATCH_INSERT)
- self.assertEquals(self.batch_feed.entry[0].batch_id.text, '0')
+ self.assertEqual(self.batch_feed.entry[0].batch_id.text, '0')
second_entry = gdata.data.BatchEntry(
id=atom.data.Id(text='http://example.com/2'), text='This is a test2')
self.batch_feed.AddInsert(second_entry, batch_id_string='foo')
- self.assertEquals(self.batch_feed.entry[1].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[1].batch_operation.type,
gdata.data.BATCH_INSERT)
- self.assertEquals(self.batch_feed.entry[1].batch_id.text, 'foo')
+ self.assertEqual(self.batch_feed.entry[1].batch_id.text, 'foo')
third_entry = gdata.data.BatchEntry(
id=atom.data.Id(text='http://example.com/3'), text='This is a test3')
@@ -328,44 +328,44 @@
self.batch_feed.AddInsert(third_entry)
# The batch entry should not have the original operation, it should
# have been changed to an insert.
- self.assertEquals(self.batch_feed.entry[2].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[2].batch_operation.type,
gdata.data.BATCH_INSERT)
- self.assertEquals(self.batch_feed.entry[2].batch_id.text, '2')
+ self.assertEqual(self.batch_feed.entry[2].batch_id.text, '2')
def testAddDelete(self):
# Try deleting an entry
delete_entry = gdata.data.BatchEntry(
id=atom.data.Id(text='http://example.com/1'), text='This is a test')
self.batch_feed.AddDelete(entry=delete_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.data.BATCH_DELETE)
- self.assertEquals(self.batch_feed.entry[0].get_id(),
+ self.assertEqual(self.batch_feed.entry[0].get_id(),
'http://example.com/1')
- self.assertEquals(self.batch_feed.entry[0].text, 'This is a test')
+ self.assertEqual(self.batch_feed.entry[0].text, 'This is a test')
# Try deleting a URL
self.batch_feed.AddDelete(url_string='http://example.com/2')
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.data.BATCH_DELETE)
- self.assertEquals(self.batch_feed.entry[1].id.text,
+ self.assertEqual(self.batch_feed.entry[1].id.text,
'http://example.com/2')
- self.assert_(self.batch_feed.entry[1].text is None)
+ self.assertTrue(self.batch_feed.entry[1].text is None)
def testAddQuery(self):
# Try querying with an existing batch entry
delete_entry = gdata.data.BatchEntry(
id=atom.data.Id(text='http://example.com/1'))
self.batch_feed.AddQuery(entry=delete_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.data.BATCH_QUERY)
- self.assertEquals(self.batch_feed.entry[0].get_id(),
+ self.assertEqual(self.batch_feed.entry[0].get_id(),
'http://example.com/1')
# Try querying a URL
self.batch_feed.AddQuery(url_string='http://example.com/2')
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.data.BATCH_QUERY)
- self.assertEquals(self.batch_feed.entry[1].id.text,
+ self.assertEqual(self.batch_feed.entry[1].id.text,
'http://example.com/2')
def testAddUpdate(self):
@@ -373,11 +373,11 @@
delete_entry = gdata.data.BatchEntry(
id=atom.data.Id(text='http://example.com/1'), text='This is a test')
self.batch_feed.AddUpdate(entry=delete_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.data.BATCH_UPDATE)
- self.assertEquals(self.batch_feed.entry[0].get_id(),
+ self.assertEqual(self.batch_feed.entry[0].get_id(),
'http://example.com/1')
- self.assertEquals(self.batch_feed.entry[0].text, 'This is a test')
+ self.assertEqual(self.batch_feed.entry[0].text, 'RefactoringTool: No changes to ./tests/gdata_tests/data_smoke_test.py
RefactoringTool: Refactored ./tests/gdata_tests/core_test.py
This is a test')
class ExtendedPropertyTest(unittest.TestCase):
@@ -386,27 +386,27 @@
ep = gdata.data.ExtendedProperty(name='blobby')
ep.SetXmlBlob('')
extension = ep.GetXmlBlob()
- self.assertEquals(extension.tag, 'some_xml')
- self.assert_(extension.namespace is None)
- self.assertEquals(extension.attributes['attr'], 'test')
+ self.assertEqual(extension.tag, 'some_xml')
+ self.assertTrue(extension.namespace is None)
+ self.assertEqual(extension.attributes['attr'], 'test')
ep2 = parse(ep.ToString(), gdata.data.ExtendedProperty)
extension = ep2.GetXmlBlob()
- self.assertEquals(extension.tag, 'some_xml')
- self.assert_(extension.namespace is None)
- self.assertEquals(extension.attributes['attr'], 'test')
+ self.assertEqual(extension.tag, 'some_xml')
+ self.assertTrue(extension.namespace is None)
+ self.assertEqual(extension.attributes['attr'], 'test')
def testGettersShouldReturnNoneWithNoBlob(self):
ep = gdata.data.ExtendedProperty(name='no blob')
- self.assert_(ep.GetXmlBlob() is None)
+ self.assertTrue(ep.GetXmlBlob() is None)
def testGettersReturnCorrectTypes(self):
ep = gdata.data.ExtendedProperty(name='has blob')
ep.SetXmlBlob('')
- self.assert_(isinstance(ep.GetXmlBlob(),
+ self.assertTrue(isinstance(ep.GetXmlBlob(),
atom.core.XmlElement))
- self.assert_(isinstance(ep.GetXmlBlob().to_string(), str))
+ self.assertTrue(isinstance(ep.GetXmlBlob().to_string(), str))
class FeedLinkTest(unittest.TestCase):
@@ -415,7 +415,7 @@
link = parse(
'',
gdata.data.FeedLink)
- self.assert_(isinstance(link, gdata.data.FeedLink))
+ self.assertTrue(isinstance(link, gdata.data.FeedLink))
self.assertEqual(link.count_hint, '5')
@@ -429,7 +429,7 @@
'Elizabeth Bennet\'s Contacts')
self.assertEqual(len(feed.entry), 2)
for entry in feed.entry:
- self.assert_(isinstance(entry, gdata.data.GDEntry))
+ self.assertTrue(isinstance(entry, gdata.data.GDEntry))
self.assertEqual(feed.entry[0].GetElements('title')[0].text,
'Fitzwilliam')
self.assertEqual(feed.entry[0].get_elements('id')[0].text,
@@ -451,15 +451,15 @@
def test_constructor_defauls(self):
feed = gdata.data.GDFeed()
- self.assert_(feed.etag is None)
+ self.assertTrue(feed.etag is None)
self.assertEqual(feed.link, [])
self.assertEqual(feed.entry, [])
entry = gdata.data.GDEntry()
- self.assert_(entry.etag is None)
+ self.assertTrue(entry.etag is None)
self.assertEqual(entry.link, [])
link = atom.data.Link()
- self.assert_(link.href is None)
- self.assert_(link.rel is None)
+ self.assertTrue(link.href is None)
+ self.assertTrue(link.rel is None)
link1 = atom.data.Link(href='http://example.com', rel='test')
self.assertEqual(link1.href, 'http://example.com')
self.assertEqual(link1.rel, 'test')
--- ./tests/gdata_tests/core_test.py (original)
+++ ./tests/gdata_tests/core_test.py (refactored)
@@ -50,7 +50,7 @@
'US","Maps"],"thumbnail": {"default": "http://i.ytimg.com/vi/hYB0mn5zh'
'2c/default.jpg","hqDefault": "http://i.ytimg.com/vi/hYB0mn5zh2c/hqdef'
'ault.jpg"},"player": {"default": "http://www.youtube.com/watch?v'
- '\u003dhYB0mn5zh2c"},"content": {"1": "rtsp://v5.cache3.c.youtube.com/'
+ '\\u003dhYB0mn5zh2c"},"content": {"1": "rtsp://v5.cache3.c.youtube.com/'
'CiILENy.../0/0/0/video.3gp","5": "http://www.youtube.com/v/hYB0mn5zh2'
'c?f...","6": "rtsp://v1.cache1.c.youtube.com/CiILENy.../0/0/0/video.3'
'gp"},"duration": 2840,"rating": 4.63,"ratingCount": 68,"viewCount": 2'
@@ -64,7 +64,7 @@
json = ('{"media$group":{"media$credit":[{"$t":"GoogleDevelopers", '
'"role":"uploader", "scheme":"urn:youtube"}]}}')
jsonc_obj = gdata.core.parse_json(json)
- self.assert_(isinstance(jsonc_obj, gdata.core.Jsonc))
+ self.assertTrue(isinstance(jsonc_obj, gdata.core.Jsonc))
raw = gdata.core._convert_to_object(jsonc_obj)
self.assertEqual(raw['media$group']['media$credit'][0]['$t'],
'GoogleDevelopers')
@@ -91,10 +91,10 @@
def test_pretty_print(self):
x = gdata.core.Jsonc(x=1, y=2, z=3)
pretty = gdata.core.prettify_jsonc(x)
- self.assert_(isinstance(pretty, (str, unicode)))
+ self.assertTrue(isinstance(pretty, str))
pretty = gdata.core.prettify_jsonc(x, 4)
- self.assert_(isinstance(pretty, (str, unicode)))
+ self.assertTrue(isinstance(pretty, str))
class MemberNameConversionTest(unittest.TestCase):
@@ -126,17 +126,17 @@
def check_video_json(self, x):
"""Validates a JsoncObject similar to VIDEO_EXAMPLE."""
- self.assert_(isinstance(x._dict, dict))
- self.assert_(isinstance(x.data, gdata.core.Jsonc))
- self.assert_(isinstance(x._dict['data'], gdata.core.Jsonc))
- self.assert_(isinstance(x.data._dict, dict))
- self.assert_(isinstance(x._dict['data']._dict, dict))
- self.assert_(isinstance(x._dict['apiVersion'], (str, unicode)))
- self.assert_(isinstance(x.api_version, (str, unicode)))
- self.assert_(isinstance(x.data._dict['items'], list))
- self.assert_(isinstance(x.data.items[0]._dict['commentCount'],
- (int, long)))
- self.assert_(isinstance(x.data.items[0].favorite_count, (int, long)))
+ self.assertTrue(isinstance(x._dict, dict))
+ self.assertTrue(isinstance(x.data, gdata.core.Jsonc))
+ self.assertTrue(isinstance(x._dict['data'], gdata.core.Jsonc))
+ self.assertTrue(isinstance(x.data._dict, dict))
+ self.assertTrue(isinstance(x._dict['data']._dict, dict))
+ self.assertTrue(isinstance(x._dict['apiVersion'], str))
+ self.assertTrue(isinstance(x.api_version, str))
+ self.assertTrue(isinstance(x.data._dict['items'], list))
+ self.assertTrue(isinstance(x.data.items[0]._dict['commentCount'],
+ int))
+ self.assertTrue(isinstance(x.data.items[0].favorite_count, int))
self.assertEqual(x.data.total_items, 800)
self.assertEqual(x._dict['data']._dict['totalItems'], 800)
self.assertEqual(x.data.items[0].view_count, 220101)
@@ -154,21 +154,21 @@
def test_convert_to_jsonc(self):
x = gdata.core._convert_to_jsonc(1)
- self.assert_(isinstance(x, (int, long)))
+ self.assertTrue(isinstance(x, int))
self.assertEqual(x, 1)
x = gdata.core._convert_to_jsonc([1, 'a'])
- self.assert_(isinstance(x, list))
+ self.assertTrue(isinstance(x, list))
self.assertEqual(len(x), 2)
- self.assert_(isinstance(x[0], (int, long)))
+ self.assertTrue(isinstance(x[0], int))
self.assertEqual(x[0], 1)
- self.assert_(isinstance(x[1], (str, unicode)))
+ self.assertTrue(isinstance(x[1], str))
self.assertEqual(x[1], 'a')
x = gdata.core._convert_to_jsonc([{'b': 1}, 'a'])
- self.assert_(isinstance(x, list))
+ self.assertTrue(isinstance(x, list))
self.assertEqual(len(x), 2)
- self.assert_(isinstance(x[0], gdata.core.Jsonc))
+ self.assertTrue(isinstance(x[0], gdata.core.Jsonc))
self.assertEqual(x[0].b, 1)
def test_non_json_members(self):
@@ -186,24 +186,24 @@
self.assertEqual(gdata.core.jsonc_to_string(x).find('B'), -1)
# We should find a 'b' becuse we don't consider names of dict keys in
# the constructor as aliases to camelCase names.
- self.assert_(not gdata.core.jsonc_to_string(x).find('b') == -1)
+ self.assertTrue(not gdata.core.jsonc_to_string(x).find('b') == -1)
def test_constructor(self):
x = gdata.core.Jsonc(a=[{'x': 'y'}, 2])
- self.assert_(isinstance(x, gdata.core.Jsonc))
- self.assert_(isinstance(x.a, list))
- self.assert_(isinstance(x.a[0], gdata.core.Jsonc))
+ self.assertTrue(isinstance(x, gdata.core.Jsonc))
+ self.assertTrue(isinstance(x.a, list))
+ self.assertTrue(isinstance(x.a[0], gdata.core.Jsonc))
self.assertEqual(x.a[0].x, 'y')
self.assertEqual(x.a[1], 2)
def test_read_json(self):
x = gdata.core.parse_json(PLAYLISRefactoringTool: No changes to ./tests/gdata_tests/contentforshopping_test.py
RefactoringTool: Refactored ./tests/gdata_tests/contacts_test.py
T_EXAMPLE)
- self.assert_(isinstance(x._dict, dict))
+ self.assertTrue(isinstance(x._dict, dict))
self.assertEqual(x._dict['apiVersion'], '2.0')
self.assertEqual(x.api_version, '2.0')
x = gdata.core.parse_json(VIDEO_EXAMPLE)
- self.assert_(isinstance(x._dict, dict))
+ self.assertTrue(isinstance(x._dict, dict))
self.assertEqual(x._dict['apiVersion'], '2.0')
self.assertEqual(x.api_version, '2.0')
@@ -311,21 +311,21 @@
x = build_test_object()
# Check for expected members using different access patterns.
- self.assert_(isinstance(x._dict, dict))
- self.assert_(isinstance(x['data'], gdata.core.Jsonc))
- self.assert_(isinstance(x._dict['data'], gdata.core.Jsonc))
- self.assert_(isinstance(x['data']._dict, dict))
- self.assert_(isinstance(x._dict['data']._dict, dict))
- self.assert_(isinstance(x['apiVersion'], (str, unicode)))
+ self.assertTrue(isinstance(x._dict, dict))
+ self.assertTrue(isinstance(x['data'], gdata.core.Jsonc))
+ self.assertTrue(isinstance(x._dict['data'], gdata.core.Jsonc))
+ self.assertTrue(isinstance(x['data']._dict, dict))
+ self.assertTrue(isinstance(x._dict['data']._dict, dict))
+ self.assertTrue(isinstance(x['apiVersion'], str))
try:
x['api_version']
self.fail('Should not find using Python style name')
except KeyError:
pass
- self.assert_(isinstance(x.data['items'], list))
- self.assert_(isinstance(x.data['items'][0]._dict['commentCount'],
- (int, long)))
- self.assert_(isinstance(x['data'].items[0]['favoriteCount'], (int, long)))
+ self.assertTrue(isinstance(x.data['items'], list))
+ self.assertTrue(isinstance(x.data['items'][0]._dict['commentCount'],
+ int))
+ self.assertTrue(isinstance(x['data'].items[0]['favoriteCount'], int))
self.assertEqual(x['data'].total_items, 800)
self.assertEqual(x['data']['totalItems'], 800)
self.assertEqual(x.data['items'][0]['viewCount'], 220101)
--- ./tests/gdata_tests/contacts_test.py (original)
+++ ./tests/gdata_tests/contacts_test.py (refactored)
@@ -29,55 +29,55 @@
self.entry = gdata.contacts.ContactEntryFromString(test_data.NEW_CONTACT)
def testParsingTestEntry(self):
- self.assertEquals(self.entry.title.text, 'Fitzgerald')
- self.assertEquals(len(self.entry.email), 2)
+ self.assertEqual(self.entry.title.text, 'Fitzgerald')
+ self.assertEqual(len(self.entry.email), 2)
for email in self.entry.email:
if email.rel == 'http://schemas.google.com/g/2005#work':
- self.assertEquals(email.address, 'liz@gmail.com')
+ self.assertEqual(email.address, 'liz@gmail.com')
elif email.rel == 'http://schemas.google.com/g/2005#home':
- self.assertEquals(email.address, 'liz@example.org')
- self.assertEquals(len(self.entry.phone_number), 3)
- self.assertEquals(len(self.entry.postal_address), 1)
- self.assertEquals(self.entry.postal_address[0].primary, 'true')
- self.assertEquals(self.entry.postal_address[0].text,
+ self.assertEqual(email.address, 'liz@example.org')
+ self.assertEqual(len(self.entry.phone_number), 3)
+ self.assertEqual(len(self.entry.postal_address), 1)
+ self.assertEqual(self.entry.postal_address[0].primary, 'true')
+ self.assertEqual(self.entry.postal_address[0].text,
'1600 Amphitheatre Pkwy Mountain View')
- self.assertEquals(len(self.entry.im), 1)
- self.assertEquals(len(self.entry.group_membership_info), 1)
- self.assertEquals(self.entry.group_membership_info[0].href,
+ self.assertEqual(len(self.entry.im), 1)
+ self.assertEqual(len(self.entry.group_membership_info), 1)
+ self.assertEqual(self.entry.group_membership_info[0].href,
'http://google.com/m8/feeds/groups/liz%40gmail.com/base/270f')
- self.assertEquals(self.entry.group_membership_info[0].deleted, 'false')
- self.assertEquals(len(self.entry.extended_property), 2)
- self.assertEquals(self.entry.extended_property[0].name, 'pet')
- self.assertEquals(self.entry.extended_property[0].value, 'hamster')
- self.assertEquals(self.entry.extended_property[1].name, 'cousine')
- self.assertEquals(
+ self.assertEqual(self.entry.group_membership_info[0].deleted, 'false')
+ self.assertEqual(len(self.entry.extended_property), 2)
+ self.assertEqual(self.entry.extended_property[0].name, 'pet')
+ self.assertEqual(self.entry.extended_property[0].value, 'hamster')
+ self.assertEqual(self.entry.extended_property[1].name, 'cousine')
+ self.assertEqual(
self.entry.extended_property[1].GetXmlBlobExtensionElement().tag,
'italian')
def testToAndFromString(self):
copied_entry = gdata.contacts.ContactEntryFromString(str(self.entry))
- self.assertEquals(copied_entry.title.text, 'Fitzgerald')
- self.assertEquals(len(copied_entry.email), 2)
+ self.assertEqual(copied_entry.title.text, 'Fitzgerald')
+ self.assertEqual(len(copied_entry.email), 2)
for email in copied_entry.email:
if email.rel == 'http://schemas.google.com/g/2005#work':
- self.assertEquals(email.address, 'liz@gmail.com')
+ self.assertEqual(email.address, 'liz@gmail.com')
elif email.rel == 'http://schemas.google.com/g/2005#home':
- self.assertEquals(email.address, 'liz@example.org')
- self.assertEquals(len(copied_entry.phone_number), 3)
- self.assertEquals(len(copied_entry.postal_address), 1)
- self.assertEquals(copied_entry.postal_address[0].primary, 'true')
- self.assertEquals(copied_entry.postal_address[0].text,
+ self.assertEqual(email.address, 'liz@example.org')
+ self.assertEqual(len(copied_entry.phone_number), 3)
+ self.assertEqual(len(copied_entry.postal_address), 1)
+ self.assertEqual(copied_entry.postal_address[0].primary, 'true')
+ self.assertEqual(copied_entry.postal_address[0].text,
'1600 Amphitheatre Pkwy Mountain View')
- self.assertEquals(len(copied_entry.im), 1)
- self.assertEquals(len(copied_entry.group_membership_info), 1)
- self.assertEquals(copied_entry.group_membership_info[0].href,
+ self.assertEqual(len(copied_entry.im), 1)
+ self.assertEqual(len(copied_entry.group_membership_info), 1)
+ self.assertEqual(copied_entry.group_membership_info[0].href,
'http://google.com/m8/feeds/groups/liz%40gmail.com/base/270f')
- self.assertEquals(copied_entry.group_membership_info[0].deleted, 'false')
- self.assertEquals(len(copied_entry.extended_property), 2)
- self.assertEquals(copied_entry.extended_property[0].name, 'pet')
- self.assertEquals(copied_entry.extended_property[0].value, 'hamster')
- self.assertEquals(copied_entry.extended_property[1].name, 'cousine')
- self.assertEquals(
+ self.assertEqual(copied_entry.group_membership_info[0].deleted, 'false')
+ self.assertEqual(len(copied_entry.extended_property), 2)
+ self.assertEqual(copied_entry.extended_property[0].name, 'pet')
+ self.assertEqual(copied_entry.extended_property[0].value, 'hamster')
+ self.assertEqual(copied_entry.extended_property[1].name, 'cousine')
+ self.assertEqual(
copied_entry.extended_property[1].GetXmlBlobExtensionElement().tag,
'italian')
@@ -102,20 +102,20 @@
# Generate and parse the XML for the new entry.
entry_copy = gdata.contacts.ContactEntryFromString(str(new_entry))
- self.assertEquals(entry_copy.title.text, new_entry.title.text)
- self.assertEquals(entry_copy.content.text, 'Test Notes')
- self.assertEquals(len(entry_copy.email), 1)
- self.assertEquals(entry_copy.email[0].rel, new_entry.email[0].rel)
- self.assertEquals(entry_copy.email[0].address, 'liz@gmail.com')
- self.assertEquals(len(entry_copy.phone_number), 1)
- self.assertEquals(entry_copy.phone_number[0].rel,
+ self.assertEqual(entry_copy.title.text, new_entry.title.text)
+ self.assertEqual(entry_copy.content.text, 'Test Notes')
+ self.assertEqual(len(entry_copy.email), 1)
+ self.assertEqual(entry_copy.email[0].rel, new_entry.email[0].rel)
+ self.assertEqual(entry_copy.email[0].address, 'liz@gmail.com')
+ self.assertEqual(len(entry_copy.phone_number), 1)
+ self.assertEqual(entry_copy.phone_number[0].rel,
new_entry.phone_number[0].rel)
- self.assertEquals(entry_copy.birthday.when, '2009-7-23')
- self.assertEquals(entry_copy.phone_number[0].text, '(206)555-1212')
- self.assertEquals(entry_copy.organization.org_name.text, 'TestCo.')
- self.assertEquals(len(entry_copy.extended_property), 2)
- self.assertEquals(entry_copy.extended_property[0].name, 'test')
- self.assertEquals(entry_copy.extended_property[0].value, '1234')
+ self.assertEqual(entry_copy.birthday.when, '2009-7-23')
+ self.assertEqual(entry_copy.phone_number[0].text, '(206)555-1212')
+ self.assertEqual(entry_copy.organization.org_name.text, 'TestCo.')
+ self.assertEqual(len(entry_copy.extended_property), 2)
+ self.assertEqual(entry_copy.extended_property[0].name, 'test')
+ self.assertEqual(entry_copy.extended_property[0].value, '1234')
class ContactsFeedTest(unittest.TestCase):
@@ -124,26 +124,26 @@
self.feed = gdata.contacts.ContactsFeedFromString(test_data.CONTACTS_FEED)
def testParsingTestFeed(self):
- self.assertEquals(self.feed.id.text,
+ self.assertEqual(self.feed.id.text,
'http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base')
- self.assertEquals(self.feed.title.text, 'Contacts')
- self.assertEquals(self.feed.total_results.text, '1')
- self.assertEquals(len(self.feed.entry), 1)
- self.assert_(isinstance(self.feed.entry[0], gdata.contacts.ContactEntry))
- self.assertEquals(self.feed.entry[0].GetPhotoLink().href,
+ self.assertEqual(self.feed.title.text, 'Contacts')
+ self.assertEqual(self.feed.total_results.text, '1')
+ self.assertEqual(len(self.feed.entry), 1)
+ self.assertTrue(isinstance(self.feed.entry[0], gdata.contacts.ContactEntry))
+ self.assertEqual(self.feed.entry[0].GetPhotoLink().href,
'http://google.com/m8/feeds/photos/media/liz%40gmail.com/c9012de')
- self.assertEquals(self.feed.entry[0].GetPhotoEditLink().href,
+ self.assertEqual(self.feed.entry[0].GetPhotoEditLink().href,
'http://www.google.com/m8/feeds/photos/media/liz%40gmail.com/'
'c9012de/photo4524')
def testToAndFromString(self):
copied_feed = gdata.contacts.ContactsFeedFromString(str(self.feed))
- self.assertEquals(copied_feed.id.text,
+ self.assertEqual(copied_feed.id.text,
'http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base')
- self.assertEquals(copied_feed.title.text, 'Contacts')
- self.assertEquals(copied_feed.total_results.text, '1')
- self.assertEquals(len(copied_feed.entry), 1)
- self.assert_(isinstance(copied_feed.entry[0], gdata.contacts.ContactEntry))
+ self.assertEqual(copied_feed.title.text, 'Contacts')
+ self.assertEqual(copied_feed.total_results.text, '1')
+ self.assertEqual(len(copied_feed.entry), 1)
+ self.assertTrue(isinstance(copied_feed.entry[0], gdata.contacts.ContactEntry))
class GroupsFeedTest(unittest.TestCase):
@@ -153,11 +153,11 @@
test_data.CONTACT_GROUPS_FEED)
def testParsingGroupsFeed(self):
- self.assertEquals(self.feed.id.text, 'jo@gmail.com')
- self.assertEquals(self.feed.title.text, 'Jo\'s Contact Groups')
- self.assertEquals(self.feed.total_results.text, '3')
- self.assertEquals(len(self.feed.entry), 1)
- self.assert_(isinstance(self.feed.entry[0], gdata.contacts.GroupEntry))
+ self.assertEqual(self.feed.id.text, 'jo@gmail.com')
+ self.assertEqual(self.feed.title.text, 'Jo\'s Contact Groups')
+ self.assertEqual(self.feed.total_results.text, '3')
+ self.assertEqual(len(self.feed.entry), 1)
+ self.assertTrue(isinstance(self.feed.entry[0], gdata.contacts.GroupEntry))
class GroupEntryTest(unittest.TestCase):
@@ -167,17 +167,17 @@
test_data.CONTACT_GROUP_ENTRY)
def testParsingTestEntry(self):
- self.assertEquals(self.entry.title.text, 'Salsa group')
- self.assertEquals(len(self.entry.extended_property), 1)
- self.assertEquals(self.entry.extended_property[0].name,
+ self.asRefactoringTool: Refactored ./tests/gdata_tests/contacts/service_test.py
sertEqual(self.entry.title.text, 'Salsa group')
+ self.assertEqual(len(self.entry.extended_property), 1)
+ self.assertEqual(self.entry.extended_property[0].name,
'more info about the group')
- self.assertEquals(
+ self.assertEqual(
self.entry.extended_property[0].GetXmlBlobExtensionElement().namespace,
atom.ATOM_NAMESPACE)
- self.assertEquals(
+ self.assertEqual(
self.entry.extended_property[0].GetXmlBlobExtensionElement().tag,
'info')
- self.assertEquals(
+ self.assertEqual(
self.entry.extended_property[0].GetXmlBlobExtensionElement().text,
'Very nice people.')
--- ./tests/gdata_tests/contacts/service_test.py (original)
+++ ./tests/gdata_tests/contacts/service_test.py (refactored)
@@ -19,7 +19,7 @@
import getpass
import re
import unittest
-import urllib
+import urllib.request, urllib.parse, urllib.error
import atom
import gdata.contacts.service
import gdata.test_config as conf
@@ -43,10 +43,10 @@
return
conf.configure_service_cache(self.gd_client, 'testGetContactsFeed')
feed = self.gd_client.GetContactsFeed()
- self.assert_(isinstance(feed, gdata.contacts.ContactsFeed))
+ self.assertTrue(isinstance(feed, gdata.contacts.ContactsFeed))
def testDefaultContactList(self):
- self.assertEquals('default', self.gd_client.contact_list)
+ self.assertEqual('default', self.gd_client.contact_list)
def testCustomContactList(self):
if not conf.options.get_value('runlive') == 'true':
@@ -55,11 +55,11 @@
self.gd_client.contact_list = conf.options.get_value('username')
feed = self.gd_client.GetContactsFeed()
- self.assert_(isinstance(feed, gdata.contacts.ContactsFeed))
+ self.assertTrue(isinstance(feed, gdata.contacts.ContactsFeed))
def testGetFeedUriDefault(self):
self.gd_client.contact_list = 'domain.com'
- self.assertEquals('/m8/feeds/contacts/domain.com/full',
+ self.assertEqual('/m8/feeds/contacts/domain.com/full',
self.gd_client.GetFeedUri())
def testGetFeedUriCustom(self):
@@ -67,7 +67,7 @@
contact_list='example.com',
projection='base/batch',
scheme='https')
- self.assertEquals(
+ self.assertEqual(
'https://www.google.com/m8/feeds/groups/example.com/base/batch', uri)
def testCreateUpdateDeleteContactAndUpdatePhoto(self):
@@ -94,25 +94,25 @@
entry = self.gd_client.CreateContact(new_entry)
# Generate and parse the XML for the new entry.
- self.assertEquals(entry.title.text, new_entry.title.text)
- self.assertEquals(entry.content.text, 'Test Notes')
- self.assertEquals(len(entry.email), 1)
- self.assertEquals(entry.email[0].rel, new_entry.email[0].rel)
- self.assertEquals(entry.email[0].address, 'liz@gmail.com')
- self.assertEquals(len(entry.phone_number), 1)
- self.assertEquals(entry.phone_number[0].rel,
+ self.assertEqual(entry.title.text, new_entry.title.text)
+ self.assertEqual(entry.content.text, 'Test Notes')
+ self.assertEqual(len(entry.email), 1)
+ self.assertEqual(entry.email[0].rel, new_entry.email[0].rel)
+ self.assertEqual(entry.email[0].address, 'liz@gmail.com')
+ self.assertEqual(len(entry.phone_number), 1)
+ self.assertEqual(entry.phone_number[0].rel,
new_entry.phone_number[0].rel)
- self.assertEquals(entry.phone_number[0].text, '(206)555-1212')
- self.assertEquals(entry.organization.org_name.text, 'TestCo.')
+ self.assertEqual(entry.phone_number[0].text, '(206)555-1212')
+ self.assertEqual(entry.organization.org_name.text, 'TestCo.')
# Edit the entry.
entry.phone_number[0].text = '(555)555-1212'
updated = self.gd_client.UpdateContact(entry.GetEditLink().href, entry)
- self.assertEquals(updated.content.text, 'Test Notes')
- self.assertEquals(len(updated.phone_number), 1)
- self.assertEquals(updated.phone_number[0].rel,
+ self.assertEqual(updated.content.text, 'Test Notes')
+ self.assertEqual(len(updated.phone_number), 1)
+ self.assertEqual(updated.phone_number[0].rel,
entry.phone_number[0].rel)
- self.assertEquals(updated.phone_number[0].text, '(555)555-1212')
+ self.assertEqual(updated.phone_number[0].text, '(555)555-1212')
# Change the contact's photo.
updated_photo = self.gd_client.ChangePhoto(
@@ -121,11 +121,11 @@
# Refetch the contact so that it has the new photo link
updated = self.gd_client.GetContact(updated.GetSelfLink().href)
- self.assert_(updated.GetPhotoLink() is not None)
+ self.assertTrue(updated.GetPhotoLink() is not None)
# Fetch the photo data.
hosted_image = self.gd_client.GetPhoto(updated)
- self.assert_(hosted_image is not None)
+ self.assertTrue(hosted_image is not None)
# Delete the entry.
self.gd_client.DeleteContact(updated.GetEditLink().href)
@@ -160,17 +160,17 @@
batch_result = self.gd_client.ExecuteBatch(batch_request,
default_batch_url)
- self.assertEquals(len(batch_result.entry), 1)
- self.assertEquals(batch_result.entry[0].title.text,
+ self.assertEqual(len(batch_result.entry), 1)
+ self.assertEqual(batch_result.entry[0].title.text,
random_contact_title)
- self.assertEquals(batch_result.entry[0].batch_operation.type,
+ self.assertEqual(batch_result.entry[0].batch_operation.type,
gdata.BATCH_INSERT)
- self.assertEquals(batch_result.entry[0].batch_status.code,
+ self.assertEqual(batch_result.entry[0].batch_status.code,
'201')
expected_batch_url = re.compile('default').sub(
- urllib.quote(self.gd_client.email),
+ urllib.parse.quote(self.gd_client.email),
gdata.contacts.service.DEFAULT_BATCH_URL)
- self.failUnless(batch_result.GetBatchLink().href,
+ self.assertTrue(batch_result.GetBatchLink().href,
expected_batch_url)
# Create a batch request to delete the newly created entry.
@@ -180,18 +180,18 @@
batch_delete_result = self.gd_client.ExecuteBatch(
batch_delete_request,
batch_result.GetBatchLink().href)
- self.assertEquals(len(batch_delete_result.entry), 1)
- self.assertEquals(batch_delete_result.entry[0].batch_operation.type,
+ self.assertEqual(len(batch_delete_result.entry), 1)
+ self.assertEqual(batch_delete_result.entry[0].batch_operation.type,
gdata.BATCH_DELETE)
- self.assertEquals(batch_result.entry[0].batch_status.code,
+ self.assertEqual(batch_result.entry[0].batch_status.code,
'201')
def testCleanUriNeedsCleaning(self):
- self.assertEquals('/relative/uri', self.gd_client._CleanUri(
+ self.assertEqual('/relative/uri', self.gd_client._CleanUri(
'http://www.google.com/relative/uri'))
def testCleanUriDoesNotNeedCleaning(self):
- self.assertEquals('/relative/uri', self.gd_client._CleanUri(
+ self.assertEqual('/relative/uri', self.gd_client._CleanUri(
'/relative/uri'))
@@ -199,21 +199,21 @@
def testConvertToStringDefaultFeed(self):
query = gdata.contacts.service.ContactsQuery()
- self.assertEquals(str(query), '/m8/feeds/contacts/default/full')
+ self.assertEqual(str(query), '/m8/feeds/contacts/default/full')
query.max_results = 10
- self.assertEquals(query.ToUri(),
+ self.assertEqual(query.ToUri(),
'/m8/feeds/contacts/default/full?max-results=10')
def testConvertToStringCustomFeed(self):
query = gdata.contacts.service.ContactsQuery('/custom/feed/uri')
- self.assertEquals(str(query), '/custom/feed/uri')
+ self.assertEqual(str(query), '/custom/feed/uri')
query.max_results = '10'
- self.assertEquals(query.ToUri(), '/custom/feed/uri?max-results=10')
+ self.assertEqual(query.ToUri(), '/custom/feed/uri?max-results=10')
def testGroupQueryParameter(self):
query = gdata.contacts.service.ContactsQuery()
query.group = 'http://google.com/m8/feeds/groups/liz%40gmail.com/full/270f'
- seRefactoringTool: Refactored ./tests/gdata_tests/contacts/profiles/service_test.py
lf.assertEquals(query.ToUri(), '/m8/feeds/contacts/default/full'
+ self.assertEqual(query.ToUri(), '/m8/feeds/contacts/default/full'
'?group=http%3A%2F%2Fgoogle.com%2Fm8%2Ffeeds%2Fgroups'
'%2Fliz%2540gmail.com%2Ffull%2F270f')
@@ -236,14 +236,14 @@
test_group = gdata.contacts.GroupEntry(title=atom.Title(
text='test group py'))
new_group = self.gd_client.CreateGroup(test_group)
- self.assert_(isinstance(new_group, gdata.contacts.GroupEntry))
- self.assertEquals(new_group.title.text, 'test group py')
+ self.assertTrue(isinstance(new_group, gdata.contacts.GroupEntry))
+ self.assertEqual(new_group.title.text, 'test group py')
# Change the group's title
new_group.title.text = 'new group name py'
updated_group = self.gd_client.UpdateGroup(new_group.GetEditLink().href,
new_group)
- self.assertEquals(updated_group.title.text, new_group.title.text)
+ self.assertEqual(updated_group.title.text, new_group.title.text)
# Remove the group
self.gd_client.DeleteGroup(updated_group.GetEditLink().href)
--- ./tests/gdata_tests/contacts/profiles/service_test.py (original)
+++ ./tests/gdata_tests/contacts/profiles/service_test.py (refactored)
@@ -53,34 +53,34 @@
def testGetFeedUriCustom(self):
uri = self.gd_client.GetFeedUri(kind='profiles', scheme='https')
- self.assertEquals(
+ self.assertEqual(
'https://%s/m8/feeds/profiles/domain/%s/full' % (server, domain), uri)
def testGetProfileFeedUriDefault(self):
self.gd_client.contact_list = 'domain.com'
- self.assertEquals('/m8/feeds/profiles/domain/domain.com/full',
+ self.assertEqual('/m8/feeds/profiles/domain/domain.com/full',
self.gd_client.GetFeedUri('profiles'))
def testCleanUriNeedsCleaning(self):
- self.assertEquals('/relative/uri', self.gd_client._CleanUri(
+ self.assertEqual('/relative/uri', self.gd_client._CleanUri(
'http://www.google.com/relative/uri'))
def testCleanUriDoesNotNeedCleaning(self):
- self.assertEquals('/relative/uri', self.gd_client._CleanUri(
+ self.assertEqual('/relative/uri', self.gd_client._CleanUri(
'/relative/uri'))
def testGetProfilesFeed(self):
feed = self.gd_client.GetProfilesFeed()
- self.assert_(isinstance(feed, gdata.contacts.ProfilesFeed))
+ self.assertTrue(isinstance(feed, gdata.contacts.ProfilesFeed))
def testGetProfile(self):
# Gets an existing entry
feed = self.gd_client.GetProfilesFeed()
entry = feed.entry[0]
- self.assert_(isinstance(entry, gdata.contacts.ProfileEntry))
- self.assertEquals(entry.title.text,
+ self.assertTrue(isinstance(entry, gdata.contacts.ProfileEntry))
+ self.assertEqual(entry.title.text,
self.gd_client.GetProfile(entry.id.text).title.text)
- self.assertEquals(entry._children,
+ self.assertEqual(entry._children,
self.gd_client.GetProfile(entry.id.text)._children)
def testUpdateProfile(self):
@@ -89,7 +89,7 @@
original_occupation = entry.occupation
entry.occupation = gdata.contacts.Occupation(text='TEST')
updated = self.gd_client.UpdateProfile(entry.GetEditLink().href, entry)
- self.assertEquals('TEST', updated.occupation.text)
+ self.assertEqual('TEST', updated.occupation.text)
updated.occupation = original_occupation
self.gd_client.UpdateProfile(updated.GetEditLink().href, updated)
@@ -98,7 +98,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], '', ['user=', 'pw=', 'domain='])
- except getopt.error, msg:
+ except getopt.error as msg:
print ('Profiles Tests\nNOTE: Please run these tests only with a test '
'account. The tests may delete or update your data.\n'
'\nUsage: service_test.py --email=EMAIL '
@@ -115,15 +115,15 @@
domain = arg
while not email:
- print 'NOTE: Please run these tests only with a test account.'
- email = raw_input('Please enter your email: ')
+ print('NOTE: Please run these tests only with a test account.')
+ email RefactoringTool: Refactored ./tests/gdata_tests/contacts/profiles/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/contacts/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/codesearch_test.py
= input('Please enter your email: ')
while not password:
password = getpass.getpass('Please enter password: ')
if not password:
- print 'Password cannot be blank.'
+ print('Password cannot be blank.')
while not domain:
- print 'NOTE: Please run these tests only with a test account.'
- domain = raw_input('Please enter your Apps domain: ')
+ print('NOTE: Please run these tests only with a test account.')
+ domain = input('Please enter your Apps domain: ')
suite = unittest.makeSuite(ProfilesServiceTest)
unittest.TextTestRunner().run(suite)
--- ./tests/gdata_tests/contacts/profiles/live_client_test.py (original)
+++ ./tests/gdata_tests/contacts/profiles/live_client_test.py (refactored)
@@ -56,7 +56,7 @@
conf.configure_cache(self.client, 'test_profiles_feed')
feed = self.client.get_profiles_feed()
- self.assert_(isinstance(feed, gdata.contacts.data.ProfilesFeed))
+ self.assertTrue(isinstance(feed, gdata.contacts.data.ProfilesFeed))
def test_profiles_query(self):
if not conf.options.get_value('runlive') == 'true':
@@ -66,8 +66,8 @@
query = gdata.contacts.client.ProfilesQuery(max_results=1)
feed = self.client.get_profiles_feed(q=query)
- self.assert_(isinstance(feed, gdata.contacts.data.ProfilesFeed))
- self.assert_(len(feed.entry) == 1)
+ self.assertTrue(isinstance(feed, gdata.contacts.data.ProfilesFeed))
+ self.assertTrue(len(feed.entry) == 1)
# Needs at least 2 profiles in the feed to test the start-key
# query param.
@@ -79,13 +79,13 @@
if 'start-key' in uri.query:
query.start_key = uri.query['start-key']
feed = self.client.get_profiles_feed(q=query)
- self.assert_(isinstance(feed, gdata.contacts.data.ProfilesFeed))
- self.assert_(len(feed.entry) == 1)
- self.assert_(feed.GetSelfLink().href == next.href)
+ self.assertTrue(isinstance(feed, gdata.contacts.data.ProfilesFeed))
+ self.assertTrue(len(feed.entry) == 1)
+ self.assertTrue(feed.GetSelfLink().href == next.href)
# Compare with a feed retrieved with the next link.
next_feed = self.client.get_profiles_feed(uri=next.href)
- self.assert_(len(next_feed.entry) == 1)
- self.assert_(next_feed.entry[0].id.text == feed.entry[0].id.text)
+ self.assertTrue(len(next_feed.entry) == 1)
+ self.assertTrue(next_feed.entry[0].id.text == feed.entry[0].id.text)
def suite():
return conf.build_suite([ProfileTest])
--- ./tests/gdata_tests/contacts/live_client_test.py (original)
+++ ./tests/gdata_tests/contacts/live_client_test.py (refactored)
@@ -66,7 +66,7 @@
title=atom.data.Title(text='a test group'))
created_group = self.client.create_group(new_group)
- self.assert_(created_group.id.text)
+ self.assertTrue(created_group.id.text)
# Add the contact to the new group.
created.group_membership_info.append(
@@ -102,12 +102,12 @@
self_link = link.get_attributes('href')[0].value
elif link.get_attributes('rel')[0].value == 'edit':
edit_link = link.get_attributes('href')[0].value
- self.assert_(self_link is not None)
- self.assert_(edit_link is not None)
+ self.assertTrue(self_link is not None)
+ self.assertTrue(edit_link is not None)
etag = posted.get_attributes('etag')[0].value
- self.assert_(etag is not None)
- self.assert_(len(etag) > 0)
+ self.assertTrue(etag is not None)
+ self.assertTrue(len(etag) > 0)
# Delete the test contact.
http_request = atom.http_core.HttpRequest()
--- ./tests/gdata_tests/codesearch_test.py (original)
+++ ./tests/gdata_tests/codesearch_test.py (refactored)
@@ -29,23 +29,23 @@
gdata.test_data.CODE_SEARCH_FEED)
def testCorrectXmlConversion(self):
- self.assert_(self.feed.id.text ==
+ self.assertTrue(self.feed.id.text ==
'http://www.google.com/codesearch/feeds/search?q=malloc')
- self.assert_(len(self.feed.entry) == 10)
+ self.assertTrue(len(self.feed.entry) == 10)
for entry in self.feed.entry:
if enRefactoringTool: Refactored ./tests/gdata_tests/client_test.py
try.id.text == ('http://www.google.com/codesearch?hl=en&q=+ma'
'lloc+show:LDjwp-Iqc7U:84hEYaYsZk8:xDGReDhvNi0&sa=N&ct=rx&cd=1'
'&cs_p=http://www.gnu.org&cs_f=software/autoconf/manual/autoco'
'nf-2.60/autoconf.html-002&cs_p=http://www.gnu.org&cs_f=softwa'
're/autoconf/manual/autoconf-2.60/autoconf.html-002#first'):
- self.assert_(len(entry.match) == 4)
+ self.assertTrue(len(entry.match) == 4)
for match in entry.match:
if match.line_number == '4':
- self.assert_(match.type == 'text/html')
- self.assert_(entry.file.name ==
+ self.assertTrue(match.type == 'text/html')
+ self.assertTrue(entry.file.name ==
'software/autoconf/manual/autoconf-2.60/autoconf.html-002')
- self.assert_(entry.package.name == 'http://www.gnu.org')
- self.assert_(entry.package.uri == 'http://www.gnu.org')
+ self.assertTrue(entry.package.name == 'http://www.gnu.org')
+ self.assertTrue(entry.package.uri == 'http://www.gnu.org')
if __name__ == '__main__':
--- ./tests/gdata_tests/client_test.py (original)
+++ ./tests/gdata_tests/client_test.py (refactored)
@@ -26,7 +26,7 @@
import gdata.gauth
import gdata.data
import atom.mock_http_core
-import StringIO
+import io
class ClientLoginTest(unittest.TestCase):
@@ -38,7 +38,7 @@
'LSID=DQAAAGsA...lk8BBbG\n'
'Auth=DQAAAGgA...dk3fA5N', {'Content-Type': 'text/plain'})
token = client.request_client_login_token('email', 'pw', 'cp', 'test')
- self.assert_(isinstance(token, gdata.gauth.ClientLoginToken))
+ self.assertTrue(isinstance(token, gdata.gauth.ClientLoginToken))
self.assertEqual(token.token_string, 'DQAAAGgA...dk3fA5N')
# Test a server response without a ClientLogin token.`
@@ -64,11 +64,11 @@
token = client.request_client_login_token('email', 'pw', '', '')
self.fail('should raise a CaptchaChallenge on a 403 with a '
'CaptchRequired error.')
- except gdata.client.CaptchaChallenge, challenge:
- self.assertEquals(challenge.captcha_url,
+ except gdata.client.CaptchaChallenge as challenge:
+ self.assertEqual(challenge.captcha_url,
'http://www.google.com/accounts/'
'Captcha?ctoken=HiteT4bVoP6-yFkHPibe7O9EqxeiI7lUSN')
- self.assertEquals(challenge.captcha_token, 'DQAAAGgA...dkI1LK9')
+ self.assertEqual(challenge.captcha_token, 'DQAAAGgA...dkI1LK9')
# Test an unexpected response, a 404 for example.
client.http_client.set_response(404, 'ignored', '', {})
@@ -82,7 +82,7 @@
'LSID=DQAAAGsA...lk8BBbG\n'
'Auth=DQAAAGgA...dk3fA5N', {'Content-Type': 'text/plain'})
client.client_login('me@example.com', 'password', 'wise', 'unit test')
- self.assert_(isinstance(client.auth_token, gdata.gauth.ClientLoginToken))
+ self.assertTrue(isinstance(client.auth_token, gdata.gauth.ClientLoginToken))
self.assertEqual(client.auth_token.token_string, 'DQAAAGgA...dk3fA5N')
@@ -98,12 +98,12 @@
client.auth_token = gdata.gauth.AuthSubToken.from_url(page_url)
- self.assert_(isinstance(client.auth_token, gdata.gauth.AuthSubToken))
+ self.assertTrue(isinstance(client.auth_token, gdata.gauth.AuthSubToken))
self.assertEqual(client.auth_token.token_string, 'CKF50YzIHxCTKMAg')
upgraded = client.upgrade_token()
- self.assert_(isinstance(client.auth_token, gdata.gauth.AuthSubToken))
+ self.assertTrue(isinstance(client.auth_token, gdata.gauth.AuthSubToken))
self.assertEqual(client.auth_token.token_string, 'UpgradedTokenVal')
self.assertEqual(client.auth_token, upgraded)
@@ -128,7 +128,7 @@
page_url = 'http://example.com/showcalendar.html?token=CKF50YzIHxCTKMAg'
client.auth_token = gdata.gauth.AuthSubToken.from_url(page_url)
deleted = client.revoke_token()
- self.assert_(deleted)
+ self.assertTrue(deleted)
self.assertEqual(
client.http_client.last_request.headers['Authorization'],
'AuthSub token=CKF50YzIHxCTKMAg')
@@ -151,18 +151,18 @@
# Also check the Authorization header which was sent in the request.
auth_header = client.http_client.last_request.headers['Authorization']
- self.assert_('OAuth' in auth_header)
- self.assert_(
+ self.assertTrue('OAuth' in auth_header)
+ self.assertTrue(
'oauth_callback="http%3A%2F%2Fexample.net%2Fmyapp"' in auth_header)
- self.assert_('oauth_version="1.0"' in auth_header)
- self.assert_('oauth_signature_method="HMAC-SHA1"' in auth_header)
- self.assert_('oauth_consumer_key="consumer"' in auth_header)
+ self.assertTrue('oauth_version="1.0"' in auth_header)
+ self.assertTrue('oauth_signature_method="HMAC-SHA1"' in auth_header)
+ self.assertTrue('oauth_consumer_key="consumer"' in auth_header)
# Check generation of the authorization URL.
authorize_url = request_token.generate_authorization_url()
- self.assert_(str(authorize_url).startswith(
+ self.assertTrue(str(authorize_url).startswith(
'https://www.google.com/accounts/OAuthAuthorizeToken'))
- self.assert_('oauth_token=ab3cd9j4ks7' in str(authorize_url))
+ self.assertTrue('oauth_token=ab3cd9j4ks7' in str(authorize_url))
# Check that the token information from the browser's URL is parsed.
redirected_url = (
@@ -179,21 +179,21 @@
access_token = client.get_access_token(request_token)
self.assertEqual(request_token.token, '3cd9Fj417')
self.assertEqual(request_token.token_secret, 'Xhrh6bXBs')
- self.assert_(request_token.verifier is None)
+ self.assertTrue(request_token.verifier is None)
self.assertEqual(request_token.auth_state, gdata.gauth.ACCESS_TOKEN)
self.assertEqual(request_token.token, access_token.token)
self.assertEqual(request_token.token_secret, access_token.token_secret)
- self.assert_(access_token.verifier is None)
+ self.assertTrue(access_token.verifier is None)
self.assertEqual(request_token.auth_state, access_token.auth_state)
# Also check the Authorization header which was sent in the request.
auth_header = client.http_client.last_request.headers['Authorization']
- self.assert_('OAuth' in auth_header)
- self.assert_('oauth_callback="' not in auth_header)
- self.assert_('oauth_version="1.0"' in auth_header)
- self.assert_('oauth_verifier="Xhhbas"' in auth_header)
- self.assert_('oauth_signature_method="HMAC-SHA1"' in auth_header)
- self.assert_('oauth_consumer_key="consumer"' in auth_header)
+ self.assertTrue('OAuth' in auth_header)
+ self.assertTrue('oauth_callback="' not in auth_header)
+ self.assertTrue('oauth_version="1.0"' in auth_header)
+ self.assertTrue('oauth_verifier="Xhhbas"' in auth_header)
+ self.assertTrue('oauth_signature_method="HMAC-SHA1"' in auth_header)
+ self.assertTrue('oauth_consumer_key="consumer"' in auth_header)
class RequestTest(unittest.TestCase):
@@ -264,8 +264,8 @@
try:
response = client.request(method='PUT', uri='http://example.com/2?gsessionid=loop')
self.fail('Loop URL should have redirected forever.')
- except gdata.client.RedirectError, err:
- self.assert_(str(err).startswith('Too many redirects from server'))
+ except gdata.client.RedirectError as err:
+ self.assertTrue(str(err).startswith('Too many redirects from server'))
def test_lowercase_location(self):
client = gdata.client.GDClient()
@@ -302,11 +302,11 @@
client.http_client = atom.mock_http_core.EchoHttpClient()
test_entry = gdata.data.GDEntry()
result = client.post(test_entry, 'http://example.com')
- self.assert_(isinstance(result, gdata.data.GDEntry))
+ self.assertTrue(isinstance(result, gdata.data.GDEntry))
result = client.post(test_entry, 'http://example.com', converter=bad_converter)
- self.assertEquals(result, 1)
+ self.assertEqual(result, 1)
result = client.post(test_entry, 'http://example.com', desired_class=TestClass)
- self.assert_(isinstance(result, TestClass))
+ self.assertTrue(isinstance(result, TestClass))
class QueryTest(unittest.TestCase):
@@ -334,13 +334,13 @@
RefactoringTool: No changes to ./tests/gdata_tests/client_smoke_test.py
RefactoringTool: Refactored ./tests/gdata_tests/calendar_test.py
class VersionConversionTest(unittest.TestCase):
def test_use_default_version(self):
- self.assertEquals(gdata.client.get_xml_version(None), 1)
+ self.assertEqual(gdata.client.get_xml_version(None), 1)
def test_str_to_int_version(self):
- self.assertEquals(gdata.client.get_xml_version('1'), 1)
- self.assertEquals(gdata.client.get_xml_version('2'), 2)
- self.assertEquals(gdata.client.get_xml_version('2.1.2'), 2)
- self.assertEquals(gdata.client.get_xml_version('10.4'), 10)
+ self.assertEqual(gdata.client.get_xml_version('1'), 1)
+ self.assertEqual(gdata.client.get_xml_version('2'), 2)
+ self.assertEqual(gdata.client.get_xml_version('2.1.2'), 2)
+ self.assertEqual(gdata.client.get_xml_version('10.4'), 10)
class UpdateTest(unittest.TestCase):
--- ./tests/gdata_tests/calendar_test.py (original)
+++ ./tests/gdata_tests/calendar_test.py (refactored)
@@ -37,21 +37,21 @@
def testEntryCount(self):
# Assert the number of items in the feed of calendars
- self.assertEquals(len(self.calendar_feed.entry),2)
+ self.assertEqual(len(self.calendar_feed.entry),2)
def testToAndFromString(self):
# Assert the appropriate type for each entry
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry, gdata.calendar.CalendarListEntry),
+ self.assertTrue(isinstance(an_entry, gdata.calendar.CalendarListEntry),
'Entry must be an instance of CalendarListEntry')
# Regenerate feed from xml text
new_calendar_feed = (
gdata.calendar.CalendarListFeedFromString(str(self.calendar_feed)))
for an_entry in new_calendar_feed.entry:
- self.assert_(isinstance(an_entry, gdata.calendar.CalendarListEntry),
+ self.assertTrue(isinstance(an_entry, gdata.calendar.CalendarListEntry),
'Entry in regenerated feed must be an instance of CalendarListEntry')
def testAuthor(self):
@@ -59,21 +59,21 @@
# Assert that each element in the feed author list is an atom.Author
for an_author in self.calendar_feed.author:
- self.assert_(isinstance(an_author, atom.Author),
+ self.assertTrue(isinstance(an_author, atom.Author),
"Calendar feed element must be an instance of " +
"atom.Author: %s" % an_author)
# Assert the feed author name is as expected
- self.assertEquals(self.calendar_feed.author[0].name.text, 'GData Ops Demo')
+ self.assertEqual(self.calendar_feed.author[0].name.text, 'GData Ops Demo')
# Assert the feed author name is as expected
- self.assertEquals(self.calendar_feed.author[0].email.text,
+ self.assertEqual(self.calendar_feed.author[0].email.text,
'gdata.ops.demo@gmail.com')
# Assert one of the values for an entry author
- self.assertEquals(self.calendar_feed.entry[0].author[0].name.text,
+ self.assertEqual(self.calendar_feed.entry[0].author[0].name.text,
'GData Ops Demo')
- self.assertEquals(self.calendar_feed.entry[0].author[0].email.text,
+ self.assertEqual(self.calendar_feed.entry[0].author[0].email.text,
'gdata.ops.demo@gmail.com')
def testId(self):
@@ -81,22 +81,22 @@
and verifies the value"""
# Assert the feed id exists and is an atom.Id
- self.assert_(isinstance(self.calendar_feed.id, atom.Id),
+ self.assertTrue(isinstance(self.calendar_feed.id, atom.Id),
"Calendar feed element must be an instance of atom.Id: %s" % (
self.calendar_feed.id))
# Assert the feed id value is as expected
- self.assertEquals(self.calendar_feed.id.text,
+ self.assertEqual(self.calendar_feed.id.text,
'http://www.google.com/calendar/feeds/default')
# Assert that each entry has an id which is an atom.Id
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.id, atom.Id),
+ self.assertTrue(isinstance(an_entry.id, atom.Id),
"Calendar entry element must be an instance of " +
"atom.Id: %s" % an_entry.id)
# Assert one of the values for an id
- self.assertEquals(self.calendar_feed.entry[1].id.text,
+ self.assertEqual(self.calendar_feed.entry[1].id.text,
'http://www.google.com/calendar/feeds/default/' +
'jnh21ovnjgfph21h32gvms2758%40group.calendar.google.com')
@@ -106,12 +106,12 @@
# Assert that each entry has a published value which is an atom.Published
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.published, atom.Published),
+ self.assertTrue(isinstance(an_entry.published, atom.Published),
"Calendar entry element must be an instance of " +
"atom.Published: %s" % an_entry.published)
# Assert one of the values for published is as expected
- self.assertEquals(self.calendar_feed.entry[1].published.text,
+ self.assertEqual(self.calendar_feed.entry[1].published.text,
'2007-03-20T22:48:57.837Z')
def testUpdated(self):
@@ -119,22 +119,22 @@
and verifies the value"""
# Assert that the feed updated element exists and is an atom.Updated
- self.assert_(isinstance(self.calendar_feed.updated, atom.Updated),
+ self.assertTrue(isinstance(self.calendar_feed.updated, atom.Updated),
"Calendar feed element must be an instance of " +
"atom.Updated: %s" % self.calendar_feed.updated)
# Assert that each entry has a updated value which is an atom.Updated
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.updated, atom.Updated),
+ self.assertTrue(isinstance(an_entry.updated, atom.Updated),
"Calendar entry element must be an instance of" +
"atom.Updated: %s" % an_entry.updated)
# Assert the feed updated value is as expected
- self.assertEquals(self.calendar_feed.updated.text,
+ self.assertEqual(self.calendar_feed.updated.text,
'2007-03-20T22:48:57.833Z')
# Assert one of the values for updated
- self.assertEquals(self.calendar_feed.entry[0].updated.text,
+ self.assertEqual(self.calendar_feed.entry[0].updated.text,
'2007-03-20T22:48:52.000Z')
def testTitle(self):
@@ -142,34 +142,34 @@
verifies the value"""
# Assert that the feed title element exists and is an atom.Title
- self.assert_(isinstance(self.calendar_feed.title, atom.Title),
+ self.assertTrue(isinstance(self.calendar_feed.title, atom.Title),
"Calendar feed element must be an instance of " +
"atom.Title: %s" % self.calendar_feed.title)
# Assert that each entry has a title value which is an atom.Title
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.title, atom.Title),
+ self.assertTrue(isinstance(an_entry.title, atom.Title),
"Calendar entry element must be an instance of " +
"atom.Title: %s" % an_entry.title)
# Assert the feed title value is as expected
- self.assertEquals(self.calendar_feed.title.text,
+ self.assertEqual(self.calendar_feed.title.text,
'GData Ops Demo\'s Calendar List')
# Assert one of the values for title
- self.assertEquals(self.calendar_feed.entry[0].title.text, 'GData Ops Demo')
+ self.assertEqual(self.calendar_feed.entry[0].title.text, 'GData Ops Demo')
def testColor(self):
"""Tests the existence of a and verifies the value"""
# Assert the color is present and is a gdata.calendar.Color
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.color, gdata.calendar.Color),
+ self.assertTrue(isinstance(an_entry.color, gdata.calendar.Color),
"Calendar feed element must be an instance of " +
"gdata.calendar.Color: %s" % an_entry.color)
# Assert the color value is as expected
- self.assertEquals(self.calendar_feed.entry[0].color.value, '#2952A3')
+ self.assertEqual(self.calendar_feed.entry[0].color.value, '#2952A3')
def testAccessLevel(self):
"""Tests the existence of a element and verifies the
@@ -177,12 +177,12 @@
# Assert the access_level is present and is a gdata.calendar.AccessLevel
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.access_level, gdata.calendar.AccessLevel),
+ self.assertTrue(isinstance(an_entry.access_level, gdata.calendar.AccessLevel),
"Calendar feed element must be an instance of " +
"gdata.calendar.AccessLevel: %s" % an_entry.access_level)
# Assert the access_level value is as expected
- self.assertEquals(self.calendar_feed.entry[0].access_level.value, 'owner')
+ self.assertEqual(self.calendar_feed.entry[0].access_level.value, 'owner')
def testTimezone(self):
"""Tests the existence of a element and verifies the
@@ -190,12 +190,12 @@
# Assert the timezone is present and is a gdata.calendar.Timezone
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.timezone, gdata.calendar.Timezone),
+ self.assertTrue(isinstance(an_entry.timezone, gdata.calendar.Timezone),
"Calendar feed element must be an instance of " +
"gdata.calendar.Timezone: %s" % an_entry.timezone)
# Assert the timezone value is as expected
- self.assertEquals(self.calendar_feed.entry[0].timezone.value,
+ self.assertEqual(self.calendar_feed.entry[0].timezone.value,
'America/Los_Angeles')
def testHidden(self):
@@ -204,35 +204,35 @@
# Assert the hidden is present and is a gdata.calendar.Hidden
for an_entry in self.calendar_feed.entry:
- self.assert_(isinstance(an_entry.hidden, gdata.calendar.Hidden),
+ self.assertTrue(isinstance(an_entry.hidden, gdata.calendar.Hidden),
"Calendar feed element must be an instance of " +
"gdata.calendar.Hidden: %s" % an_entry.hidden)
# Assert the hidden value is as expected
- self.assertEquals(self.calendar_feed.entry[0].hidden.value, 'false')
+ self.assertEqual(self.calendar_feed.entry[0].hidden.value, 'false')
def testOpenSearch(self):
"""Tests the existence of """
# Assert that the elements exist and are the appropriate type
- self.assert_(isinstance(self.calendar_feed.start_index, gdata.StartIndex),
+ self.assertTrue(isinstance(self.calendar_feed.start_index, gdata.StartIndex),
"Calendar feed element must be an " +
"instance of gdata.StartIndex: %s" % self.calendar_feed.start_index)
# Assert the values for each openSearch element are as expected
- self.assertEquals(self.calendar_feed.start_index.text, '1')
+ self.assertEqual(self.calendar_feed.start_index.text, '1')
def testGenerator(self):
"""Tests the existence of and verifies the value"""
# Assert that the element exists and is of the appropriate type
- self.assert_(isinstance(self.calendar_feed.generator, atom.Generator),
+ self.assertTrue(isinstance(self.calendar_feed.generator, atom.Generator),
"Calendar feed element must be an instance of " +
"atom.Generator: %s" % self.calendar_feed.generator)
# Assert the generator version, uri and text are as expected
- self.assertEquals(self.calendar_feed.generator.text, 'Google Calendar')
- self.assertEquals(self.calendar_feed.generator.version, '1.0')
- self.assertEquals(self.calendar_feed.generator.uri,
+ self.assertEqual(self.calendar_feed.generator.text, 'Google Calendar')
+ self.assertEqual(self.calendar_feed.generator.version, '1.0')
+ self.assertEqual(self.calendar_feed.generator.uri,
'http://www.google.com/calendar')
def testEntryLink(self):
@@ -241,12 +241,12 @@
entry = gdata.calendar.CalendarEventEntryFromString(
test_data.RECURRENCE_EXCEPTION_ENTRY)
- self.assert_(isinstance(entry.recurrence_exception, list))
- self.assert_(isinstance(entry.recurrence_exception[0].entry_link,
+ self.assertTrue(isinstance(entry.recurrence_exception, list))
+ self.assertTrue(isinstance(entry.recurrence_exception[0].entry_link,
gdata.EntryLink))
- self.assert_(isinstance(entry.recurrence_exception[0].entry_link.entry,
+ self.assertTrue(isinstance(entry.recurrence_exception[0].entry_link.entry,
gdata.calendar.CalendarEventEntry))
- self.assertEquals(
+ self.assertEqual(
entry.recurrence_exception[0].entry_link.entry.author[0].name.text,
'gdata ops')
@@ -266,7 +266,7 @@
entry = gdata.calendar.CalendarEventEntryFromString(
test_data.RECURRENCE_EXCEPTION_ENTRY)
- self.assertEquals(
+ self.assertEqual(
entry.recurrence_exception[0].entry_link.entry.original_event.id,
'i7lgfj69mjqjgnodklif3vbm7g')
@@ -289,19 +289,19 @@
def testEntryCount(self):
# Assert the number of items in the feed of events
- self.assertEquals(len(self.calendar_event_feed.entry),11)
+ self.assertEqual(len(self.calendar_event_feed.entry),11)
def testToAndFromString(self):
# Assert the appropriate type for each entry
for an_entry in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_entry, gdata.calendar.CalendarEventEntry),
+ self.assertTrue(isinstance(an_entry, gdata.calendar.CalendarEventEntry),
"Entry must be an instance of a CalendarEventEntry")
# Regenerate feed from xml text
new_calendar_event_feed = gdata.calendar.CalendarEventFeedFromString(
str(self.calendar_event_feed))
for an_entry in new_calendar_event_feed.entry:
- self.assert_(isinstance(an_entry, gdata.calendar.CalendarEventEntry),
+ self.assertTrue(isinstance(an_entry, gdata.calendar.CalendarEventEntry),
"Entry in regenerated feed must be an instance of CalendarEventEntry")
def testAuthor(self):
@@ -309,22 +309,22 @@
# Assert that each element in the feed author list is an atom.Author
for an_author in self.calendar_event_feed.author:
- self.assert_(isinstance(an_author, atom.Author),
+ self.assertTrue(isinstance(an_author, atom.Author),
"Calendar event feed element must be an instance of " +
"atom.Author: %s" % an_author)
# Assert the feed author name is as expected
- self.assertEquals(self.calendar_event_feed.author[0].name.text,
+ self.assertEqual(self.calendar_event_feed.author[0].name.text,
'GData Ops Demo')
# Assert the feed author name is as expected
- self.assertEquals(self.calendar_event_feed.author[0].email.text,
+ self.assertEqual(self.calendar_event_feed.author[0].email.text,
'gdata.ops.demo@gmail.com')
# Assert one of the values for an entry author
- self.assertEquals(self.calendar_event_feed.entry[0].author[0].name.text,
+ self.assertEqual(self.calendar_event_feed.entry[0].author[0].name.text,
'GData Ops Demo')
- self.assertEquals(self.calendar_event_feed.entry[0].author[0].email.text,
+ self.assertEqual(self.calendar_event_feed.entry[0].author[0].email.text,
'gdata.ops.demo@gmail.com')
def testId(self):
@@ -332,22 +332,22 @@
verifies the value"""
# Assert the feed id exists and is an atom.Id
- self.assert_(isinstance(self.calendar_event_feed.id, atom.Id),
+ self.assertTrue(isinstance(self.calendar_event_feed.id, atom.Id),
"Calendar event feed element must be an instance of " +
"atom.Id: %s" % self.calendar_event_feed.id)
# Assert the feed id value is as expected
- self.assertEquals(self.calendar_event_feed.id.text,
+ self.assertEqual(self.calendar_event_feed.id.text,
'http://www.google.com/calendar/feeds/default/private/full')
# Assert that each entry has an id which is an atom.Id
for an_entry in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_entry.id, atom.Id),
+ self.assertTrue(isinstance(an_entry.id, atom.Id),
"Calendar event entry element must be an " +
"instance of atom.Id: %s" % an_entry.id)
# Assert one of the values for an id
- self.assertEquals(self.calendar_event_feed.entry[1].id.text,
+ self.assertEqual(self.calendar_event_feed.entry[1].id.text,
'http://www.google.com/calendar/feeds/default/private/full/' +
'2qt3ao5hbaq7m9igr5ak9esjo0')
@@ -357,12 +357,12 @@
# Assert that each entry has a published value which is an atom.Published
for an_entry in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_entry.published, atom.Published),
+ self.assertTrue(isinstance(an_entry.published, atom.Published),
"Calendar event entry element must be an instance " +
"of atom.Published: %s" % an_entry.published)
# Assert one of the values for published is as expected
- self.assertEquals(self.calendar_event_feed.entry[1].published.text,
+ self.assertEqual(self.calendar_event_feed.entry[1].published.text,
'2007-03-20T21:26:04.000Z')
def testUpdated(self):
@@ -370,22 +370,22 @@
verifies the value"""
# Assert that the feed updated element exists and is an atom.Updated
- self.assert_(isinstance(self.calendar_event_feed.updated, atom.Updated),
+ self.assertTrue(isinstance(self.calendar_event_feed.updated, atom.Updated),
"Calendar feed element must be an instance of " +
"atom.Updated: %s" % self.calendar_event_feed.updated)
# Assert that each entry has a updated value which is an atom.Updated
for an_entry in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_entry.updated, atom.Updated),
+ self.assertTrue(isinstance(an_entry.updated, atom.Updated),
"Calendar event entry element must be an instance " +
"of atom.Updated: %s" % an_entry.updated)
# Assert the feed updated value is as expected
- self.assertEquals(self.calendar_event_feed.updated.text,
+ self.assertEqual(self.calendar_event_feed.updated.text,
'2007-03-20T21:29:57.000Z')
# Assert one of the values for updated
- self.assertEquals(self.calendar_event_feed.entry[3].updated.text,
+ self.assertEqual(self.calendar_event_feed.entry[3].updated.text,
'2007-03-20T21:25:46.000Z')
def testTitle(self):
@@ -393,21 +393,21 @@
and verifies the value"""
# Assert that the feed title element exists and is an atom.Title
- self.assert_(isinstance(self.calendar_event_feed.title, atom.Title),
+ self.assertTrue(isinstance(self.calendar_event_feed.title, atom.Title),
"Calendar feed element must be an instance of " +
"atom.Title: %s" % self.calendar_event_feed.title)
# Assert that each entry has a title value which is an atom.Title
for an_entry in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_entry.title, atom.Title),
+ self.assertTrue(isinstance(an_entry.title, atom.Title),
"Calendar event entry element must be an instance of " +
"atom.Title: %s" % an_entry.title)
# Assert the feed title value is as expected
- self.assertEquals(self.calendar_event_feed.title.text, 'GData Ops Demo')
+ self.assertEqual(self.calendar_event_feed.title.text, 'GData Ops Demo')
# Assert one of the values for title
- self.assertEquals(self.calendar_event_feed.entry[0].title.text,
+ self.assertEqual(self.calendar_event_feed.entry[0].title.text,
'test deleted')
def testPostLink(self):
@@ -416,15 +416,15 @@
# Assert that each link in the feed is an atom.Link
for a_link in self.calendar_event_feed.link:
- self.assert_(isinstance(a_link, atom.Link),
+ self.assertTrue(isinstance(a_link, atom.Link),
"Calendar event entry element must be an instance of " +
"atom.Link: %s" % a_link)
# Assert post link exists
- self.assert_(self.calendar_event_feed.GetPostLink() is not None)
+ self.assertTrue(self.calendar_event_feed.GetPostLink() is not None)
# Assert the post link value is as expected
- self.assertEquals(self.calendar_event_feed.GetPostLink().href,
+ self.assertEqual(self.calendar_event_feed.GetPostLink().href,
'http://www.google.com/calendar/feeds/default/private/full')
def testEditLink(self):
@@ -433,19 +433,19 @@
# Assert that each link in the feed is an atom.Link
for a_link in self.calendar_event_feed.link:
- self.assert_(isinstance(a_link, atom.Link),
+ self.assertTrue(isinstance(a_link, atom.Link),
"Calendar event entry element must be an instance of " +
"atom.Link: %s" % a_link)
# Assert edit link exists
for a_entry in self.calendar_event_feed.entry:
- self.assert_(a_entry.GetEditLink() is not None)
+ self.assertTrue(a_entry.GetEditLink() is not None)
# Assert the edit link value is as expected
- self.assertEquals(self.calendar_event_feed.entry[0].GetEditLink().href,
+ self.assertEqual(self.calendar_event_feed.entry[0].GetEditLink().href,
'http://www.google.com/calendar/feeds/default/private/full/o99flmgm' +
'kfkfrr8u745ghr3100/63310109397')
- self.assertEquals(self.calendar_event_feed.entry[0].GetEditLink().type,
+ self.assertEqual(self.calendar_event_feed.entry[0].GetEditLink().type,
'application/atom+xml')
def testOpenSearch(self):
@@ -453,40 +453,40 @@
, """
# Assert that the elements exist and are the appropriate type
- self.assert_(isinstance(self.calendar_event_feed.total_results,
+ self.assertTrue(isinstance(self.calendar_event_feed.total_results,
gdata.TotalResults),
"Calendar event feed element must be an " +
"instance of gdata.TotalResults: %s" % (
self.calendar_event_feed.total_results))
- self.assert_(
+ self.assertTrue(
isinstance(self.calendar_event_feed.start_index, gdata.StartIndex),
"Calendar event feed element must be an " +
"instance of gdata.StartIndex: %s" % (
self.calendar_event_feed.start_index))
- self.assert_(
+ self.assertTrue(
isinstance(self.calendar_event_feed.items_per_page, gdata.ItemsPerPage),
"Calendar event feed element must be an " +
"instance of gdata.ItemsPerPage: %s" % (
self.calendar_event_feed.items_per_page))
# Assert the values for each openSearch element are as expected
- self.assertEquals(self.calendar_event_feed.total_results.text, '10')
- self.assertEquals(self.calendar_event_feed.start_index.text, '1')
- self.assertEquals(self.calendar_event_feed.items_per_page.text, '25')
+ self.assertEqual(self.calendar_event_feed.total_results.text, '10')
+ self.assertEqual(self.calendar_event_feed.start_index.text, '1')
+ self.assertEqual(self.calendar_event_feed.items_per_page.text, '25')
def testGenerator(self):
"""Tests the existence of and verifies the value"""
# Assert that the element exists and is of the appropriate type
- self.assert_(isinstance(self.calendar_event_feed.generator, atom.Generator),
+ self.assertTrue(isinstance(self.calendar_event_feed.generator, atom.Generator),
"Calendar event feed element must be an instance " +
"of atom.Generator: %s" % self.calendar_event_feed.generator)
# Assert the generator version, uri and text are as expected
- self.assertEquals(self.calendar_event_feed.generator.text,
+ self.assertEqual(self.calendar_event_feed.generator.text,
'Google Calendar')
- self.assertEquals(self.calendar_event_feed.generator.version, '1.0')
- self.assertEquals(self.calendar_event_feed.generator.uri,
+ self.assertEqual(self.calendar_event_feed.generator.version, '1.0')
+ self.assertEqual(self.calendar_event_feed.generator.uri,
'http://www.google.com/calendar')
def testCategory(self):
@@ -494,22 +494,22 @@
# Assert that the element exists and is of the appropriate type and value
for a_category in self.calendar_event_feed.category:
- self.assert_(isinstance(a_category, atom.Category),
+ self.assertTrue(isinstance(a_category, atom.Category),
"Calendar event feed element must be an instance " +
"of atom.Category: %s" % a_category)
- self.assertEquals(a_category.scheme,
+ self.assertEqual(a_category.scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(a_category.term,
+ self.assertEqual(a_category.term,
'http://schemas.google.com/g/2005#event')
for an_event in self.calendar_event_feed.entry:
for a_category in an_event.category:
- self.assert_(isinstance(a_category, atom.Category),
+ self.assertTrue(isinstance(a_category, atom.Category),
"Calendar event feed entry element must be an " +
"instance of atom.Category: %s" % a_category)
- self.assertEquals(a_category.scheme,
+ self.assertEqual(a_category.scheme,
'http://schemas.google.com/g/2005#kind')
- self.assertEquals(a_category.term,
+ self.assertEqual(a_category.term,
'http://schemas.google.com/g/2005#event')
@@ -519,18 +519,18 @@
# Assert that the element exists and is of the appropriate type and value
for an_event in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_event.send_event_notifications,
+ self.assertTrue(isinstance(an_event.send_event_notifications,
gdata.calendar.SendEventNotifications),
("Calendar event feed entry element " +
"must be an instance of gdata.calendar.SendEventNotifications: %s") % (
an_event.send_event_notifications,))
# Assert the are as expected
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[0].send_event_notifications.value,
'false')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[2].send_event_notifications.value,
'true')
@@ -543,8 +543,8 @@
unmarshalled_entry = entry.ToString()
tag = '{%s}quickadd' % (gdata.calendar.GCAL_NAMESPACE)
marshalled_entry = ElementTree.fromstring(unmarshalled_entry).find(tag)
- self.assert_(marshalled_entry.attrib['value'],'true')
- self.assert_(marshalled_entry.tag,tag)
+ self.assertTrue(marshalled_entry.attrib['value'],'true')
+ self.assertTrue(marshalled_entry.tag,tag)
def testEventStatus(self):
"""Test the existence of
@@ -552,18 +552,18 @@
# Assert that the element exists and is of the appropriate type and value
for an_event in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_event.event_status,
+ self.assertTrue(isinstance(an_event.event_status,
gdata.calendar.EventStatus),
("Calendar event feed entry element " +
"must be an instance of gdata.calendar.EventStatus: %s") % (
an_event.event_status,))
# Assert the are as expected
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[0].event_status.value,
'CANCELED')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[1].event_status.value,
'CONFIRMED')
@@ -572,7 +572,7 @@
# Assert that the element exists and is of the appropriate type and value
for an_event in self.calendar_event_feed.entry:
- self.assert_(an_event.comments is None or isinstance(an_event.comments,
+ self.assertTrue(an_event.comments is None or isinstance(an_event.comments,
gdata.calendar.Comments),
("Calendar event feed entry element " +
"must be an instance of gdata.calendar.Comments: %s") % (
@@ -583,22 +583,22 @@
# Assert that the element exists and is of the appropriate type and value
for an_event in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_event.visibility,
+ self.assertTrue(isinstance(an_event.visibility,
gdata.calendar.Visibility),
("Calendar event feed entry element " +
"must be an instance of gdata.calendar.Visibility: %s") % (
an_event.visibility,))
# Assert the are as expected
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[0].visibility.value,
'DEFAULT')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[1].visibility.value,
'PRIVATE')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[2].visibility.value,
'PUBLIC')
@@ -607,22 +607,22 @@
# Assert that the element exists and is of the appropriate type and value
for an_event in self.calendar_event_feed.entry:
- self.assert_(isinstance(an_event.transparency,
+ self.assertTrue(isinstance(an_event.transparency,
gdata.calendar.Transparency),
("Calendar event feed entry element " +
"must be an instance of gdata.calendar.Transparency: %s") % (
an_event.transparency,))
# Assert the are as expected
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[0].transparency.value,
'OPAQUE')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[1].transparency.value,
'OPAQUE')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[2].transparency.value,
'OPAQUE')
@@ -635,12 +635,12 @@
# Assert that each entry has a where value which is an gdata.calendar.Where
for an_entry in self.calendar_event_feed.entry:
for a_where in an_entry.where:
- self.assert_(isinstance(a_where, gdata.calendar.Where),
+ self.assertTrue(isinstance(a_where, gdata.calendar.Where),
"Calendar event entry element must be an instance of " +
"gdata.calendar.Where: %s" % a_where)
# Assert one of the values for where is as expected
- self.assertEquals(self.calendar_event_feed.entry[1].where[0].value_string,
+ self.assertEqual(self.calendar_event_feed.entry[1].where[0].value_string,
'Dolores Park with Kim')
def testWhenAndReminder(self):
@@ -651,46 +651,46 @@
# Assert that each reminder is a gdata.calendar.Reminder
for an_entry in self.calendar_event_feed.entry:
for a_when in an_entry.when:
- self.assert_(isinstance(a_when, gdata.calendar.When),
+ self.assertTrue(isinstance(a_when, gdata.calendar.When),
"Calendar event entry element must be an instance " +
"of gdata.calendar.When: %s" % a_when)
for a_reminder in a_when.reminder:
- self.assert_(isinstance(a_reminder, gdata.calendar.Reminder),
+ self.assertTrue(isinstance(a_reminder, gdata.calendar.Reminder),
"Calendar event entry element must be an " +
"instance of gdata.calendar.Reminder: %s" % a_reminder)
# Assert one of the values for when is as expected
- self.assertEquals(self.calendar_event_feed.entry[0].when[0].start_time,
+ self.assertEqual(self.calendar_event_feed.entry[0].when[0].start_time,
'2007-03-23T12:00:00.000-07:00')
- self.assertEquals(self.calendar_event_feed.entry[0].when[0].end_time,
+ self.assertEqual(self.calendar_event_feed.entry[0].when[0].end_time,
'2007-03-23T13:00:00.000-07:00')
# Assert the reminder child of when is as expected
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[0].when[0].reminder[0].minutes, '10')
- self.assertEquals(
+ self.assertEqual(
self.calendar_event_feed.entry[1].when[0].reminder[0].minutes, '20')
def testBatchRequestParsing(self):
batch_request = gdata.calendar.CalendarEventFeedFromString(
test_data.CALENDAR_BATCH_REQUEST)
- self.assertEquals(len(batch_request.entry), 4)
+ self.assertEqual(len(batch_request.entry), 4)
# Iterate over the batch request entries and match the operation with
# the batch id. These values are hard coded to match the test data.
for entry in batch_request.entry:
if entry.batch_id.text == '1':
- self.assertEquals(entry.batch_operation.type, 'insert')
+ self.assertEqual(entry.batch_operation.type, 'insert')
if entry.batch_id.text == '2':
- self.assertEquals(entry.batch_operation.type, 'query')
+ self.assertEqual(entry.batch_operation.type, 'query')
if entry.batch_id.text == '3':
- self.assertEquals(entry.batch_operation.type, 'update')
- self.assertEquals(entry.title.text, 'Event updated via batch')
+ self.assertEqual(entry.batch_operation.type, 'update')
+ self.assertEqual(entry.title.text, 'Event updated via batch')
if entry.batch_id.text == '4':
- self.assertEquals(entry.batch_operation.type, 'delete')
- self.assertEquals(entry.id.text,
+ self.assertEqual(entry.batch_operation.type, 'delete')
+ self.assertEqual(entry.id.text,
'http://www.google.com/calendar/feeds/default/'
'private/full/d8qbg9egk1n6lhsgq1sjbqffqc')
- self.assertEquals(entry.GetEditLink().href,
+ self.assertEqual(entry.GetEditLink().href,
'http://www.google.com/calendar/feeds/default/'
'private/full/d8qbg9egk1n6lhsgq1sjbqffqc/'
'63326018324')
@@ -698,22 +698,22 @@
def testBatchResponseParsing(self):
batch_response = gdata.calendar.CalendarEventFeedFromString(
test_data.CALENDAR_BATCH_RESPONSE)
- self.assertEquals(len(batch_response.entry), 4)
+ self.assertEqual(len(batch_response.entry), 4)
for entry in batch_response.entry:
if entry.batch_id.text == '1':
- self.assertEquals(entry.batch_operation.type, 'insert')
- self.assertEquals(entry.batch_status.code, '201')
- self.assertEquals(entry.batch_status.reason, 'Created')
- self.assertEquals(entry.id.text, 'http://www.google.com/calendar/'
+ self.assertEqual(entry.batch_operation.type, 'insert')
+ self.assertEqual(entry.batch_status.code, '201')
+ self.assertEqual(entry.batch_status.reason, 'Created')
+ self.assertEqual(entry.id.text, 'http://www.google.com/calendar/'
'feeds/default/private/full/'
'n9ug78gd9tv53ppn4hdjvk68ek')
if entry.batch_id.text == '2':
- self.assertEquals(entry.batch_operation.type, 'query')
+ self.assertEqual(entry.batch_operation.type, 'query')
if entry.batch_id.text == '3':
- self.assertEquals(entry.batch_operation.type, 'update')
+ self.assertEqual(entry.batch_operation.type, 'update')
if entry.batch_id.text == '4':
- self.assertEquals(entry.batch_operation.type, 'delete')
- self.assertEquals(entry.id.text, 'http://www.google.com/calendar/'
+ self.assertEqual(entry.batch_operation.type, 'delete')
+ self.assertEqual(entry.id.text, 'http://www.google.com/calendar/'
'feeds/default/private/full/'
'd8qbg9egk1n6lhsgq1sjbqffqc')
@@ -834,11 +834,11 @@
"""Asserts that the web content link is the correct type and contains the
expected values"""
- self.assert_(isinstance(web_content_link, gdata.calendar.WebContentLink),
+ self.assertTrue(isinstance(web_content_link, gdata.calendar.WebContentLink),
"Web content link element must be an " +
"instance of gdata.calendar.WebContentLink: %s" % web_content_link)
expected_rel = '%s/%s' % (gdata.calendar.GCAL_NAMESPACE, 'webContent')
- self.assertEquals(expected_rel, web_content_link.rel)
+ self.assertEqual(expected_rel, web_content_link.rel)
self.assertEquaRefactoringTool: Refactored ./tests/gdata_tests/calendar_resource/live_client_test.py
l(expected_title, web_content_link.title)
self.assertEqual(expected_href, web_content_link.href)
self.assertEqual(expected_type, web_content_link.type)
@@ -848,12 +848,12 @@
"""Asserts that the web content element is the correct type and contains
the expected values"""
- self.assert_(isinstance(web_content_element, gdata.calendar.WebContent),
+ self.assertTrue(isinstance(web_content_element, gdata.calendar.WebContent),
"Calendar event entry element must be an " +
"instance of gdata.calendar.WebContent: %s" % web_content_element)
- self.assertEquals(expected_width, web_content_element.width)
- self.assertEquals(expected_height, web_content_element.height)
- self.assertEquals(expected_url, web_content_element.url)
+ self.assertEqual(expected_width, web_content_element.width)
+ self.assertEqual(expected_height, web_content_element.height)
+ self.assertEqual(expected_url, web_content_element.url)
def assertValidWebContentGadget(self, expected_url=None, expected_width=None,
expected_height=None, expected_pref_name=None, expected_pref_value=None,
@@ -861,15 +861,15 @@
"""Asserts that the web content element is the correct type and contains
the expected values"""
- self.assert_(isinstance(web_content_element, gdata.calendar.WebContent),
+ self.assertTrue(isinstance(web_content_element, gdata.calendar.WebContent),
"Calendar event entry element must be an " +
"instance of gdata.calendar.WebContent: %s" % web_content_element)
- self.assertEquals(expected_width, web_content_element.width)
- self.assertEquals(expected_height, web_content_element.height)
- self.assertEquals(expected_url, web_content_element.url)
- self.assertEquals(expected_pref_name,
+ self.assertEqual(expected_width, web_content_element.width)
+ self.assertEqual(expected_height, web_content_element.height)
+ self.assertEqual(expected_url, web_content_element.url)
+ self.assertEqual(expected_pref_name,
web_content_element.gadget_pref[0].name)
- self.assertEquals(expected_pref_value,
+ self.assertEqual(expected_pref_value,
web_content_element.gadget_pref[0].value)
def testSampleCode(self):
@@ -898,8 +898,8 @@
ep.value = 'val'
xml_string = ep.ToString()
ep2 = gdata.ExtendedPropertyFromString(xml_string)
- self.assertEquals(ep.name, ep2.name)
- self.assertEquals(ep.value, ep2.value)
+ self.assertEqual(ep.name, ep2.name)
+ self.assertEqual(ep.value, ep2.value)
if __name__ == '__main__':
--- ./tests/gdata_tests/calendar_resource/live_client_test.py (original)
+++ ./tests/gdata_tests/calendar_resource/live_client_test.py (refactored)
@@ -85,8 +85,8 @@
'CR-NYC-14-12-BR', 'Boardroom',
('This conference room is in New York City, building 14, floor 12, '
'Boardroom'), 'CR')
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
self.client.delete_resource('CR-NYC-14-12-BR')
# If the test failed to run to completion
# the resource may already exist
@@ -95,7 +95,7 @@
('This conference room is in New York City, building 14, floor 12, '
'Boardroom'), 'CR')
- self.assert_(isinstance(new_entry,
+ self.assertTrue(isinstance(new_entry,
gdata.calendar_resource.data.CalendarResourceEntry))
self.assertEqual(new_entry.resource_id, 'CR-NYC-14-12-BR')
self.assertEqual(new_entry.resource_common_name, 'Boardroom')
@@ -105,7 +105,7 @@
self.assertEqual(new_entry.resource_type, 'CR')
fetched_entry = self.client.get_resource(resource_id='CR-NYC-14-12-BR')
- self.assert_(isinstance(fetched_entry,
+ self.assertTrue(isinstance(fetched_entry,
gdata.calendar_resource.data.CalendarResourceEntry))
self.assertEqual(fetched_entry.resource_id, 'CR-NYC-14-12-BR')
self.assertEqual(fetched_entry.resource_common_name, 'Boardroom')
@@ -119,7 +119,7 @@
new_entry.resource_description = 'ThisRefactoringTool: Refactored ./tests/gdata_tests/calendar_resource/data_test.py
RefactoringTool: Refactored ./tests/gdata_tests/calendar/service_test.py
conference room is in Mountain View'
new_entry.resource_type = 'BR'
updated_entry = self.client.update(new_entry)
- self.assert_(isinstance(updated_entry,
+ self.assertTrue(isinstance(updated_entry,
gdata.calendar_resource.data.CalendarResourceEntry))
self.assertEqual(updated_entry.resource_id, 'CR-MTV-14-12-BR')
self.assertEqual(updated_entry.resource_common_name, 'Executive Boardroom')
--- ./tests/gdata_tests/calendar_resource/data_test.py (original)
+++ ./tests/gdata_tests/calendar_resource/data_test.py (refactored)
@@ -34,39 +34,39 @@
gdata.calendar_resource.data.CalendarResourceFeed)
def testCalendarResourceEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.calendar_resource.data.CalendarResourceEntry))
- self.assertEquals(self.entry.resource_id, 'CR-NYC-14-12-BR')
- self.assertEquals(self.entry.resource_common_name, 'Boardroom')
- self.assertEquals(self.entry.resource_description,
+ self.assertEqual(self.entry.resource_id, 'CR-NYC-14-12-BR')
+ self.assertEqual(self.entry.resource_common_name, 'Boardroom')
+ self.assertEqual(self.entry.resource_description,
('This conference room is in New York City, building 14, floor 12, '
'Boardroom'))
- self.assertEquals(self.entry.resource_type, 'CR')
+ self.assertEqual(self.entry.resource_type, 'CR')
def testCalendarResourceFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.calendar_resource.data.CalendarResourceFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.calendar_resource.data.CalendarResourceEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.calendar_resource.data.CalendarResourceEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
'https://apps-apis.google.com/feeds/calendar/resource/2.0/yourdomain.com/CR-NYC-14-12-BR')
- self.assertEquals(self.feed.entry[0].resource_id, 'CR-NYC-14-12-BR')
- self.assertEquals(self.feed.entry[0].resource_common_name, 'Boardroom')
- self.assertEquals(self.feed.entry[0].resource_description,
+ self.assertEqual(self.feed.entry[0].resource_id, 'CR-NYC-14-12-BR')
+ self.assertEqual(self.feed.entry[0].resource_common_name, 'Boardroom')
+ self.assertEqual(self.feed.entry[0].resource_description,
('This conference room is in New York City, building 14, floor 12, '
'Boardroom'))
- self.assertEquals(self.feed.entry[0].resource_type, 'CR')
- self.assertEquals(self.feed.entry[1].resource_id,
+ self.assertEqual(self.feed.entry[0].resource_type, 'CR')
+ self.assertEqual(self.feed.entry[1].resource_id,
'(Bike)-London-43-Lobby-Bike-1')
- self.assertEquals(self.feed.entry[1].resource_common_name, 'London bike-1')
- self.assertEquals(self.feed.entry[1].resource_description,
+ self.assertEqual(self.feed.entry[1].resource_common_name, 'London bike-1')
+ self.assertEqual(self.feed.entry[1].resource_description,
'Bike is in London at building 43\'s lobby.')
- self.assertEquals(self.feed.entry[1].resource_type, '(Bike)')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[1].resource_type, '(Bike)')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
'https://apps-apis.google.com/a/feeds/calendar/resource/2.0/yourdomain.com/(Bike)-London-43-Lobby-Bike-1')
--- ./tests/gdata_tests/calendar/service_test.py (original)
+++ ./tests/gdata_tests/calendar/service_test.py (refactored)
@@ -46,11 +46,11 @@
pass
def testUrlScrubbing(self):
- self.assertEquals(self.cal_client._RemoveStandardUrlPrefix(
+ self.assertEqual(self.cal_client._RemoveStandardUrlPrefix(
'/test'), '/test')
- self.assertEquals(self.cal_client._RemoveStandardUrlPrefix(
+ self.assertEqual(self.cal_client._RemoveStandardUrlPrefix(
'http://www.google.com/calendar/test'), '/calendar/test')
- self.assertEquals(self.cal_client._RemoveStandardUrlPrefix(
+ self.assertEqual(self.cal_client._RemoveStandardUrlPrefix(
'https://www.google.com/calendar/test'),
'https://www.google.com/calendar/test')
@@ -67,22 +67,22 @@
calendar = gdata.calendar.CalendarListEntry()
calendar.id = atom.Id(text=subscription_id)
returned_calendar = self.cal_client.InsertCalendarSubscription(calendar)
- self.assertEquals(subscription_url, returned_calendar.id.text)
- self.assertEquals('Google Doodles', returned_calendar.title.text)
+ self.assertEqual(subscription_url, returned_calendar.id.text)
+ self.assertEqual('Google Doodles', returned_calendar.title.text)
# Update subscription
calendar_to_update = self.cal_client.GetCalendarListEntry(subscription_url)
- self.assertEquals('Google Doodles', calendar_to_update.title.text)
- self.assertEquals('true', calendar_to_update.selected.value)
+ self.assertEqual('Google Doodles', calendar_to_update.title.text)
+ self.assertEqual('true', calendar_to_update.selected.value)
calendar_to_update.selected.value = 'false'
- self.assertEquals('false', calendar_to_update.selected.value)
+ self.assertEqual('false', calendar_to_update.selected.value)
updated_calendar = self.cal_client.UpdateCalendar(calendar_to_update)
- self.assertEquals('false', updated_calendar.selected.value)
+ self.assertEqual('false', updated_calendar.selected.value)
# Delete subscription
response = self.cal_client.DeleteCalendarEntry(
returned_calendar.GetEditLink().href)
- self.assertEquals(True, response)
+ self.assertEqual(True, response)
def testPostUpdateAndDeleteCalendar(self):
"""Test posting a new calendar, updating it, deleting it"""
@@ -110,15 +110,15 @@
# Create calendar
new_calendar = self.cal_client.InsertCalendar(new_calendar=calendar)
- self.assertEquals(title, new_calendar.title.text)
- self.assertEquals(description, new_calendar.summary.text)
- self.assertEquals(location, new_calendar.where.value_string)
- self.assertEquals(color, new_calendar.color.value)
- self.assertEquals(time_zone, new_calendar.timezone.value)
+ self.assertEqual(title, new_calendar.title.text)
+ self.assertEqual(description, new_calendar.summary.text)
+ self.assertEqual(location, new_calendar.where.value_string)
+ self.assertEqual(color, new_calendar.color.value)
+ self.assertEqual(time_zone, new_calendar.timezone.value)
if hidden:
- self.assertEquals('true', new_calendar.hidden.value)
+ self.assertEqual('true', new_calendar.hidden.value)
else:
- self.assertEquals('false', new_calendar.hidden.value)
+ self.assertEqual('false', new_calendar.hidden.value)
# Update calendar
calendar_to_update = self.cal_client.GetCalendarListEntry(
@@ -126,7 +126,7 @@
updated_title = 'This is the updated title'
calendar_to_update.title.text = updated_title
updated_calendar = self.cal_client.UpdateCalendar(calendar_to_update)
- self.assertEquals(updated_title, updated_calendar.title.text)
+ self.assertEqual(updated_title, updated_calendar.title.text)
# Delete calendar
calendar_to_delete = self.cal_client.GetCalendarListEntry(
@@ -157,7 +157,7 @@
new_event = self.cal_client.InsertEvent(event,
'/calendar/feeds/default/private/full')
- self.assertEquals(event.extended_property[0].value,
+ self.assertEqual(event.extended_property[0].value,
new_event.extended_property[0].value)
# Delete the event
@@ -239,11 +239,11 @@
'/calendar/feeds/default/private/full')
# Ensure that atom data returned from calendar server equals atom data sent
- self.assertEquals(event.title.text, new_event.title.text)
- self.assertEquals(event.content.text, new_event.content.text)
+ self.assertEqual(event.title.text, new_event.title.text)
+ self.assertEqual(event.content.text, new_event.content.text)
# Ensure that gd:where data returned from calendar equals value sent
- self.assertEquals(event.where[0].value_string,
+ self.assertEqual(event.where[0].value_string,
new_event.where[0].value_string)
# Commented out as dateutil is not in this repository
@@ -265,7 +265,7 @@
event_to_update.GetEditLink().href, event_to_update)
# Ensure that updated title was set in the updated event
- self.assertEquals(event_to_update.title.text, updated_event.title.text)
+ self.assertEqual(event_to_update.title.text, updated_event.title.text)
# Delete the event
self.cal_client.DeleteEvent(updated_event.GetEditLink().href)
@@ -279,11 +279,11 @@
after_delete_query)
# Ensure feed returned at max after_delete_query.max_results events
- self.assert_(
+ self.assertTrue(
len(after_delete_query_result.entry) <= after_delete_query.max_results)
# Ensure status of returned event is canceled
- self.assertEquals(after_delete_query_result.entry[0].event_status.value,
+ self.assertEqual(after_delete_query_result.entry[0].event_status.value,
'CANCELED')
def testEventWithSyncEventAndUID(self):
@@ -313,7 +313,7 @@
# the format doesn't seem to be important per the RFC except for being
# globally unique.
uid_string = ''
- for i in xrange(121):
+ for i in range(121):
uid_string += "%X" % r.randint(0, 0xf)
# Set event data
@@ -337,7 +337,7 @@
bad_event = self.cal_client.InsertEvent(event,
'/calendar/feeds/default/private/full')
self.fail('Was able to insert an event with a duplicate UID')
- except gdata.service.RequestError, error:
+ except gdata.service.RequestError as error:
# for the current problem with redirects, just re-raise so the
# failure doesn't seem to be because of the duplicate UIDs.
status = error[0]['status']
@@ -345,16 +345,16 @@
raise
# otherwise, make sure it was the right error
- self.assertEquals(error[0]['status'], 409)
- self.assertEquals(error[0]['reason'], 'Conflict')
+ self.assertEqual(error[0]['status'], 409)
+ self.assertEqual(error[0]['reason'], 'Conflict')
# Ensure that atom data returned from calendar server equals atom data
# sent
- self.assertEquals(event.title.text, new_event.title.text)
- self.assertEquals(event.content.text, new_event.content.text)
+ self.assertEqual(event.title.text, new_event.title.text)
+ self.assertEqual(event.content.text, new_event.content.text)
# Ensure that gd:where data returned from calendar equals value sent
- self.assertEquals(event.where[0].value_string,
+ self.assertEqual(event.where[0].value_string,
new_event.where[0].value_string)
# Delete the event
@@ -384,11 +384,11 @@
batch_result = self.cal_client.ExecuteBatch(batch_request,
gdata.calendar.service.DEFAULT_BATCH_URL)
- self.assertEquals(len(batch_result.entry), 1)
- self.assertEquals(batch_result.entry[0].title.text, random_event_title)
- self.assertEquals(batch_result.entry[0].batch_operation.type,
+ self.assertEqual(len(batch_result.entry), 1)
+ self.assertEqual(batch_result.entry[0].title.text, random_event_title)
+ self.assertEqual(batch_result.entry[0].batch_operation.type,
gdata.BATCH_INSERT)
- self.assertEquals(batch_result.GetBatchLink().href,
+ self.assertEqual(batch_result.GetBatchLink().href,
gdata.calendar.service.DEFAULT_BATCH_URL)
# Create a batch request to delete the newly created entry.
@@ -397,15 +397,15 @@
batch_delete_result = self.cal_client.ExecuteBatch(batch_delete_request,
batch_result.GetBatchLink().href)
- self.assertEquals(len(batch_delete_result.entry), 1)
- self.assertEquals(batch_delete_result.entry[0].batch_operation.type,
+ self.assertEqual(len(batch_delete_result.entry), 1)
+ selRefactoringTool: Refactored ./tests/gdata_tests/calendar/calendar_acl_test.py
f.assertEqual(batch_delete_result.entry[0].batch_operation.type,
gdata.BATCH_DELETE)
def testCorrectReturnTypesForGetMethods(self):
self.cal_client.ProgrammaticLogin()
result = self.cal_client.GetCalendarEventFeed()
- self.assertEquals(isinstance(result, gdata.calendar.CalendarEventFeed),
+ self.assertEqual(isinstance(result, gdata.calendar.CalendarEventFeed),
True)
def testValidHostName(self):
@@ -417,11 +417,11 @@
self.cal_client.ssl = True
self.cal_client.http_client = mock_http
self.cal_client.SetAuthSubToken('foo')
- self.assertEquals(str(self.cal_client.token_store.find_token(
+ self.assertEqual(str(self.cal_client.token_store.find_token(
'https://www.google.com/calendar/feeds/default/allcalendars/full')),
'AuthSub token=foo')
resp = self.cal_client.Get('/calendar/feeds/default/allcalendars/full')
- self.assert_(resp is not None)
+ self.assertTrue(resp is not None)
class CalendarEventQueryUnitTest(unittest.TestCase):
@@ -431,31 +431,31 @@
def testOrderByValidatesValues(self):
self.query.orderby = 'lastmodified'
- self.assertEquals(self.query.orderby, 'lastmodified')
+ self.assertEqual(self.query.orderby, 'lastmodified')
try:
self.query.orderby = 'illegal input'
self.fail()
except gdata.calendar.service.Error:
- self.assertEquals(self.query.orderby, 'lastmodified')
+ self.assertEqual(self.query.orderby, 'lastmodified')
def testSortOrderValidatesValues(self):
self.query.sortorder = 'a'
- self.assertEquals(self.query.sortorder, 'a')
+ self.assertEqual(self.query.sortorder, 'a')
try:
self.query.sortorder = 'illegal input'
self.fail()
except gdata.calendar.service.Error:
- self.assertEquals(self.query.sortorder, 'a')
+ self.assertEqual(self.query.sortorder, 'a')
def testTimezoneParameter(self):
self.query.ctz = 'America/Los_Angeles'
- self.assertEquals(self.query['ctz'], 'America/Los_Angeles')
- self.assert_(self.query.ToUri().find('America%2FLos_Angeles') > -1)
+ self.assertEqual(self.query['ctz'], 'America/Los_Angeles')
+ self.assertTrue(self.query.ToUri().find('America%2FLos_Angeles') > -1)
if __name__ == '__main__':
print ('Google Calendar Test\nNOTE: Please run these tests only with a '
'test account. The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ username = input('Please enter your username: ')
password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/calendar/calendar_acl_test.py (original)
+++ ./tests/gdata_tests/calendar/calendar_acl_test.py (refactored)
@@ -73,7 +73,7 @@
try:
self.cal_client.GetCalendarAclFeed(self._aclFeedUri)
self.fail("Unauthenticated request should fail")
- except gdata.service.RequestError, error:
+ except gdata.service.RequestError as error:
self.assertEqual(error[0]['status'], 401)
self.assertEqual(error[0]['reason'], "Authorization required")
@@ -88,7 +88,7 @@
try:
self.cal_client.GetCalendarAclEntry(self._aclEntryUri)
self.fail("Unauthenticated request should fail");
- except gdata.service.RequestError, error:
+ except gdata.service.RequestError as error:
self.assertEqual(error[0]['status'], 401)
self.assertEqual(error[0]['reason'], "Authorization required")
@@ -131,7 +131,7 @@
# Delete the event
self.cal_client.DeleteAclEntry(returned_rule.GetEditLink().href)
aclFeed = self.cal_client.GetCalendarAclFeed(self._aclFeedUri)
- self.assertEquals(original_rule_count, len(aclFeed.entry))
+ self.assertEqual(original_rule_count, len(aclFeed.entry))
def testUpdateAclChangeScopeValue(self):
"""Fiendishly try to insert a test ACL rule and attempt to change the scope value (i.e. username).
@@ -147,7 +147,7 @@
updated_rule.scope.value = "user_%s@gmail.com" % (self._getRandomNumber())
try:
returned_rule = self.cal_client.UpdRefactoringTool: Refactored ./tests/gdata_tests/books_test.py
ateAclEntry(returned_rule.GetEditLink().href, updated_rule)
- except gdata.service.RequestError, error:
+ except gdata.service.RequestError as error:
self.assertEqual(error[0]['status'], 403)
self.assertEqual(error[0]['reason'], "Forbidden")
@@ -168,7 +168,7 @@
updated_rule.scope.type = "domain"
try:
returned_rule = self.cal_client.UpdateAclEntry(returned_rule.GetEditLink().href, updated_rule)
- except gdata.service.RequestError, error:
+ except gdata.service.RequestError as error:
self.assertEqual(error[0]['status'], 403)
self.assertEqual(error[0]['reason'], "Forbidden")
@@ -193,9 +193,9 @@
self.cal_client.DeleteAclEntry(updated_rule.GetEditLink().href)
if __name__ == '__main__':
- print ('NOTE: Please run these tests only with a test account. ' +
- 'The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ print(('NOTE: Please run these tests only with a test account. ' +
+ 'The tests may delete or update your data.'))
+ username = input('Please enter your username: ')
password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/books_test.py (original)
+++ ./tests/gdata_tests/books_test.py (refactored)
@@ -14,38 +14,38 @@
def testBookEntryFromString(self):
entry = gdata.books.Book.FromString(test_data.BOOK_ENTRY)
- self.assert_(isinstance(entry, gdata.books.Book))
- self.assertEquals([x.text for x in entry.creator], ['John Rawls'])
- self.assertEquals(entry.date.text, '1999')
- self.assertEquals(entry.format.text, '538 pages')
- self.assertEquals([x.text for x in entry.identifier],
+ self.assertTrue(isinstance(entry, gdata.books.Book))
+ self.assertEqual([x.text for x in entry.creator], ['John Rawls'])
+ self.assertEqual(entry.date.text, '1999')
+ self.assertEqual(entry.format.text, '538 pages')
+ self.assertEqual([x.text for x in entry.identifier],
['b7GZr5Btp30C', 'ISBN:0198250541', 'ISBN:9780198250548'])
- self.assertEquals([x.text for x in entry.publisher],
+ self.assertEqual([x.text for x in entry.publisher],
['Oxford University Press'])
- self.assertEquals(entry.subject, None)
- self.assertEquals([x.text for x in entry.dc_title],
+ self.assertEqual(entry.subject, None)
+ self.assertEqual([x.text for x in entry.dc_title],
['A theory of justice'])
- self.assertEquals(entry.viewability.value,
+ self.assertEqual(entry.viewability.value,
'http://schemas.google.com/books/2008#view_partial')
- self.assertEquals(entry.embeddability.value,
+ self.assertEqual(entry.embeddability.value,
'http://schemas.google.com/books/2008#embeddable')
- self.assertEquals(entry.review, None)
- self.assertEquals([getattr(entry.rating, x) for x in
+ self.assertEqual(entry.review, None)
+ self.assertEqual([getattr(entry.rating, x) for x in
("min", "max", "average", "value")], ['1', '5', '4.00', None])
- self.assertEquals(entry.GetThumbnailLink().href,
+ self.assertEqual(entry.GetThumbnailLink().href,
'http://bks0.books.google.com/books?id=b7GZr5Btp30C&printsec=frontcover&img=1&zoom=5&sig=ACfU3U121bWZsbjBfVwVRSK2o982jJTd1w&source=gbs_gdata')
- self.assertEquals(entry.GetInfoLink().href,
+ self.assertEqual(entry.GetInfoLink().href,
'http://books.google.com/books?id=b7GZr5Btp30C&ie=ISO-8859-1&source=gbs_gdata')
- self.assertEquals(entry.GetPreviewLink(), None)
- self.assertEquals(entry.GetAnnotationLink().href,
+ self.assertEqual(entry.GetPreviewLink(), None)
+ self.assertEqual(entry.GetAnnotationLink().href,
'http://www.google.com/books/feeds/users/me/volumes')
- self.assertEquals(entry.get_google_id(), 'b7GZr5Btp30C')
+ self.assertEqual(entry.get_google_id(), 'b7GZr5Btp30C')
def testBookFeedFRefactoringTool: Refactored ./tests/gdata_tests/books/service_test.py
RefactoringTool: Refactored ./tests/gdata_tests/blogger_test.py
romString(self):
feed = gdata.books.BookFeed.FromString(test_data.BOOK_FEED)
- self.assert_(isinstance(feed, gdata.books.BookFeed))
- self.assertEquals( len(feed.entry), 1)
- self.assert_(isinstance(feed.entry[0], gdata.books.Book))
+ self.assertTrue(isinstance(feed, gdata.books.BookFeed))
+ self.assertEqual( len(feed.entry), 1)
+ self.assertTrue(isinstance(feed.entry[0], gdata.books.Book))
def testBookEntryToDict(self):
book = gdata.books.Book()
--- ./tests/gdata_tests/books/service_test.py (original)
+++ ./tests/gdata_tests/books/service_test.py (refactored)
@@ -27,12 +27,12 @@
def testPublicSearch(self):
entry = self.service.get_by_google_id("b7GZr5Btp30C")
- self.assertEquals((entry.creator[0].text, entry.dc_title[0].text),
+ self.assertEqual((entry.creator[0].text, entry.dc_title[0].text),
('John Rawls', 'A theory of justice'))
feed = self.service.search_by_keyword(isbn="9780198250548")
feed1 = self.service.search("9780198250548")
- self.assertEquals(len(feed.entry), 1)
- self.assertEquals(len(feed1.entry), 1)
+ self.assertEqual(len(feed.entry), 1)
+ self.assertEqual(len(feed1.entry), 1)
def testLibraryCrd(self):
"""
@@ -45,11 +45,11 @@
entry = self.service.get_by_google_id("b7GZr5Btp30C")
entry = self.service.add_item_to_library(entry)
lib = list(self.service.get_library())
- self.assert_(entry.to_dict()['title'] in
+ self.assertTrue(entry.to_dict()['title'] in
[x.to_dict()['title'] for x in lib])
self.service.remove_item_from_library(entry)
lib = list(self.service.get_library())
- self.assert_(entry.to_dict()['title'] not in
+ self.assertTrue(entry.to_dict()['title'] not in
[x.to_dict()['title'] for x in lib])
def testAnnotations(self):
@@ -58,7 +58,7 @@
if __name__ == "__main__":
- print "Please use a test account. May cause data loss."
- username = raw_input("Google Username: ").strip()
+ print("Please use a test account. May cause data loss.")
+ username = input("Google Username: ").strip()
password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/blogger_test.py (original)
+++ ./tests/gdata_tests/blogger_test.py (refactored)
@@ -28,42 +28,42 @@
def testBlogEntryFromString(self):
entry = gdata.blogger.BlogEntryFromString(test_data.BLOG_ENTRY)
- self.assertEquals(entry.GetBlogName(), 'blogName')
- self.assertEquals(entry.GetBlogId(), 'blogID')
- self.assertEquals(entry.title.text, 'Lizzy\'s Diary')
+ self.assertEqual(entry.GetBlogName(), 'blogName')
+ self.assertEqual(entry.GetBlogId(), 'blogID')
+ self.assertEqual(entry.title.text, 'Lizzy\'s Diary')
def testBlogPostFeedFromString(self):
feed = gdata.blogger.BlogPostFeedFromString(test_data.BLOG_POSTS_FEED)
- self.assertEquals(len(feed.entry), 1)
- self.assert_(isinstance(feed, gdata.blogger.BlogPostFeed))
- self.assert_(isinstance(feed.entry[0], gdata.blogger.BlogPostEntry))
- self.assertEquals(feed.entry[0].GetPostId(), 'postID')
- self.assertEquals(feed.entry[0].GetBlogId(), 'blogID')
- self.assertEquals(feed.entry[0].title.text, 'Quite disagreeable')
+ self.assertEqual(len(feed.entry), 1)
+ self.assertTrue(isinstance(feed, gdata.blogger.BlogPostFeed))
+ self.assertTrue(isinstance(feed.entry[0], gdata.blogger.BlogPostEntry))
+ self.assertEqual(feed.entry[0].GetPostId(), 'postID')
+ self.assertEqual(feed.entry[0].GetBlogId(), 'blogID')
+ self.assertEqual(feed.entry[0].title.text, 'Quite disagreeable')
def testCommentFeedFromString(self):
feed = gdata.blogger.CommentFeedFromString(test_data.BLOG_COMMENTS_FEED)
- self.assertEquals(len(feed.entry), 1)
- self.assert_(isinstance(feed, gdata.blogger.CommentFeed))
- self.assert_(isinstance(feed.entry[0], gdata.blogger.CommentEntry))
- self.assertEquals(feed.entry[0].GetBlogId(), 'blogID')
- self.assertEquaRefactoringTool: Refactored ./tests/gdata_tests/blogger/service_test.py
ls(feed.entry[0].GetCommentId(), 'commentID')
- self.assertEquals(feed.entry[0].title.text, 'This is my first comment')
- self.assertEquals(feed.entry[0].in_reply_to.source,
+ self.assertEqual(len(feed.entry), 1)
+ self.assertTrue(isinstance(feed, gdata.blogger.CommentFeed))
+ self.assertTrue(isinstance(feed.entry[0], gdata.blogger.CommentEntry))
+ self.assertEqual(feed.entry[0].GetBlogId(), 'blogID')
+ self.assertEqual(feed.entry[0].GetCommentId(), 'commentID')
+ self.assertEqual(feed.entry[0].title.text, 'This is my first comment')
+ self.assertEqual(feed.entry[0].in_reply_to.source,
'http://blogName.blogspot.com/feeds/posts/default/postID')
- self.assertEquals(feed.entry[0].in_reply_to.ref,
+ self.assertEqual(feed.entry[0].in_reply_to.ref,
'tag:blogger.com,1999:blog-blogID.post-postID')
- self.assertEquals(feed.entry[0].in_reply_to.href,
+ self.assertEqual(feed.entry[0].in_reply_to.href,
'http://blogName.blogspot.com/2007/04/first-post.html')
- self.assertEquals(feed.entry[0].in_reply_to.type, 'text/html')
+ self.assertEqual(feed.entry[0].in_reply_to.type, 'text/html')
def testIdParsing(self):
entry = gdata.blogger.BlogEntry()
entry.id = atom.Id(
text='tag:blogger.com,1999:user-146606542.blog-4023408167658848')
- self.assertEquals(entry.GetBlogId(), '4023408167658848')
+ self.assertEqual(entry.GetBlogId(), '4023408167658848')
entry.id = atom.Id(text='tag:blogger.com,1999:blog-4023408167658848')
- self.assertEquals(entry.GetBlogId(), '4023408167658848')
+ self.assertEqual(entry.GetBlogId(), '4023408167658848')
class InReplyToTest(unittest.TestCase):
@@ -74,10 +74,10 @@
type='text/html')
xml_string = str(in_reply_to)
parsed = gdata.blogger.InReplyToFromString(xml_string)
- self.assertEquals(parsed.source, in_reply_to.source)
- self.assertEquals(parsed.href, in_reply_to.href)
- self.assertEquals(parsed.ref, in_reply_to.ref)
- self.assertEquals(parsed.type, in_reply_to.type)
+ self.assertEqual(parsed.source, in_reply_to.source)
+ self.assertEqual(parsed.href, in_reply_to.href)
+ self.assertEqual(parsed.ref, in_reply_to.ref)
+ self.assertEqual(parsed.type, in_reply_to.type)
class CommentEntryTest(unittest.TestCase):
@@ -87,8 +87,8 @@
in_reply_to=gdata.blogger.InReplyTo(
source='http://example.com/my_post'))
parsed = gdata.blogger.CommentEntryFromString(str(comment))
- self.assertEquals(parsed.in_reply_to.source, comment.in_reply_to.source)
- self.assertEquals(parsed.content.text, comment.content.text)
+ self.assertEqual(parsed.in_reply_to.source, comment.in_reply_to.source)
+ self.assertEqual(parsed.content.text, comment.content.text)
if __name__ == '__main__':
--- ./tests/gdata_tests/blogger/service_test.py (original)
+++ ./tests/gdata_tests/blogger/service_test.py (refactored)
@@ -49,18 +49,18 @@
posted = self.client.AddPost(new_entry, blog_id=test_blog_id)
- self.assertEquals(posted.title.text, new_entry.title.text)
+ self.assertEqual(posted.title.text, new_entry.title.text)
# Should be one category in the posted entry for the 'test' label.
- self.assertEquals(len(posted.category), 1)
- self.assert_(isinstance(posted, gdata.blogger.BlogPostEntry))
+ self.assertEqual(len(posted.category), 1)
+ self.assertTrue(isinstance(posted, gdata.blogger.BlogPostEntry))
# Change the title and add more labels.
posted.title.text = 'Updated'
posted.AddLabel('second')
updated = self.client.UpdatePost(entry=posted)
- self.assertEquals(updated.title.text, 'Updated')
- self.assertEquals(len(updated.category), 2)
+ self.assertEqual(updated.title.text, 'Updated')
+ self.assertEqual(len(updated.category), 2)
# Cleanup and delete the draft blog post.
self.client.DeletePost(entry=posted)
@@ -79,7 +79,7 @@
new_comment.content = atom.Content(text='Test comment')
posted = self.client.AddComment(new_comment, blog_id=blog_id,
post_id=postRefactoringTool: Refactored ./tests/gdata_tests/blogger/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/blogger/data_test.py
_id)
- self.assertEquals(posted.content.text, new_comment.content.text)
+ self.assertEqual(posted.content.text, new_comment.content.text)
# Cleanup and delete the comment test blog post.
self.client.DeletePost(entry=target_post)
@@ -98,10 +98,10 @@
if __name__ == '__main__':
- print ('NOTE: Please run these tests only with a test account. ' +
- 'The tests may delete or update your data.')
- username = raw_input('Please enter your username: ')
+ print(('NOTE: Please run these tests only with a test account. ' +
+ 'The tests may delete or update your data.'))
+ username = input('Please enter your username: ')
password = getpass.getpass()
- test_blog_id = raw_input('Please enter the blog id for the test blog: ')
+ test_blog_id = input('Please enter the blog id for the test blog: ')
unittest.main()
--- ./tests/gdata_tests/blogger/live_client_test.py (original)
+++ ./tests/gdata_tests/blogger/live_client_test.py (refactored)
@@ -63,14 +63,14 @@
self.assertEqual(created.title.text, 'test post from BloggerClientTest')
self.assertEqual(created.content.text, 'Hey look, another test!')
self.assertEqual(len(created.category), 2)
- self.assert_(created.control is None)
+ self.assertTrue(created.control is None)
# Change the title of the blog post we just added.
created.title.text = 'Edited'
updated = self.client.update(created)
self.assertEqual(updated.title.text, 'Edited')
- self.assert_(isinstance(updated, gdata.blogger.data.BlogPost))
+ self.assertTrue(isinstance(updated, gdata.blogger.data.BlogPost))
self.assertEqual(updated.content.text, created.content.text)
# Delete the test entry from the blog.
@@ -91,8 +91,8 @@
'draft test post from BloggerClientTest')
self.assertEqual(created.content.text, 'This should only be a draft.')
self.assertEqual(len(created.category), 2)
- self.assert_(created.control is not None)
- self.assert_(created.control.draft is not None)
+ self.assertTrue(created.control is not None)
+ self.assertTrue(created.control.draft is not None)
self.assertEqual(created.control.draft.text, 'yes')
# Publish the blog post.
@@ -122,8 +122,8 @@
self.assertEqual(created.title.text, 'draft page from BloggerClientTest')
self.assertEqual(created.content.text, 'draft content')
- self.assert_(created.control is not None)
- self.assert_(created.control.draft is not None)
+ self.assertTrue(created.control is not None)
+ self.assertTrue(created.control.draft is not None)
self.assertEqual(created.control.draft.text, 'yes')
self.assertEqual(str(int(created.get_page_id())), created.get_page_id())
--- ./tests/gdata_tests/blogger/data_test.py (original)
+++ ./tests/gdata_tests/blogger/data_test.py (refactored)
@@ -29,45 +29,45 @@
def testBlogEntryFromString(self):
entry = atom.core.parse(test_data.BLOG_ENTRY, gdata.blogger.data.Blog)
- self.assertEquals(entry.GetBlogName(), 'blogName')
- self.assertEquals(entry.GetBlogId(), 'blogID')
- self.assertEquals(entry.title.text, 'Lizzy\'s Diary')
+ self.assertEqual(entry.GetBlogName(), 'blogName')
+ self.assertEqual(entry.GetBlogId(), 'blogID')
+ self.assertEqual(entry.title.text, 'Lizzy\'s Diary')
def testBlogPostFeedFromString(self):
feed = atom.core.parse(test_data.BLOG_POSTS_FEED,
gdata.blogger.data.BlogPostFeed)
- self.assertEquals(len(feed.entry), 1)
- self.assert_(isinstance(feed, gdata.blogger.data.BlogPostFeed))
- self.assert_(isinstance(feed.entry[0], gdata.blogger.data.BlogPost))
- self.assertEquals(feed.entry[0].GetPostId(), 'postID')
- self.assertEquals(feed.entry[0].GetBlogId(), 'blogID')
- self.assertEquals(feed.entry[0].title.text, 'Quite disagreeable')
+ self.assertEqual(len(feed.entry), 1)
+ self.assertTrue(isinstance(feed, gdata.blogger.data.BlogPostFeed))
+ self.assertTrue(isinstance(feed.entry[0], gdata.blogger.data.BlogPost))
+ self.assertEqual(feed.entry[0].GetPosRefactoringTool: Refactored ./tests/gdata_tests/auth_test.py
tId(), 'postID')
+ self.assertEqual(feed.entry[0].GetBlogId(), 'blogID')
+ self.assertEqual(feed.entry[0].title.text, 'Quite disagreeable')
def testCommentFeedFromString(self):
feed = atom.core.parse(test_data.BLOG_COMMENTS_FEED,
gdata.blogger.data.CommentFeed)
- self.assertEquals(len(feed.entry), 1)
- self.assert_(isinstance(feed, gdata.blogger.data.CommentFeed))
- self.assert_(isinstance(feed.entry[0], gdata.blogger.data.Comment))
- self.assertEquals(feed.entry[0].get_blog_id(), 'blogID')
- self.assertEquals(feed.entry[0].get_blog_name(), 'a-blogName')
- self.assertEquals(feed.entry[0].get_comment_id(), 'commentID')
- self.assertEquals(feed.entry[0].title.text, 'This is my first comment')
- self.assertEquals(feed.entry[0].in_reply_to.source,
+ self.assertEqual(len(feed.entry), 1)
+ self.assertTrue(isinstance(feed, gdata.blogger.data.CommentFeed))
+ self.assertTrue(isinstance(feed.entry[0], gdata.blogger.data.Comment))
+ self.assertEqual(feed.entry[0].get_blog_id(), 'blogID')
+ self.assertEqual(feed.entry[0].get_blog_name(), 'a-blogName')
+ self.assertEqual(feed.entry[0].get_comment_id(), 'commentID')
+ self.assertEqual(feed.entry[0].title.text, 'This is my first comment')
+ self.assertEqual(feed.entry[0].in_reply_to.source,
'http://blogName.blogspot.com/feeds/posts/default/postID')
- self.assertEquals(feed.entry[0].in_reply_to.ref,
+ self.assertEqual(feed.entry[0].in_reply_to.ref,
'tag:blogger.com,1999:blog-blogID.post-postID')
- self.assertEquals(feed.entry[0].in_reply_to.href,
+ self.assertEqual(feed.entry[0].in_reply_to.href,
'http://blogName.blogspot.com/2007/04/first-post.html')
- self.assertEquals(feed.entry[0].in_reply_to.type, 'text/html')
+ self.assertEqual(feed.entry[0].in_reply_to.type, 'text/html')
def testIdParsing(self):
entry = gdata.blogger.data.Blog()
entry.id = atom.data.Id(
text='tag:blogger.com,1999:user-146606542.blog-4023408167658848')
- self.assertEquals(entry.GetBlogId(), '4023408167658848')
+ self.assertEqual(entry.GetBlogId(), '4023408167658848')
entry.id = atom.data.Id(text='tag:blogger.com,1999:blog-4023408167658848')
- self.assertEquals(entry.GetBlogId(), '4023408167658848')
+ self.assertEqual(entry.GetBlogId(), '4023408167658848')
class InReplyToTest(unittest.TestCase):
@@ -78,10 +78,10 @@
source='http://example.com/my_post', type='text/html')
xml_string = str(in_reply_to)
parsed = atom.core.parse(xml_string, gdata.blogger.data.InReplyTo)
- self.assertEquals(parsed.source, in_reply_to.source)
- self.assertEquals(parsed.href, in_reply_to.href)
- self.assertEquals(parsed.ref, in_reply_to.ref)
- self.assertEquals(parsed.type, in_reply_to.type)
+ self.assertEqual(parsed.source, in_reply_to.source)
+ self.assertEqual(parsed.href, in_reply_to.href)
+ self.assertEqual(parsed.ref, in_reply_to.ref)
+ self.assertEqual(parsed.type, in_reply_to.type)
class CommentTest(unittest.TestCase):
@@ -92,8 +92,8 @@
in_reply_to=gdata.blogger.data.InReplyTo(
source='http://example.com/my_post'))
parsed = atom.core.parse(str(comment), gdata.blogger.data.Comment)
- self.assertEquals(parsed.in_reply_to.source, comment.in_reply_to.source)
- self.assertEquals(parsed.content.text, comment.content.text)
+ self.assertEqual(parsed.in_reply_to.source, comment.in_reply_to.source)
+ self.assertEqual(parsed.content.text, comment.content.text)
def suite():
--- ./tests/gdata_tests/auth_test.py (original)
+++ ./tests/gdata_tests/auth_test.py (refactored)
@@ -20,7 +20,7 @@
import re
import unittest
-import urllib
+import urllib.request, urllib.parse, urllib.error
import gdata.auth
@@ -67,13 +67,13 @@
parameters = body.split('&')
for param in parameters:
(name, value) = param.split('=')
- self.assert_(expected_name_value_pairs[name] == value)
+ self.assertTrue(expected_name_value_pairs[name] == value)
def testGenerateClientLoginAuthToken(self):
http_body = ('SID=DQAAAGgA7Zg8CTN\r\n'
'LSID=DQAAAGsAlk8BBbG\r\n'
'Auth=DQAAAGgAdk3fA5N')
- self.assert_(gdata.auth.GenerateClientLoginAuthToken(http_body) ==
+ self.assertTrue(gdata.auth.GenerateClientLoginAuthToken(http_body) ==
'GoogleLogin auth=DQAAAGgAdk3fA5N')
@@ -82,17 +82,17 @@
def testPostBodyShouldMatchShortExample(self):
auth_body = gdata.auth.GenerateClientLoginRequestBody('johndoe@gmail.com',
'north23AZ', 'cl', 'Gulp-CalGulp-1.05')
- self.assert_(-1 < auth_body.find('Email=johndoe%40gmail.com'))
- self.assert_(-1 < auth_body.find('Passwd=north23AZ'))
- self.assert_(-1 < auth_body.find('service=cl'))
- self.assert_(-1 < auth_body.find('source=Gulp-CalGulp-1.05'))
+ self.assertTrue(-1 < auth_body.find('Email=johndoe%40gmail.com'))
+ self.assertTrue(-1 < auth_body.find('Passwd=north23AZ'))
+ self.assertTrue(-1 < auth_body.find('service=cl'))
+ self.assertTrue(-1 < auth_body.find('source=Gulp-CalGulp-1.05'))
def testPostBodyShouldMatchLongExample(self):
auth_body = gdata.auth.GenerateClientLoginRequestBody('johndoe@gmail.com',
'north23AZ', 'cl', 'Gulp-CalGulp-1.05',
captcha_token='DQAAAGgA...dkI1', captcha_response='brinmar')
- self.assert_(-1 < auth_body.find('logintoken=DQAAAGgA...dkI1'))
- self.assert_(-1 < auth_body.find('logincaptcha=brinmar'))
+ self.assertTrue(-1 < auth_body.find('logintoken=DQAAAGgA...dkI1'))
+ self.assertTrue(-1 < auth_body.find('logincaptcha=brinmar'))
def testEquivalenceWithOldLogic(self):
email = 'jo@gmail.com'
@@ -100,7 +100,7 @@
account_type = 'HOSTED'
service = 'test'
source = 'auth test'
- old_request_body = urllib.urlencode({'Email': email,
+ old_request_body = urllib.parse.urlencode({'Email': email,
'Passwd': password,
'accountType': account_type,
'service': service,
@@ -108,7 +108,7 @@
new_request_body = gdata.auth.GenerateClientLoginRequestBody(email,
password, service, source, account_type=account_type)
for parameter in old_request_body.split('&'):
- self.assert_(-1 < new_request_body.find(parameter))
+ self.assertTrue(-1 < new_request_body.find(parameter))
class GenerateAuthSubUrlTest(unittest.TestCase):
@@ -116,24 +116,24 @@
def testDefaultParameters(self):
url = gdata.auth.GenerateAuthSubUrl('http://example.com/xyz?x=5',
'http://www.google.com/test/feeds')
- self.assert_(-1 < url.find(
+ self.assertTrue(-1 < url.find(
r'scope=http%3A%2F%2Fwww.google.com%2Ftest%2Ffeeds'))
- self.assert_(-1 < url.find(
+ self.assertTrue(-1 < url.find(
r'next=http%3A%2F%2Fexample.com%2Fxyz%3Fx%3D5'))
- self.assert_(-1 < url.find('secure=0'))
- self.assert_(-1 < url.find('session=1'))
+ self.assertTrue(-1 < url.find('secure=0'))
+ self.assertTrue(-1 < url.find('session=1'))
def testAllParameters(self):
url = gdata.auth.GenerateAuthSubUrl('http://example.com/xyz?x=5',
'http://www.google.com/test/feeds', secure=True, session=False,
request_url='https://example.com/auth')
- self.assert_(-1 < url.find(
+ self.assertTrue(-1 < url.find(
r'scope=http%3A%2F%2Fwww.google.com%2Ftest%2Ffeeds'))
- self.assert_(-1 < url.find(
+ self.assertTrue(-1 < url.find(
r'next=http%3A%2F%2Fexample.com%2Fxyz%3Fx%3D5'))
- self.assert_(-1 < url.find('secure=1'))
- self.assert_(-1 < url.find('session=0'))
- self.assert_(url.startswith('https://example.com/auth'))
+ self.assertTrue(-1 < url.find('secure=1'))
+ self.assertTrue(-1 < url.find('session=0'))
+ self.assertTrue(url.startswith('https://example.com/auth'))
class GenerateOAuthRequestTokenUrlTest(unittest.TestCase):
@@ -148,19 +148,19 @@
]
url = gdata.auth.GenerateOAuthRequestTokenUrl(
oauth_input_params, scopes=scopes)
- self.assertEquals('https', url.protocol)
- self.assertEquals('www.google.com', url.host)
- self.assertEquals('/accounts/OAuthGetRequestToken', url.path)
- self.assertEquals('1.0', url.params['oauth_version'])
- self.assertEquals('RSA-SHA1', url.params['oauth_signature_method'])
- self.assert_(url.params['oauth_nonce'])
- self.assert_(url.params['oauth_timestamp'])
+ self.assertEqual('https', url.protocol)
+ self.assertEqual('www.google.com', url.host)
+ self.assertEqual('/accounts/OAuthGetRequestToken', url.path)
+ self.assertEqual('1.0', url.params['oauth_version'])
+ self.assertEqual('RSA-SHA1', url.params['oauth_signature_method'])
+ self.assertTrue(url.params['oauth_nonce'])
+ self.assertTrue(url.params['oauth_timestamp'])
actual_scopes = url.params['scope'].split(' ')
- self.assertEquals(2, len(actual_scopes))
+ self.assertEqual(2, len(actual_scopes))
for scope in actual_scopes:
- self.assert_(scope in scopes)
- self.assertEquals(CONSUMER_KEY, url.params['oauth_consumer_key'])
- self.assert_(url.params['oauth_signature'])
+ self.assertTrue(scope in scopes)
+ self.assertEqual(CONSUMER_KEY, url.params['oauth_consumer_key'])
+ self.assertTrue(url.params['oauth_signature'])
def testAllParameters(self):
oauth_input_params = gdata.auth.OAuthInputParams(
@@ -171,20 +171,20 @@
oauth_input_params, scopes=scopes,
request_token_url='https://www.example.com/accounts/OAuthRequestToken',
extra_parameters={'oauth_version': '2.0', 'my_param': 'my_value'})
- self.assertEquals('https', url.protocol)
- self.assertEquals('www.example.com', url.host)
- self.assertEquals('/accounts/OAuthRequestToken', url.path)
- self.assertEquals('2.0', url.params['oauth_version'])
- self.assertEquals('HMAC-SHA1', url.params['oauth_signature_method'])
- self.assert_(url.params['oauth_nonce'])
- self.assert_(url.params['oauth_timestamp'])
+ self.assertEqual('https', url.protocol)
+ self.assertEqual('www.example.com', url.host)
+ self.assertEqual('/accounts/OAuthRequestToken', url.path)
+ self.assertEqual('2.0', url.params['oauth_version'])
+ self.assertEqual('HMAC-SHA1', url.params['oauth_signature_method'])
+ self.assertTrue(url.params['oauth_nonce'])
+ self.assertTrue(url.params['oauth_timestamp'])
actual_scopes = url.params['scope'].split(' ')
- self.assertEquals(1, len(actual_scopes))
+ self.assertEqual(1, len(actual_scopes))
for scope in actual_scopes:
- self.assert_(scope in scopes)
- self.assertEquals(CONSUMER_KEY, url.params['oauth_consumer_key'])
- self.assert_(url.params['oauth_signature'])
- self.assertEquals('my_value', url.params['my_param'])
+ self.assertTrue(scope in scopes)
+ self.assertEqual(CONSUMER_KEY, url.params['oauth_consumer_key'])
+ self.assertTrue(url.params['oauth_signature'])
+ self.assertEqual('my_value', url.params['my_param'])
class GenerateOAuthAuthorizationUrlTest(unittest.TestCase):
@@ -194,10 +194,10 @@
token_secret = 'SDFDSGSDADADSAF'
request_token = gdata.auth.OAuthToken(key=token_key, secret=token_secret)
url = gdata.auth.GenerateOAuthAuthorizationUrl(request_token)
- self.assertEquals('https', url.protocol)
- self.assertEquals('www.google.com', url.host)
- self.assertEquals('/accounts/OAuthAuthorizeToken', url.path)
- self.assertEquals(token_key, url.params['oauth_token'])
+ self.assertEqual('https', url.protocol)
+ self.assertEqual('www.google.com', url.host)
+ self.assertEqual('/accounts/OAuthAuthorizeToken', url.path)
+ self.assertEqual(token_key, url.params['oauth_token'])
def testAllParameters(self):
token_key = 'ABCDDSFFDSG'
@@ -214,14 +214,14 @@
callback_url='http://www.yourwebapp.com/print',
extra_params={'permission': '1'},
include_scopes_in_callback=True, scopes_param_prefix='token_scope')
- self.assertEquals('https', url.protocol)
- self.assertEquals('www.example.com', url.host)
- self.assertEquals('/accounts/OAuthAuthToken', url.path)
- self.assertEquals(token_key, url.params['oauth_token'])
+ self.assertEqual('https', url.protocol)
+ self.assertEqual('www.example.com', url.host)
+ self.assertEqual('/accounts/OAuthAuthToken', url.path)
+ self.assertEqual(token_key, url.params['oauth_token'])
expected_callback_url = ('http://www.yourwebapp.com/print?'
'token_scope=http%3A%2F%2Fabcd.example.com%2Ffeeds'
'+http%3A%2F%2Fwww.example.com%2Fabcd%2Ffeeds')
- self.assertEquals(expected_callback_url, url.params['oauth_callback'])
+ self.assertEqual(expected_callback_url, url.params['oauth_callback'])
class GenerateOAuthAccessTokenUrlTest(unittest.TestCase):
@@ -236,16 +236,16 @@
consumer_secret=CONSUMER_SECRET)
url = gdata.auth.GenerateOAuthAccessTokenUrl(authorized_request_token,
oauth_input_params)
- self.assertEquals('https', url.protocol)
- self.assertEquals('www.google.com', url.host)
- self.assertEquals('/accounts/OAuthGetAccessToken', url.path)
- self.assertEquals(token_key, url.params['oauth_token'])
- self.assertEquals('1.0', url.params['oauth_version'])
- self.assertEquals('HMAC-SHA1', url.params['oauth_signature_method'])
- self.assert_(url.params['oauth_nonce'])
- self.assert_(url.params['oauth_timestamp'])
- self.assertEquals(CONSUMER_KEY, url.params['oauth_consumer_key'])
- self.assert_(url.params['oauth_signature'])
+ self.assertEqual('https', url.protocol)
+ self.assertEqual('www.google.com', url.host)
+ self.assertEqual('/accounts/OAuthGetAccessToken', url.path)
+ self.assertEqual(token_key, url.params['oauth_token'])
+ self.assertEqual('1.0', url.params['oauth_version'])
+ self.assertEqual('HMAC-SHA1', url.params['oauth_signature_method'])
+ self.assertTrue(url.params['oauth_nonce'])
+ self.assertTrue(url.params['oauth_timestamp'])
+ self.assertEqual(CONSUMER_KEY, url.params['oauth_consumer_key'])
+ self.assertTrue(url.params['oauth_signature'])
def testAllParameters(self):
token_key = 'ABCDDSFFDSG'
@@ -257,34 +257,34 @@
authorized_request_token, oauth_input_params,
access_token_url='https://www.example.com/accounts/OAuthGetAccessToken',
oauth_version= '2.0')
- self.assertEquals('https', url.protocol)
- self.assertEquals('www.example.com', url.host)
- self.assertEquals('/accounts/OAuthGetAccessToken', url.path)
- self.assertEquals(token_key, url.params['oauth_token'])
- self.assertEquals('2.0', url.params['oauth_version'])
- self.assertEquals('RSA-SHA1', url.params['oauth_signature_method'])
- self.assert_(url.params['oauth_nonce'])
- self.assert_(url.params['oauth_timestamp'])
- self.assertEquals(CONSUMER_KEY, url.params['oauth_consumer_key'])
- self.assert_(url.params['oauth_signature'])
+ self.assertEqual('https', url.protocol)
+ self.assertEqual('www.example.com', url.host)
+ self.assertEqual('/accounts/OAuthGetAccessToken', url.path)
+ self.assertEqual(token_key, url.params['oauth_token'])
+ self.assertEqual('2.0', url.params['oauth_version'])
+ self.assertEqual('RSA-SHA1', url.params['oauth_signature_method'])
+ self.assertTrue(url.params['oauth_nonce'])
+ self.assertTrue(url.params['oauth_timestamp'])
+ self.assertEqual(CONSUMER_KEY, url.params['oauth_consumer_key'])
+ self.assertTrue(url.params['oauth_signature'])
class ExtractAuthSubTokensTest(unittest.TestCase):
def testGetTokenFromUrl(self):
url = 'http://www.yourwebapp.com/showcalendar.html?token=CKF50YzIH'
- self.assert_(gdata.auth.AuthSubTokenFromUrl(url) ==
+ self.assertTrue(gdata.auth.AuthSubTokenFromUrl(url) ==
'AuthSub token=CKF50YzIH')
- self.assert_(gdata.auth.TokenFromUrl(url) == 'CKF50YzIH')
+ self.assertTrue(gdata.auth.TokenFromUrl(url) == 'CKF50YzIH')
url = 'http://www.yourwebapp.com/showcalendar.html?token==tokenCKF50YzIH='
- self.assert_(gdata.auth.AuthSubTokenFromUrl(url) ==
+ self.assertTrue(gdata.auth.AuthSubTokenFromUrl(url) ==
'AuthSub token==tokenCKF50YzIH=')
- self.assert_(gdata.auth.TokenFromUrl(url) == '=tokenCKF50YzIH=')
+ self.assertTrue(gdata.auth.TokenFromUrl(url) == '=tokenCKF50YzIH=')
def testGetTokenFromHttpResponse(self):
response_body = ('Token=DQAA...7DCTN\r\n'
'Expiration=20061004T123456Z')
- self.assert_(gdata.auth.AuthSubTokenFromHttpBody(response_body) ==
+ self.assertTrue(gdata.auth.AuthSubTokenFromHttpBody(response_body) ==
'AuthSub token=DQAA...7DCTN')
class CreateAuthSubTokenFlowTest(unittest.TestCase):
@@ -293,33 +293,33 @@
request_url = gdata.auth.generate_auth_sub_url(next='http://example.com',
scopes=['http://www.blogger.com/feeds/',
'http://www.google.com/base/feeds/'])
- self.assertEquals(request_url.protocol, 'https')
- self.assertEquals(request_url.host, 'www.google.com')
- self.assertEquals(request_url.params['scope'],
+ self.assertEqual(request_url.protocol, 'https')
+ self.assertEqual(request_url.host, 'www.google.com')
+ self.assertEqual(request_url.params['scope'],
'http://www.blogger.com/feeds/ http://www.google.com/base/feeds/')
- self.assertEquals(request_url.params['hd'], 'default')
- self.assert_(request_url.params['next'].find('auth_sub_scopes') > -1)
- self.assert_(request_url.params['next'].startswith('http://example.com'))
+ self.assertEqual(request_url.params['hd'], 'default')
+ self.assertTrue(request_url.params['next'].find('auth_sub_scopes') > -1)
+ self.assertTrue(request_url.params['next'].startswith('http://example.com'))
# Use a more complicated 'next' URL.
request_url = gdata.auth.generate_auth_sub_url(
next='http://example.com/?token_scope=http://www.blogger.com/feeds/',
scopes=['http://www.blogger.com/feeds/',
'http://www.google.com/base/feeds/'])
- self.assert_(request_url.params['next'].find('auth_sub_scopes') > -1)
- self.assert_(request_url.params['next'].find('token_scope') > -1)
- self.assert_(request_url.params['next'].startswith('http://example.com/'))
+ self.assertTrue(request_url.params['next'].find('auth_sub_scopes') > -1)
+ self.assertTrue(request_url.params['next'].find('token_scope') > -1)
+ self.assertTrue(request_url.params['next'].startswith('http://example.com/'))
def testParseNextUrl(self):
url = ('http://example.com/?auth_sub_scopes=http%3A%2F%2Fwww.blogger.com'
'%2Ffeeds%2F+http%3A%2F%2Fwww.google.com%2Fbase%2Ffeeds%2F&'
'token=my_nifty_token')
token = gdata.auth.extract_auth_sub_token_from_url(url)
- self.assertEquals(token.get_token_string(), 'my_nifty_token')
- self.assert_(isinstance(token, gdata.auth.AuthSubToken))
- self.assert_(token.valid_for_scope('http://www.blogger.com/feeds/'))
- self.assert_(token.valid_for_scope('http://www.google.com/base/feeds/'))
- self.assert_(
+ self.assertEqual(token.get_token_string(), 'my_nifty_token')
+ self.assertTrue(isinstance(token, gdata.auth.AuthSubToken))
+ self.assertTrue(token.valid_for_scope('http://www.blogger.com/feeds/'))
+ self.assertTrue(token.valid_for_scope('http://www.google.com/base/feeds/'))
+ self.assertTrue(
not token.valid_for_scope('http://www.google.com/calendar/feeds/'))
# Parse a more complicated response.
@@ -328,19 +328,19 @@
'token_scope=http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F&'
'token=second_token')
token = gdata.auth.extract_auth_sub_token_from_url(url)
- self.assertEquals(token.get_token_string(), 'second_token')
- self.assert_(isinstance(token, gdata.auth.AuthSubToken))
- self.assert_(token.valid_for_scope('http://www.blogger.com/feeds/'))
- self.assert_(token.valid_for_scope('http://www.google.com/base/feeds/'))
- self.assert_(
+ self.assertEqual(token.get_token_string(), 'second_token')
+ self.assertTrue(isinstance(token, gdata.auth.AuthSubToken))
+ self.assertTrue(token.valid_for_scope('http://www.blogger.com/feeds/'))
+ self.assertTrue(token.valid_for_scope('http://www.google.com/base/feeds/'))
+ self.assertTrue(
not token.valid_for_scope('http://www.google.com/calendar/feeds/'))
def testParseNextWithNoToken(self):
token = gdata.auth.extract_auth_sub_token_from_url('http://example.com/')
- self.assert_(token is None)
+ self.assertTrue(token is None)
token = gdata.auth.extract_auth_sub_token_from_url(
'http://example.com/?no_token=foo&other=1')
- self.assert_(token is None)
+ self.assertTrue(token is None)
class ExtractClientLoginTokenTest(unittest.TestCase):
@@ -351,10 +351,10 @@
'Auth=DQAAAGgAdk3fA5N')
token = gdata.auth.extract_client_login_token(http_body_string,
['http://docs.google.com/feeds/'])
- self.assertEquals(token.get_token_string(), 'DQAAAGgAdk3fA5N')
- self.assert_(isinstance(token, gdata.auth.ClientLoginToken))
- self.assert_(token.valid_for_scope('http://docs.google.com/feeds/'))
- self.assert_(not token.valid_for_scope('http://www.blogger.com/feeds'))
+ self.assertEqual(token.get_token_string(), 'DQAAAGgAdk3fA5N')
+ self.assertTrue(isinstance(token, gdata.auth.ClientLoginToken))
+ self.assertTrue(token.valid_for_scope('http://docs.google.com/feeds/'))
+ self.assertTrue(not token.valid_for_scope('http://www.blogger.com/feeds'))
class ExtractOAuthTokensTest(unittest.TestCase):
@@ -367,10 +367,10 @@
'%2Ffeeds%2F+http%3A%2F%2Fdocs.google.com%2Ffeeds%2F&'
'oauth_token=CMns6t7MCxDz__8B')
token = gdata.auth.OAuthTokenFromUrl(url)
- self.assertEquals('CMns6t7MCxDz__8B', token.key)
- self.assertEquals(2, len(token.scopes))
- self.assert_(scope_1 in token.scopes)
- self.assert_(scope_2 in token.scopes)
+ self.assertEqual('CMns6t7MCxDz__8B', token.key)
+ self.assertEqual(2, len(token.scopes))
+ self.assertTrue(scope_1 in token.scopes)
+ self.assertTrue(scope_2 in token.scopes)
# Case 2: token and scopes both are present but scope_param_prefix
# passed does not match the one present in the URL.
url = ('http://dummy.com/?oauth_token_scope=http%3A%2F%2Fwww.blogger.com'
@@ -378,14 +378,14 @@
'oauth_token=CMns6t7MCxDz__8B')
token = gdata.auth.OAuthTokenFromUrl(url,
scopes_param_prefix='token_scope')
- self.assertEquals('CMns6t7MCxDz__8B', token.key)
- self.assert_(not token.scopes)
+ self.assertEqual('CMns6t7MCxDz__8B', token.key)
+ self.assertTrue(not token.scopes)
# Case 3: None present.
url = ('http://dummy.com/?no_oauth_token_scope=http%3A%2F%2Fwww.blogger.com'
'%2Ffeeds%2F+http%3A%2F%2Fdocs.google.com%2Ffeeds%2F&'
'no_oauth_token=CMns6t7MCxDz__8B')
token = gdata.auth.OAuthTokenFromUrl(url)
- self.assert_(token is None)
+ self.assertTrue(token is None)
def testOAuthTokenFromHttpBody(self):
token_key = 'ABCD'
@@ -394,8 +394,8 @@
http_body = 'oauth_token=%s&oauth_token_secret=%s' % (token_key,
token_secret)
token = gdata.auth.OAuthTokenFromHttpBody(http_body)
- self.assertEquals(token_key, token.key)
- self.assertEquals(token_secret, token.secret)
+ self.assertEqual(token_key, token.key)
+ self.assertEqual(token_secret, token.secret)
class OAuthInputParametersTest(unittest.TestCase):
@@ -409,21 +409,21 @@
rsa_key=RSA_KEY)
def testGetSignatureMethod(self):
- self.assertEquals(
+ self.assertEqual(
'HMAC-SHA1',
self.oauth_input_parameters_hmac.GetSignatureMethod().get_name())
rsa_signature_method = self.oauth_input_parameters_rsa.GetSignatureMethod()
- self.assertEquals('RSA-SHA1', rsa_signature_method.get_name())
- self.assertEquals(RSA_KEY, rsa_signature_method._fetch_private_cert(None))
+ self.assertEqual('RSA-SHA1', rsa_signature_method.get_name())
+ self.assertEqual(RSA_KEY, rsa_signature_method._fetch_private_cert(None))
def testGetConsumer(self):
- self.assertEquals(CONSUMER_KEY,
+ self.assertEqual(CONSUMER_KEY,
self.oauth_input_parameters_hmac.GetConsumer().key)
- self.assertEquals(CONSUMER_KEY,
+ self.assertEqual(CONSUMER_KEY,
self.oauth_input_parameters_rsa.GetConsumer().key)
- self.assertEquals(CONSUMER_SECRET,
+ self.assertEqual(CONSUMER_SECRET,
self.oauth_input_parameters_hmac.GetConsumer().secret)
- self.assert_(self.oauth_input_parameters_rsa.GetConsumer().secret is None)
+ self.assertTrue(self.oauth_input_parameters_rsa.GetConsumer().secret is None)
class TokenClassesTest(unittest.TestCase):
@@ -431,35 +431,35 @@
def testClientLoginToAndFromString(self):
token = gdata.auth.ClientLoginToken()
token.set_token_string('foo')
- self.assertEquals(token.get_token_string(), 'foo')
- self.assertEquals(token.auth_header, '%s%s' % (
+ self.assertEqual(token.get_token_string(), 'foo')
+ self.assertEqual(token.auth_header, '%s%s' % (
gdata.auth.PROGRAMMATIC_AUTH_LABEL, 'foo'))
token.set_token_string(token.get_token_string())
- self.assertEquals(token.get_token_string(), 'foo')
+ self.assertEqual(token.get_token_string(), 'foo')
def testAuthSubToAndFromString(self):
token = gdata.auth.AuthSubToken()
token.set_token_string('foo')
- self.assertEquals(token.get_token_string(), 'foo')
- self.assertEquals(token.auth_header, '%s%s' % (
+ self.assertEqual(token.get_token_string(), 'foo')
+ self.assertEqual(token.auth_header, '%s%s' % (
gdata.auth.AUTHSUB_AUTH_LABEL, 'foo'))
token.set_token_string(token.get_token_string())
- self.assertEquals(token.get_token_string(), 'foo')
+ self.assertEqual(token.get_token_string(), 'foo')
def testSecureAuthSubToAndFromString(self):
# Case 1: no token.
token = gdata.auth.SecureAuthSubToken(RSA_KEY)
token.set_token_string('foo')
- self.assertEquals(token.get_token_string(), 'foo')
+ self.assertEqual(token.get_token_string(), 'foo')
token.set_token_string(token.get_token_string())
- self.assertEquals(token.get_token_string(), 'foo')
- self.assertEquals(str(token), 'foo')
+ self.assertEqual(token.get_token_string(), 'foo')
+ self.assertEqual(str(token), 'foo')
# Case 2: token is a string
token = gdata.auth.SecureAuthSubToken(RSA_KEY, token_string='foo')
- self.assertEquals(token.get_token_string(), 'foo')
+ self.assertEqual(token.get_token_string(), 'foo')
token.set_token_string(token.get_token_string())
- self.assertEquals(token.get_token_string(), 'foo')
- self.assertEquals(str(token), 'foo')
+ self.assertEqual(token.get_token_string(), 'foo')
+ self.assertEqual(str(token), 'foo')
def testOAuthToAndFromString(self):
token_key = 'ABCD'
@@ -469,10 +469,10 @@
token_secret)
token = gdata.auth.OAuthToken()
token.set_token_string(token_string)
- self.assert_(-1 < token.get_token_string().find(token_string.split('&')[0]))
- self.assert_(-1 < token.get_token_string().find(token_string.split('&')[1]))
- self.assertEquals(token_key, token.key)
- self.assertEquals(token_secret, token.secret)
+ self.assertTrue(-1 < token.get_token_string().find(token_string.split('&')[0]))
+ self.assertTrue(-1 < token.get_token_string().find(token_string.split('&')[1]))
+ self.assertEqual(token_key, token.key)
+ self.assertEqual(token_secret, token.secret)
# Case 2: token key and secret both present multiple times with unwanted
# parameters.
token_string = ('oauth_token=%s&oauth_token_secret=%s&'
@@ -481,48 +481,48 @@
'LMNO'))
token = gdata.auth.OAuthToken()
token.set_token_string(token_string)
- self.assert_(-1 < token.get_token_string().find(token_string.split('&')[0]))
- self.assert_(-1 < token.get_token_string().find(token_string.split('&')[1]))
- self.assertEquals(token_key, token.key)
- self.assertEquals(token_secret, token.secret)
+ self.assertTrue(-1 < token.get_token_string().find(token_string.split('&')[0]))
+ self.assertTrue(-1 < token.get_token_string().find(token_string.split('&')[1]))
+ self.assertEqual(token_key, token.key)
+ self.assertEqual(token_secret, token.secret)
# Case 3: Only token key present.
token_string = 'oauth_token=%s' % (token_key,)
token = gdata.auth.OAuthToken()
token.set_token_string(token_string)
- self.assertEquals(token_string, token.get_token_string())
- self.assertEquals(token_key, token.key)
- self.assert_(not token.secret)
+ self.assertEqual(token_string, token.get_token_string())
+ self.assertEqual(token_key, token.key)
+ self.assertTrue(not token.secret)
# Case 4: Only token key present.
token_string = 'oauth_token_secret=%s' % (token_secret,)
token = gdata.auth.OAuthToken()
token.set_token_string(token_string)
- self.assertEquals(token_string, token.get_token_string())
- self.assertEquals(token_secret, token.secret)
- self.assert_(not token.key)
+ self.assertEqual(token_string, token.get_token_string())
+ self.assertEqual(token_secret, token.secret)
+ self.assertTrue(not token.key)
# Case 5: None present.
token_string = ''
token = gdata.auth.OAuthToken()
token.set_token_string(token_string)
- self.assert_(token.get_token_string() is None)
- self.assert_(not token.key)
- self.assert_(not token.secret)
+ self.assertTrue(token.get_token_string() is None)
+ self.assertTrue(not token.key)
+ self.assertTrue(not token.secret)
def testSecureAuthSubGetAuthHeader(self):
# Case 1: Presence of OAuth token (in case of 3-legged OAuth)
url = 'http://dummy.com/?q=notebook&s=true'
token = gdata.auth.SecureAuthSubToken(RSA_KEY, token_string='foo')
auth_header = token.GetAuthHeader('GET', url)
- self.assert_('Authorization' in auth_header)
+ self.assertTrue('Authorization' in auth_header)
header_value = auth_header['Authorization']
- self.assert_(header_value.startswith(r'AuthSub token="foo"'))
- self.assert_(-1 < header_value.find(r'sigalg="rsa-sha1"'))
- self.assert_(-1 < header_value.find(r'data="'))
- self.assert_(-1 < header_value.find(r'sig="'))
+ self.assertTrue(header_value.startswith(r'AuthSub token="foo"'))
+ self.assertTrue(-1 < header_value.find(r'sigalg="rsa-sha1"'))
+ self.assertTrue(-1 < header_value.find(r'data="'))
+ self.assertTrue(-1 < header_value.find(r'sig="'))
m = re.search(r'data="(.*?)"', header_value)
- self.assert_(m is not None)
+ self.assertTrue(m is not None)
data = m.group(1)
- self.assert_(data.startswith('GET'))
- self.assert_(-1 < data.find(url))
+ self.assertTrue(data.startswith('GET'))
+ self.assertTrue(-1 < data.find(url))
def testOAuthGetAuthHeader(self):
# Case 1: Presence of OAuth token (in case of 3-legged OAuth)
@@ -534,17 +534,17 @@
auth_header = token.GetAuthHeader('GET',
'http://dummy.com/?q=notebook&s=true',
realm='http://dummy.com')
- self.assert_('Authorization' in auth_header)
+ self.assertTrue('Authorization' in auth_header)
header_value = auth_header['Authorization']
- self.assert_(-1 < header_value.find(r'OAuth realm="http://dummy.com"'))
- self.assert_(-1 < header_value.find(r'oauth_version="1.0"'))
- self.assert_(-1 < header_value.find(r'oauth_token="ABCDDSFFDSG"'))
- self.assert_(-1 < header_value.find(r'oauth_nonce="'))
- self.assert_(-1 < header_value.find(r'oauth_timestamp="'))
- self.assert_(-1 < header_value.find(r'oauth_signature="'))
- self.assert_(-1 < header_value.find(
+ self.assertTrue(-1 < header_value.find(r'OAuth realm="http://dummy.com"'))
+ self.assertTrue(-1 < header_value.find(r'oauth_version="1.0"'))
+ self.assertTrue(-1 < header_value.find(r'oauth_token="ABCDDSFFDSG"'))
+ self.assertTrue(-1 < header_value.find(r'oauth_nonce="'))
+ RefactoringTool: Refactored ./tests/gdata_tests/apps_test.py
self.assertTrue(-1 < header_value.find(r'oauth_timestamp="'))
+ self.assertTrue(-1 < header_value.find(r'oauth_signature="'))
+ self.assertTrue(-1 < header_value.find(
r'oauth_consumer_key="%s"' % CONSUMER_KEY))
- self.assert_(-1 < header_value.find(r'oauth_signature_method="RSA-SHA1"'))
+ self.assertTrue(-1 < header_value.find(r'oauth_signature_method="RSA-SHA1"'))
# Case 2: Absence of OAuth token (in case of 2-legged OAuth)
oauth_input_params = gdata.auth.OAuthInputParams(
gdata.auth.OAuthSignatureMethod.HMAC_SHA1, CONSUMER_KEY,
@@ -552,17 +552,17 @@
token = gdata.auth.OAuthToken(oauth_input_params=oauth_input_params)
auth_header = token.GetAuthHeader(
'GET', 'http://dummy.com/?xoauth_requestor_id=user@gmail.com&q=book')
- self.assert_('Authorization' in auth_header)
+ self.assertTrue('Authorization' in auth_header)
header_value = auth_header['Authorization']
- self.assert_(-1 < header_value.find(r'OAuth realm=""'))
- self.assert_(-1 < header_value.find(r'oauth_version="1.0"'))
- self.assertEquals(-1, header_value.find(r'oauth_token='))
- self.assert_(-1 < header_value.find(r'oauth_nonce="'))
- self.assert_(-1 < header_value.find(r'oauth_timestamp="'))
- self.assert_(-1 < header_value.find(r'oauth_signature="'))
- self.assert_(-1 < header_value.find(
+ self.assertTrue(-1 < header_value.find(r'OAuth realm=""'))
+ self.assertTrue(-1 < header_value.find(r'oauth_version="1.0"'))
+ self.assertEqual(-1, header_value.find(r'oauth_token='))
+ self.assertTrue(-1 < header_value.find(r'oauth_nonce="'))
+ self.assertTrue(-1 < header_value.find(r'oauth_timestamp="'))
+ self.assertTrue(-1 < header_value.find(r'oauth_signature="'))
+ self.assertTrue(-1 < header_value.find(
r'oauth_consumer_key="%s"' % CONSUMER_KEY))
- self.assert_(-1 < header_value.find(r'oauth_signature_method="HMAC-SHA1"'))
+ self.assertTrue(-1 < header_value.find(r'oauth_signature_method="HMAC-SHA1"'))
if __name__ == '__main__':
--- ./tests/gdata_tests/apps_test.py (original)
+++ ./tests/gdata_tests/apps_test.py (refactored)
@@ -36,36 +36,36 @@
def testEmailListRecipientEntryCount(self):
"""Count EmailListRecipient entries in EmailListRecipientFeed"""
- self.assertEquals(len(self.rcpt_feed.entry), 2)
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.rcpt_feed.GetSelfLink() is not None)
- self.assert_(self.rcpt_feed.GetNextLink() is not None)
- self.assert_(self.rcpt_feed.GetEditLink() is None)
- self.assert_(self.rcpt_feed.GetHtmlLink() is None)
+ self.assertEqual(len(self.rcpt_feed.entry), 2)
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.rcpt_feed.GetSelfLink() is not None)
+ self.assertTrue(self.rcpt_feed.GetNextLink() is not None)
+ self.assertTrue(self.rcpt_feed.GetEditLink() is None)
+ self.assertTrue(self.rcpt_feed.GetHtmlLink() is None)
def testStartItem(self):
"""Tests the existence of in
EmailListRecipientFeed and verifies the value"""
- self.assert_(isinstance(self.rcpt_feed.start_index, gdata.StartIndex),
+ self.assertTrue(isinstance(self.rcpt_feed.start_index, gdata.StartIndex),
"EmailListRecipient feed element must be " +
"an instance of gdata.OpenSearch: %s" % self.rcpt_feed.start_index)
- self.assertEquals(self.rcpt_feed.start_index.text, "1")
+ self.assertEqual(self.rcpt_feed.start_index.text, "1")
def testEmailListRecipientEntries(self):
"""Tests the existence of in EmailListRecipientFeed
and simply verifies the value"""
for a_entry in self.rcpt_feed.entry:
- self.assert_(isinstance(a_entry, gdata.apps.EmailListRecipientEntry),
+ self.assertTrue(isinstance(a_entry, gdata.apps.EmailListRecipientEntry),
"EmailListRecipient Feed must be an instance of " +
"apps.EmailListRecipientEntry: %s" % a_entry)
- self.assertEquals(self.rcpt_feed.entry[0].who.email, "joe@example.com")
- self.assertEquals(self.rcpt_feed.entry[1].who.email, "susan@example.com")
+ self.assertEqual(self.rcpt_feed.entry[0].who.email, "joe@example.com")
+ self.assertEqual(self.rcpt_feed.entry[1].who.email, "susan@example.com")
class AppsEmailListFeedTest(unittest.TestCase):
@@ -76,36 +76,36 @@
def testEmailListEntryCount(self):
"""Count EmailList entries in EmailListFeed"""
- self.assertEquals(len(self.list_feed.entry), 2)
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.list_feed.GetSelfLink() is not None)
- self.assert_(self.list_feed.GetNextLink() is not None)
- self.assert_(self.list_feed.GetEditLink() is None)
- self.assert_(self.list_feed.GetHtmlLink() is None)
+ self.assertEqual(len(self.list_feed.entry), 2)
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.list_feed.GetSelfLink() is not None)
+ self.assertTrue(self.list_feed.GetNextLink() is not None)
+ self.assertTrue(self.list_feed.GetEditLink() is None)
+ self.assertTrue(self.list_feed.GetHtmlLink() is None)
def testStartItem(self):
"""Tests the existence of in EmailListFeed
and verifies the value"""
- self.assert_(isinstance(self.list_feed.start_index, gdata.StartIndex),
+ self.assertTrue(isinstance(self.list_feed.start_index, gdata.StartIndex),
"EmailList feed element must be an instance " +
"of gdata.OpenSearch: %s" % self.list_feed.start_index)
- self.assertEquals(self.list_feed.start_index.text, "1")
+ self.assertEqual(self.list_feed.start_index.text, "1")
def testUserEntries(self):
"""Tests the existence of in EmailListFeed and simply
verifies the value"""
for a_entry in self.list_feed.entry:
- self.assert_(isinstance(a_entry, gdata.apps.EmailListEntry),
+ self.assertTrue(isinstance(a_entry, gdata.apps.EmailListEntry),
"EmailList Feed must be an instance of " +
"apps.EmailListEntry: %s" % a_entry)
- self.assertEquals(self.list_feed.entry[0].email_list.name, "us-sales")
- self.assertEquals(self.list_feed.entry[1].email_list.name, "us-eng")
+ self.assertEqual(self.list_feed.entry[0].email_list.name, "us-sales")
+ self.assertEqual(self.list_feed.entry[1].email_list.name, "us-eng")
class AppsUserFeedTest(unittest.TestCase):
@@ -115,39 +115,39 @@
def testUserEntryCount(self):
"""Count User entries in UserFeed"""
- self.assertEquals(len(self.user_feed.entry), 2)
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.user_feed.GetSelfLink() is not None)
- self.assert_(self.user_feed.GetNextLink() is not None)
- self.assert_(self.user_feed.GetEditLink() is None)
- self.assert_(self.user_feed.GetHtmlLink() is None)
+ self.assertEqual(len(self.user_feed.entry), 2)
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.user_feed.GetSelfLink() is not None)
+ self.assertTrue(self.user_feed.GetNextLink() is not None)
+ self.assertTrue(self.user_feed.GetEditLink() is None)
+ self.assertTrue(self.user_feed.GetHtmlLink() is None)
def testStartItem(self):
"""Tests the existence of in UserFeed and
verifies the value"""
- self.assert_(isinstance(self.user_feed.start_index, gdata.StartIndex),
+ self.assertTrue(isinstance(self.user_feed.start_index, gdata.StartIndex),
"User feed element must be an instance " +
"of gdata.OpenSearch: %s" % self.user_feed.start_index)
- self.assertEquals(self.user_feed.start_index.text, "1")
+ self.assertEqual(self.user_feed.start_index.text, "1")
def testUserEntries(self):
"""Tests the existence of in UserFeed and simply
verifies the value"""
for a_entry in self.user_feed.entry:
- self.assert_(isinstance(a_entry, gdata.apps.UserEntry),
+ self.assertTrue(isinstance(a_entry, gdata.apps.UserEntry),
"User Feed must be an instance of " +
"apps.UserEntry: %s" % a_entry)
- self.assertEquals(self.user_feed.entry[0].login.user_name, "TestUser")
- self.assertEquals(self.user_feed.entry[0].who.email,
+ self.assertEqual(self.user_feed.entry[0].login.user_name, "TestUser")
+ self.assertEqual(self.user_feed.entry[0].who.email,
"TestUser@example.com")
- self.assertEquals(self.user_feed.entry[1].login.user_name, "JohnSmith")
- self.assertEquals(self.user_feed.entry[1].who.email,
+ self.assertEqual(self.user_feed.entry[1].login.user_name, "JohnSmith")
+ self.assertEqual(self.user_feed.entry[1].who.email,
"JohnSmith@example.com")
class AppsNicknameFeedTest(unittest.TestCase):
@@ -158,56 +158,56 @@
def testNicknameEntryCount(self):
"""Count Nickname entries in NicknameFeed"""
- self.assertEquals(len(self.nick_feed.entry), 2)
+ self.assertEqual(len(self.nick_feed.entry), 2)
def testId(self):
"""Tests the existence of in NicknameFeed and verifies
the value"""
- self.assert_(isinstance(self.nick_feed.id, atom.Id),
+ self.assertTrue(isinstance(self.nick_feed.id, atom.Id),
"Nickname feed element must be an instance of " +
"atom.Id: %s" % self.nick_feed.id)
- self.assertEquals(self.nick_feed.id.text,
+ self.assertEqual(self.nick_feed.id.text,
"http://apps-apis.google.com/a/feeds/example.com/nickname/2.0")
def testStartItem(self):
"""Tests the existence of in NicknameFeed
and verifies the value"""
- self.assert_(isinstance(self.nick_feed.start_index, gdata.StartIndex),
+ self.assertTrue(isinstance(self.nick_feed.start_index, gdata.StartIndex),
"Nickname feed element must be an instance " +
"of gdata.OpenSearch: %s" % self.nick_feed.start_index)
- self.assertEquals(self.nick_feed.start_index.text, "1")
+ self.assertEqual(self.nick_feed.start_index.text, "1")
def testItemsPerPage(self):
"""Tests the existence of in
NicknameFeed and verifies the value"""
- self.assert_(isinstance(self.nick_feed.items_per_page, gdata.ItemsPerPage),
+ self.assertTrue(isinstance(self.nick_feed.items_per_page, gdata.ItemsPerPage),
"Nickname feed element must be an " +
"instance of gdata.ItemsPerPage: %s" % self.nick_feed.items_per_page)
- self.assertEquals(self.nick_feed.items_per_page.text, "2")
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.nick_feed.GetSelfLink() is not None)
- self.assert_(self.nick_feed.GetEditLink() is None)
- self.assert_(self.nick_feed.GetHtmlLink() is None)
+ self.assertEqual(self.nick_feed.items_per_page.text, "2")
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.nick_feed.GetSelfLink() is not None)
+ self.assertTrue(self.nick_feed.GetEditLink() is None)
+ self.assertTrue(self.nick_feed.GetHtmlLink() is None)
def testNicknameEntries(self):
"""Tests the existence of in NicknameFeed and simply
verifies the value"""
for a_entry in self.nick_feed.entry:
- self.assert_(isinstance(a_entry, gdata.apps.NicknameEntry),
+ self.assertTrue(isinstance(a_entry, gdata.apps.NicknameEntry),
"Nickname Feed must be an instance of " +
"apps.NicknameEntry: %s" % a_entry)
- self.assertEquals(self.nick_feed.entry[0].nickname.name, "Foo")
- self.assertEquals(self.nick_feed.entry[1].nickname.name, "Bar")
+ self.assertEqual(self.nick_feed.entry[0].nickname.name, "Foo")
+ self.assertEqual(self.nick_feed.entry[1].nickname.name, "Bar")
class AppsEmailListRecipientEntryTest(unittest.TestCase):
@@ -220,13 +220,13 @@
"""Tests the existence of in EmailListRecipientEntry and
verifies the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.rcpt_entry.id, atom.Id),
"EmailListRecipient entry element must be an instance of " +
"atom.Id: %s" %
self.rcpt_entry.id)
- self.assertEquals(
+ self.assertEqual(
self.rcpt_entry.id.text,
'https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/' +
'recipient/TestUser%40example.com')
@@ -235,12 +235,12 @@
"""Tests the existence of in
EmailListRecipientEntry and verifies the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.rcpt_entry.updated, atom.Updated),
"EmailListRecipient entry element must be an instance " +
"of atom.Updated: %s" % self.rcpt_entry.updated)
- self.assertEquals(self.rcpt_entry.updated.text,
+ self.assertEqual(self.rcpt_entry.updated.text,
'1970-01-01T00:00:00.000Z')
def testCategory(self):
@@ -248,15 +248,15 @@
EmailListRecipientEntry and verifies the value"""
for a_category in self.rcpt_entry.category:
- self.assert_(
+ self.assertTrue(
isinstance(a_category, atom.Category),
"EmailListRecipient entry element must be an " +
"instance of atom.Category: %s" % a_category)
- self.assertEquals(a_category.scheme,
+ self.assertEqual(a_category.scheme,
"http://schemas.google.com/g/2005#kind")
- self.assertEquals(a_category.term,
+ self.assertEqual(a_category.term,
"http://schemas.google.com/apps/2006#" +
"emailList.recipient")
@@ -264,28 +264,28 @@
"""Tests the existence of in EmailListRecipientEntry
and verifies the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.rcpt_entry.title, atom.Title),
"EmailListRecipient entry element must be an instance of " +
"atom.Title: %s" % self.rcpt_entry.title)
- self.assertEquals(self.rcpt_entry.title.text, 'TestUser')
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.rcpt_entry.GetSelfLink() is not None)
- self.assert_(self.rcpt_entry.GetEditLink() is not None)
- self.assert_(self.rcpt_entry.GetHtmlLink() is None)
+ self.assertEqual(self.rcpt_entry.title.text, 'TestUser')
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.rcpt_entry.GetSelfLink() is not None)
+ self.assertTrue(self.rcpt_entry.GetEditLink() is not None)
+ self.assertTrue(self.rcpt_entry.GetHtmlLink() is None)
def testWho(self):
"""Tests the existence of a in EmailListRecipientEntry
and verifies the value"""
- self.assert_(isinstance(self.rcpt_entry.who, gdata.apps.Who),
+ self.assertTrue(isinstance(self.rcpt_entry.who, gdata.apps.Who),
"EmailListRecipient entry must be an instance of " +
"apps.Who: %s" % self.rcpt_entry.who)
- self.assertEquals(self.rcpt_entry.who.email, 'TestUser@example.com')
+ self.assertEqual(self.rcpt_entry.who.email, 'TestUser@example.com')
class AppsEmailListEntryTest(unittest.TestCase):
@@ -298,12 +298,12 @@
"""Tests the existence of in EmailListEntry and verifies
the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.list_entry.id, atom.Id),
"EmailList entry element must be an instance of atom.Id: %s" %
self.list_entry.id)
- self.assertEquals(
+ self.assertEqual(
self.list_entry.id.text,
'https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/testlist')
@@ -311,12 +311,12 @@
"""Tests the existence of in EmailListEntry and
verifies the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.list_entry.updated, atom.Updated),
"EmailList entry element must be an instance of " +
"atom.Updated: %s" % self.list_entry.updated)
- self.assertEquals(self.list_entry.updated.text,
+ self.assertEqual(self.list_entry.updated.text,
'1970-01-01T00:00:00.000Z')
def testCategory(self):
@@ -324,56 +324,56 @@
verifies the value"""
for a_category in self.list_entry.category:
- self.assert_(
+ self.assertTrue(
isinstance(a_category, atom.Category),
"EmailList entry element must be an instance " +
"of atom.Category: %s" % a_category)
- self.assertEquals(a_category.scheme,
+ self.assertEqual(a_category.scheme,
"http://schemas.google.com/g/2005#kind")
- self.assertEquals(a_category.term,
+ self.assertEqual(a_category.term,
"http://schemas.google.com/apps/2006#emailList")
def testTitle(self):
"""Tests the existence of in EmailListEntry and verifies
the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.list_entry.title, atom.Title),
"EmailList entry element must be an instance of " +
"atom.Title: %s" % self.list_entry.title)
- self.assertEquals(self.list_entry.title.text, 'testlist')
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.list_entry.GetSelfLink() is not None)
- self.assert_(self.list_entry.GetEditLink() is not None)
- self.assert_(self.list_entry.GetHtmlLink() is None)
+ self.assertEqual(self.list_entry.title.text, 'testlist')
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.list_entry.GetSelfLink() is not None)
+ self.assertTrue(self.list_entry.GetEditLink() is not None)
+ self.assertTrue(self.list_entry.GetHtmlLink() is None)
def testEmailList(self):
"""Tests the existence of a in EmailListEntry and
verifies the value"""
- self.assert_(isinstance(self.list_entry.email_list, gdata.apps.EmailList),
+ self.assertTrue(isinstance(self.list_entry.email_list, gdata.apps.EmailList),
"EmailList entry must be an instance of " +
"apps.EmailList: %s" % self.list_entry.email_list)
- self.assertEquals(self.list_entry.email_list.name, 'testlist')
+ self.assertEqual(self.list_entry.email_list.name, 'testlist')
def testFeedLink(self):
"""Test the existence of a in EmailListEntry and
verifies the value"""
for an_feed_link in self.list_entry.feed_link:
- self.assert_(isinstance(an_feed_link, gdata.FeedLink),
+ self.assertTrue(isinstance(an_feed_link, gdata.FeedLink),
"EmailList entry must be an instance of " +
"gdata.FeedLink: %s" % an_feed_link)
- self.assertEquals(self.list_entry.feed_link[0].rel,
+ self.assertEqual(self.list_entry.feed_link[0].rel,
'http://schemas.google.com/apps/2006#' +
'emailList.recipients')
- self.assertEquals(self.list_entry.feed_link[0].href,
+ self.assertEqual(self.list_entry.feed_link[0].href,
'http://apps-apis.google.com/a/feeds/example.com/emailList/' +
'2.0/testlist/recipient/')
@@ -386,12 +386,12 @@
"""Tests the existence of in NicknameEntry and verifies
the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.nick_entry.id, atom.Id),
"Nickname entry element must be an instance of atom.Id: %s" %
self.nick_entry.id)
- self.assertEquals(
+ self.assertEqual(
self.nick_entry.id.text,
'https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Foo')
@@ -400,51 +400,51 @@
verifies the value"""
for a_category in self.nick_entry.category:
- self.assert_(
+ self.assertTrue(
isinstance(a_category, atom.Category),
"Nickname entry element must be an instance " +
"of atom.Category: %s" % a_category)
- self.assertEquals(a_category.scheme,
+ self.assertEqual(a_category.scheme,
"http://schemas.google.com/g/2005#kind")
- self.assertEquals(a_category.term,
+ self.assertEqual(a_category.term,
"http://schemas.google.com/apps/2006#nickname")
def testTitle(self):
"""Tests the existence of in NicknameEntry and
verifies the value"""
- self.assert_(isinstance(self.nick_entry.title, atom.Title),
+ self.assertTrue(isinstance(self.nick_entry.title, atom.Title),
"Nickname entry element must be an instance " +
"of atom.Title: %s" % self.nick_entry.title)
- self.assertEquals(self.nick_entry.title.text, "Foo")
+ self.assertEqual(self.nick_entry.title.text, "Foo")
def testLogin(self):
"""Tests the existence of in NicknameEntry and
verifies the value"""
- self.assert_(isinstance(self.nick_entry.login, gdata.apps.Login),
+ self.assertTrue(isinstance(self.nick_entry.login, gdata.apps.Login),
"Nickname entry element must be an instance " +
"of apps.Login: %s" % self.nick_entry.login)
- self.assertEquals(self.nick_entry.login.user_name, "TestUser")
+ self.assertEqual(self.nick_entry.login.user_name, "TestUser")
def testNickname(self):
"""Tests the existence of in NicknameEntry and
verifies the value"""
- self.assert_(isinstance(self.nick_entry.nickname, gdata.apps.Nickname),
+ self.assertTrue(isinstance(self.nick_entry.nickname, gdata.apps.Nickname),
"Nickname entry element must be an instance " +
"of apps.Nickname: %s" % self.nick_entry.nickname)
- self.assertEquals(self.nick_entry.nickname.name, "Foo")
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.nick_entry.GetSelfLink() is not None)
- self.assert_(self.nick_entry.GetEditLink() is not None)
- self.assert_(self.nick_entry.GetHtmlLink() is None)
+ self.assertEqual(self.nick_entry.nickname.name, "Foo")
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.nick_entry.GetSelfLink() is not None)
+ self.assertTrue(self.nick_entry.GetEditLink() is not None)
+ self.assertTrue(self.nick_entry.GetHtmlLink() is None)
class AppsUserEntryTest(unittest.TestCase):
@@ -455,12 +455,12 @@
"""Tests the existence of in UserEntry and verifies the
value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.user_entry.id, atom.Id),
"User entry element must be an instance of atom.Id: %s" %
self.user_entry.id)
- self.assertEquals(
+ self.assertEqual(
self.user_entry.id.text,
'https://apps-apis.google.com/a/feeds/example.com/user/2.0/TestUser')
@@ -468,12 +468,12 @@
"""Tests the existence of in UserEntry and verifies
the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.user_entry.updated, atom.Updated),
"User entry element must be an instance of " +
"atom.Updated: %s" % self.user_entry.updated)
- self.assertEquals(self.user_entry.updated.text,
+ self.assertEqual(self.user_entry.updated.text,
'1970-01-01T00:00:00.000Z')
def testCategory(self):
@@ -481,84 +481,84 @@
verifies the value"""
for a_category in self.user_entry.category:
- self.assert_(
+ self.assertTrue(
isinstance(a_category, atom.Category),
"User entry element must be an instance " +
"of atom.Category: %s" % a_category)
- self.assertEquals(a_category.scheme,
+ self.assertEqual(a_category.scheme,
"http://schemas.google.com/g/2005#kind")
- self.assertEquals(a_category.term,
+ self.assertEqual(a_category.term,
"http://schemas.google.com/apps/2006#user")
def testTitle(self):
"""Tests the existence of in UserEntry and verifies
the value"""
- self.assert_(
+ self.assertTrue(
isinstance(self.user_entry.title, atom.Title),
"User entry element must be an instance of atom.Title: %s" %
self.user_entry.title)
- self.assertEquals(self.user_entry.title.text, 'TestUser')
-
- def testLinkFinderFindsHtmlLink(self):
- """Tests the return value of GetXXXLink() methods"""
-
- self.assert_(self.user_entry.GetSelfLink() is not None)
- self.assert_(self.user_entry.GetEditLink() is not None)
- self.assert_(self.user_entry.GetHtmlLink() is None)
+ self.assertEqual(self.user_entry.title.text, 'TestUser')
+
+ def testLinkFinderFindsHtmlLink(self):
+ """Tests the return value of GetXXXLink() methods"""
+
+ self.assertTrue(self.user_entry.GetSelfLink() is not None)
+ self.assertTrue(self.user_entry.GetEditLink() is not None)
+ self.assertTrue(self.user_entry.GetHtmlLink() is None)
def testLogin(self):
"""Tests the existence of in UserEntry and verifies
the value"""
- self.assert_(isinstance(self.user_entry.login, gdata.apps.Login),
+ self.assertTrue(isinstance(self.user_entry.login, gdata.apps.Login),
"User entry element must be an instance of apps.Login: %s"
% self.user_entry.login)
- self.assertEquals(self.user_entry.login.user_name, 'TestUser')
- self.assertEquals(self.user_entry.login.password, 'password')
- self.assertEquals(self.user_entry.login.suspended, 'false')
- self.assertEquals(self.user_entry.login.ip_whitelisted, 'false')
- self.assertEquals(self.user_entry.login.hash_function_name, 'SHA-1')
+ self.assertEqual(self.user_entry.login.user_name, 'TestUser')
+ self.assertEqual(self.user_entry.login.password, 'password')
+ self.assertEqual(self.user_entry.login.suspended, 'false')
+ self.assertEqual(self.user_entry.login.ip_whitelisted, 'false')
+ self.assertEqual(self.user_entry.login.hash_function_name, 'SHA-1')
def testName(self):
"""Tests the existence of in UserEntry and verifies
the value"""
- self.assert_(isinstance(self.user_entry.name, gdata.apps.Name),
+ self.assertTrue(isinstance(self.user_entry.name, gdata.apps.Name),
"User entry element must be an instance of apps.Name: %s"
% self.user_entry.name)
- self.assertEquals(self.user_entry.name.family_name, 'Test')
- self.assertEquals(self.user_entry.name.given_name, 'User')
+ self.assertEqual(self.user_entry.name.family_name, 'Test')
+ self.assertEqual(self.user_entry.name.given_name, 'User')
def testQuota(self):
"""Tests the existence of in UserEntry and verifies
the value"""
- self.assert_(isinstance(self.user_entry.quota, gdata.apps.Quota),
+ self.assertTrue(isinstance(self.user_entry.quota, gdata.apps.Quota),
"User entry element must be an instance of apps.Quota: %s"
% self.user_entry.quota)
- self.assertEquals(self.user_entry.quota.limit, '1024')
+ self.assertEqual(self.user_entry.quota.limit, '1024')
def testFeedLink(self):
"""Test the existence of a in UserEntry and
verifies the value"""
for an_feed_link in self.user_entry.feed_link:
- self.assert_(isinstance(an_feed_link, gdata.FeedLink),
+ self.assertTrue(isinstance(an_feed_link, gdata.FeedLink),
"User entry must be an instance of gdata.FeedLink" +
": %s" % an_feed_link)
- self.assertEquals(self.user_entry.feed_link[0].rel,
+ self.assertEqual(self.user_RefactoringTool: Refactored ./tests/gdata_tests/apps/service_test_using_mock.py
RefactoringTool: Refactored ./tests/gdata_tests/apps/service_test.py
entry.feed_link[0].rel,
'http://schemas.google.com/apps/2006#user.nicknames')
- self.assertEquals(self.user_entry.feed_link[0].href,
+ self.assertEqual(self.user_entry.feed_link[0].href,
'https://apps-apis.google.com/a/feeds/example.com/nickname/' +
'2.0?username=Test-3121')
- self.assertEquals(self.user_entry.feed_link[1].rel,
+ self.assertEqual(self.user_entry.feed_link[1].rel,
'http://schemas.google.com/apps/2006#user.emailLists')
- self.assertEquals(self.user_entry.feed_link[1].href,
+ self.assertEqual(self.user_entry.feed_link[1].href,
'https://apps-apis.google.com/a/feeds/example.com/emailList/' +
'2.0?recipient=testlist@example.com')
@@ -572,11 +572,11 @@
self.user_entry.login.suspended = 'true'
modified = gdata.apps.UserEntryFromString(self.user_entry.ToString())
- self.assertEquals(modified.name.family_name, 'ModifiedFamilyName')
- self.assertEquals(modified.name.given_name, 'ModifiedGivenName')
- self.assertEquals(modified.quota.limit, '2048')
- self.assertEquals(modified.login.password, 'ModifiedPassword')
- self.assertEquals(modified.login.suspended, 'true')
+ self.assertEqual(modified.name.family_name, 'ModifiedFamilyName')
+ self.assertEqual(modified.name.given_name, 'ModifiedGivenName')
+ self.assertEqual(modified.quota.limit, '2048')
+ self.assertEqual(modified.login.password, 'ModifiedPassword')
+ self.assertEqual(modified.login.suspended, 'true')
if __name__ == '__main__':
unittest.main()
--- ./tests/gdata_tests/apps/service_test_using_mock.py (original)
+++ ./tests/gdata_tests/apps/service_test_using_mock.py (refactored)
@@ -48,7 +48,7 @@
res.body = re.sub(r'SID=[^\n]+', 'SID=hogehoge', res.body)
res.body = re.sub(r'LSID=[^\n]+', 'LSID=hogehoge', res.body)
res.body = re.sub(r'Auth=[^\n]+', 'Auth=hogehoge', res.body)
- if req.headers.has_key('Authorization'):
+ if 'Authorization' in req.headers:
req.headers['Authorization'] = 'hogehoge'
ret.append((req, res))
return ret
@@ -93,7 +93,7 @@
for recipient_feed in generator:
for a_recipient in recipient_feed.entry:
i = i + 1
- self.assert_(i == 102)
+ self.assertTrue(i == 102)
class AppsServiceTestForGetGeneratorForAllEmailLists(AppsServiceBaseTest,
unittest.TestCase):
@@ -105,7 +105,7 @@
for emaillist_feed in generator:
for a_emaillist in emaillist_feed.entry:
i = i + 1
- self.assert_(i == 105)
+ self.assertTrue(i == 105)
class AppsServiceTestForGetGeneratorForAllNicknames(AppsServiceBaseTest,
unittest.TestCase):
@@ -117,7 +117,7 @@
for nickname_feed in generator:
for a_nickname in nickname_feed.entry:
i = i + 1
- self.assert_(i == 102)
+ self.assertTrue(i == 102)
class AppsServiceTestForGetGeneratorForAllUsers(AppsServiceBaseTest,
@@ -131,10 +131,10 @@
for user_feed in generator:
for a_user in user_feed.entry:
i = i + 1
- self.assert_(i == 102)
+ self.assertTrue(i == 102)
if __name__ == '__main__':
print ('The tests may delete or update your data.')
- apps_username = raw_input('Please enter your username: ')
+ apps_username = input('Please enter your username: ')
apps_password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/apps/service_test.py (original)
+++ ./tests/gdata_tests/apps/service_test.py (refactored)
@@ -48,7 +48,7 @@
if self.created_user is not None:
try:
self.apps_client.DeleteUser(self.created_user.login.user_name)
- except Exception, e:
+ except Exception as e:
pass
def test001RetrieveUser(self):
@@ -58,10 +58,10 @@
self_user_entry = self.apps_client.RetrieveUser(apps_username)
except:
self.fail('Unexpected exception occurred')
- self.assert_(isinstance(self_user_entry, gdata.apps.UserEntry),
+ self.assertTrue(isinstance(self_user_entry, gdata.apps.UserEntry),
"The return value of RetrieveUser() must be an instance of " +
"apps.UserEntry: %s" % self_user_entry)
- self.assertEquals(self_user_entry.login.user_name, apps_username)
+ self.assertEqual(self_user_entry.login.user_name, apps_username)
def test002RetrieveUserRaisesException(self):
"""Tests if RetrieveUser() raises AppsForYourDomainException with
@@ -69,9 +69,9 @@
try:
non_existance = self.apps_client.RetrieveUser('nobody-' + self.postfix)
- except gdata.apps.service.AppsForYourDomainException, e:
- self.assertEquals(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
- except Exception, e:
+ except gdata.apps.service.AppsForYourDomainException as e:
+ self.assertEqual(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
else:
self.fail('No exception occurred')
@@ -90,9 +90,9 @@
# Suspend then restore the new user.
entry = self.apps_client.SuspendUser(created_user.login.user_name)
- self.assertEquals(entry.login.suspended, 'true')
+ self.assertEqual(entry.login.suspended, 'true')
entry = self.apps_client.RestoreUser(created_user.login.user_name)
- self.assertEquals(entry.login.suspended, 'false')
+ self.assertEqual(entry.login.suspended, 'false')
# Clean up, delete the test user.
self.apps_client.DeleteUser(user_name)
@@ -110,14 +110,14 @@
created_user = self.apps_client.CreateUser(
user_name=user_name, family_name=family_name, given_name=given_name,
password=password, suspended=suspended)
- except Exception, e:
- self.assert_(False, 'Unexpected exception occurred: %s' % e)
+ except Exception as e:
+ self.assertTrue(False, 'Unexpected exception occurred: %s' % e)
self.created_user = created_user
- self.assertEquals(created_user.login.user_name, user_name)
- self.assertEquals(created_user.login.suspended, suspended)
- self.assertEquals(created_user.name.family_name, family_name)
- self.assertEquals(created_user.name.given_name, given_name)
+ self.assertEqual(created_user.login.user_name, user_name)
+ self.assertEqual(created_user.login.suspended, suspended)
+ self.assertEqual(created_user.name.family_name, family_name)
+ self.assertEqual(created_user.name.given_name, given_name)
# self.assertEquals(created_user.quota.limit,
# gdata.apps.service.DEFAULT_QUOTA_LIMIT)
@@ -126,14 +126,14 @@
try:
user_feed = self.apps_client.RetrieveAllUsers()
- except Exception, e:
- self.assert_(False, 'Unexpected exception occurred: %s' % e)
+ except Exception as e:
+ self.assertTrue(False, 'Unexpected exception occurred: %s' % e)
succeed = False
for a_entry in user_feed.entry:
if a_entry.login.user_name == user_name:
succeed = True
- self.assert_(succeed, 'There must be a user: %s' % user_name)
+ self.assertTrue(succeed, 'There must be a user: %s' % user_name)
"""Tests UpdateUser method"""
@@ -148,15 +148,15 @@
try:
new_user_entry = self.apps_client.UpdateUser(user_name, created_user)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
- self.assert_(isinstance(new_user_entry, gdata.apps.UserEntry),
+ self.assertTrue(isinstance(new_user_entry, gdata.apps.UserEntry),
"new user entry must be an instance of gdata.apps.UserEntry: %s"
% new_user_entry)
- self.assertEquals(new_user_entry.name.family_name, new_family_name)
- self.assertEquals(new_user_entry.name.given_name, new_given_name)
- self.assertEquals(new_user_entry.login.suspended, 'true')
+ self.assertEqual(new_user_entry.name.family_name, new_family_name)
+ self.assertEqual(new_user_entry.name.given_name, new_given_name)
+ self.assertEqual(new_user_entry.login.suspended, 'true')
# quota limit update does not always success.
# self.assertEquals(new_user_entry.quota.limit, new_quota)
@@ -168,9 +168,9 @@
# make sure that there is no account with nobody- + self.postfix
try:
tmp_entry = self.apps_client.RetrieveUser('nobody-' + self.postfix)
- except gdata.apps.service.AppsForYourDomainException, e:
- self.assertEquals(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
- except Exception, e:
+ except gdata.apps.service.AppsForYourDomainException as e:
+ self.assertEqual(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
else:
self.fail('No exception occurred')
@@ -179,9 +179,9 @@
try:
new_user_entry = self.apps_client.UpdateUser('nobody-' + self.postfix,
nobody)
- except gdata.apps.service.AppsForYourDomainException, e:
- self.assertEquals(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
- except Exception, e:
+ except gdata.apps.service.AppsForYourDomainException as e:
+ self.assertEqual(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
else:
self.fail('No exception occurred')
@@ -190,15 +190,15 @@
try:
self.apps_client.DeleteUser(user_name)
- except Exception, e:
- self.assert_(False, 'Unexpected exception occurred: %s' % e)
+ except Exception as e:
+ self.assertTrue(False, 'Unexpected exception occurred: %s' % e)
# make sure that the account deleted
try:
self.apps_client.RetrieveUser(user_name)
- except gdata.apps.service.AppsForYourDomainException, e:
- self.assertEquals(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
- except Exception, e:
+ except gdata.apps.service.AppsForYourDomainException as e:
+ self.assertEqual(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
else:
self.fail('No exception occurred')
@@ -207,9 +207,9 @@
# make sure that DeleteUser fails with AppsForYourDomainException.
try:
self.apps_client.DeleteUser(user_name)
- except gdata.apps.service.AppsForYourDomainException, e:
- self.assertEquals(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
- except Exception, e:
+ except gdata.apps.service.AppsForYourDomainException as e:
+ self.assertEqual(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
else:
self.fail('No exception occurred')
@@ -228,7 +228,7 @@
created_user = self.apps_client.CreateUser(
user_name=user_name, family_name=family_name, given_name=given_name,
password=password, suspended=suspended)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_user = created_user
@@ -236,34 +236,34 @@
nickname = 'emmy-' + self.postfix
try:
created_nickname = self.apps_client.CreateNickname(user_name, nickname)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assert_(isinstance(created_nickname, gdata.apps.NicknameEntry),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertTrue(isinstance(created_nickname, gdata.apps.NicknameEntry),
"Return value of CreateNickname method must be an instance of " +
"gdata.apps.NicknameEntry: %s" % created_nickname)
- self.assertEquals(created_nickname.login.user_name, user_name)
- self.assertEquals(created_nickname.nickname.name, nickname)
+ self.assertEqual(created_nickname.login.user_name, user_name)
+ self.assertEqual(created_nickname.nickname.name, nickname)
# tests RetrieveNickname method
retrieved_nickname = self.apps_client.RetrieveNickname(nickname)
- self.assert_(isinstance(retrieved_nickname, gdata.apps.NicknameEntry),
+ self.assertTrue(isinstance(retrieved_nickname, gdata.apps.NicknameEntry),
"Return value of RetrieveNickname method must be an instance of " +
"gdata.apps.NicknameEntry: %s" % retrieved_nickname)
- self.assertEquals(retrieved_nickname.login.user_name, user_name)
- self.assertEquals(retrieved_nickname.nickname.name, nickname)
+ self.assertEqual(retrieved_nickname.login.user_name, user_name)
+ self.assertEqual(retrieved_nickname.nickname.name, nickname)
# tests RetrieveNicknames method
nickname_feed = self.apps_client.RetrieveNicknames(user_name)
- self.assert_(isinstance(nickname_feed, gdata.apps.NicknameFeed),
+ self.assertTrue(isinstance(nickname_feed, gdata.apps.NicknameFeed),
"Return value of RetrieveNicknames method must be an instance of " +
"gdata.apps.NicknameFeed: %s" % nickname_feed)
- self.assertEquals(nickname_feed.entry[0].login.user_name, user_name)
- self.assertEquals(nickname_feed.entry[0].nickname.name, nickname)
+ self.assertEqual(nickname_feed.entry[0].login.user_name, user_name)
+ self.assertEqual(nickname_feed.entry[0].nickname.name, nickname)
# tests RetrieveAllNicknames method
nickname_feed = self.apps_client.RetrieveAllNicknames()
- self.assert_(isinstance(nickname_feed, gdata.apps.NicknameFeed),
+ self.assertTrue(isinstance(nickname_feed, gdata.apps.NicknameFeed),
"Return value of RetrieveAllNicknames method must be an instance of " +
"gdata.apps.NicknameFeed: %s" % nickname_feed)
succeed = False
@@ -271,16 +271,16 @@
if a_entry.login.user_name == user_name and \
a_entry.nickname.name == nickname:
succeed = True
- self.assert_(succeed,
+ self.assertTrue(succeed,
"There must be a nickname entry named %s." % nickname)
# tests DeleteNickname method
self.apps_client.DeleteNickname(nickname)
try:
non_existence = self.apps_client.RetrieveNickname(nickname)
- except gdata.apps.service.AppsForYourDomainException, e:
- self.assertEquals(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
- except Exception, e:
+ except gdata.apps.service.AppsForYourDomainException as e:
+ self.assertEqual(e.error_code, gdata.apps.service.ENTITY_DOES_NOT_EXIST)
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
else:
self.fail('No exception occurred')
@@ -301,13 +301,13 @@
for user in self.created_users:
try:
self.apps_client.DeleteUser(user.login.user_name)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
for email_list in self.created_email_lists:
try:
self.apps_client.DeleteEmailList(email_list.email_list.name)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
def test001MethodsForEmaillist(self):
"""Tests methods for emaillist """
@@ -322,7 +322,7 @@
user_yuji = self.apps_client.CreateUser(
user_name=user_name, family_name=family_name, given_name=given_name,
password=password, suspended=suspended)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(user_yuji)
@@ -337,7 +337,7 @@
user_taro = self.apps_client.CreateUser(
user_name=user_name, family_name=family_name, given_name=given_name,
password=password, suspended=suspended)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(user_taro)
@@ -346,13 +346,13 @@
list_name = 'list01-' + self.postfix
try:
created_email_list = self.apps_client.CreateEmailList(list_name)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assert_(isinstance(created_email_list, gdata.apps.EmailListEntry),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertTrue(isinstance(created_email_list, gdata.apps.EmailListEntry),
"Return value of CreateEmailList method must be an instance of " +
"EmailListEntry: %s" % created_email_list)
- self.assertEquals(created_email_list.email_list.name, list_name)
+ self.assertEqual(created_email_list.email_list.name, list_name)
self.created_email_lists.append(created_email_list)
# tests AddRecipientToEmailList method
@@ -360,86 +360,86 @@
recipient = self.apps_client.AddRecipientToEmailList(
user_yuji.login.user_name + '@' + apps_domain,
list_name)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assert_(isinstance(recipient, gdata.apps.EmailListRecipientEntry),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertTrue(isinstance(recipient, gdata.apps.EmailListRecipientEntry),
"Return value of AddRecipientToEmailList method must be an instance " +
"of EmailListRecipientEntry: %s" % recipient)
- self.assertEquals(recipient.who.email,
+ self.assertEqual(recipient.who.email,
user_yuji.login.user_name + '@' + apps_domain)
try:
recipient = self.apps_client.AddRecipientToEmailList(
user_taro.login.user_name + '@' + apps_domain,
list_name)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
# tests RetrieveAllRecipients method
try:
recipient_feed = self.apps_client.RetrieveAllRecipients(list_name)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assert_(isinstance(recipient_feed, gdata.apps.EmailListRecipientFeed),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertTrue(isinstance(recipient_feed, gdata.apps.EmailListRecipientFeed),
"Return value of RetrieveAllRecipients method must be an instance " +
"of EmailListRecipientFeed: %s" % recipient_feed)
- self.assertEquals(len(recipient_feed.entry), 2)
+ self.assertEqual(len(recipient_feed.entry), 2)
# tests RemoveRecipientFromEmailList method
try:
self.apps_client.RemoveRecipientFromEmailList(
user_taro.login.user_name + '@' + apps_domain, list_name)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
# make sure that removal succeeded.
try:
recipient_feed = self.apps_client.RetrieveAllRecipients(list_name)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assert_(isinstance(recipient_feed, gdata.apps.EmailListRecipientFeed),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertTrue(isinstance(recipient_feed, gdata.apps.EmailListRecipientFeed),
"Return value of RetrieveAllRecipients method must be an instance " +
"of EmailListRecipientFeed: %s" % recipient_feed)
- self.assertEquals(len(recipient_feed.entry), 1)
+ self.assertEqual(len(recipient_feed.entry), 1)
# tests RetrieveAllEmailLists
try:
list_feed = self.apps_client.RetrieveAllEmailLists()
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
- self.assert_(isinstance(list_feed, gdata.apps.EmailListFeed),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+ self.assertTrue(isinstance(list_feed, gdata.apps.EmailListFeed),
"Return value of RetrieveAllEmailLists method must be an instance" +
"of EmailListFeed: %s" % list_feed)
succeed = False
for email_list in list_feed.entry:
if email_list.email_list.name == list_name:
succeed = True
- self.assert_(succeed, "There must be an email list named %s" % list_name)
+ self.assertTrue(succeed, "There must be an email list named %RefactoringTool: Refactored ./tests/gdata_tests/apps/organization/service_test.py
s" % list_name)
# tests RetrieveEmailLists method.
try:
list_feed = self.apps_client.RetrieveEmailLists(
user_yuji.login.user_name + '@' + apps_domain)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
- self.assert_(isinstance(list_feed, gdata.apps.EmailListFeed),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+ self.assertTrue(isinstance(list_feed, gdata.apps.EmailListFeed),
"Return value of RetrieveEmailLists method must be an instance" +
"of EmailListFeed: %s" % list_feed)
succeed = False
for email_list in list_feed.entry:
if email_list.email_list.name == list_name:
succeed = True
- self.assert_(succeed, "There must be an email list named %s" % list_name)
+ self.assertTrue(succeed, "There must be an email list named %s" % list_name)
def testRetrieveEmailList(self):
new_list = self.apps_client.CreateEmailList('my_testing_email_list')
retrieved_list = self.apps_client.RetrieveEmailList('my_testing_email_list')
- self.assertEquals(new_list.title.text, retrieved_list.title.text)
- self.assertEquals(new_list.id.text, retrieved_list.id.text)
- self.assertEquals(new_list.email_list.name, retrieved_list.email_list.name)
+ self.assertEqual(new_list.title.text, retrieved_list.title.text)
+ self.assertEqual(new_list.id.text, retrieved_list.id.text)
+ self.assertEqual(new_list.email_list.name, retrieved_list.email_list.name)
self.apps_client.DeleteEmailList('my_testing_email_list')
@@ -467,13 +467,13 @@
for user in self.created_users:
try:
self.apps_client.DeleteUser(user.login.user_name)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
for email_list in self.created_email_lists:
try:
self.apps_client.DeleteEmailList(email_list.email_list.name)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
def test001Pagenation(self):
"""Tests for pagination. It takes toooo long."""
@@ -485,18 +485,18 @@
list_name = 'list%03d-' % i + self.postfix
try:
created_email_list = self.apps_client.CreateEmailList(list_name)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_email_lists.append(created_email_list)
list_feed = self.apps_client.RetrieveAllEmailLists()
- self.assertEquals(len(list_feed.entry), list_nums + quantity)
+ self.assertEqual(len(list_feed.entry), list_nums + quantity)
if __name__ == '__main__':
print ('Google Apps Service Tests\nNOTE: Please run these tests only with '
'a test domain. The tests may delete or update your domain\'s '
'account data.')
- apps_domain = raw_input('Please enter your domain: ')
- apps_username = raw_input('Please enter your username of admin account: ')
+ apps_domain = input('Please enter your domain: ')
+ apps_username = input('Please enter your username of admin account: ')
apps_password = getpass.getpass()
unittest.main()
--- ./tests/gdata_tests/apps/organization/service_test.py (original)
+++ ./tests/gdata_tests/apps/organization/service_test.py (refactored)
@@ -20,7 +20,7 @@
__author__ = 'Alexandre Vivien (alex@simplecode.fr)'
-import urllib
+import urllib.request, urllib.parse, urllib.error
import unittest
try:
from xml.etree import ElementTree
@@ -71,8 +71,8 @@
given_name=given_name,
password=password,
suspended=suspended)
- print 'User ' + user_name + ' created'
- except Exception, e:
+ print('User ' + user_name + ' created')
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(self.user_yuji)
@@ -89,8 +89,8 @@
given_name=given_name,
password=password,
suspended=suspended)
- print 'User ' + user_name + ' created'
- except Exception, e:
+ print('User ' + user_name + ' created')
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(self.user_taro)
@@ -107,28 +107,28 @@
given_name=given_name,
password=password,
suspended=suspended)
- print 'User ' + user_name + ' created'
- except Exception, e:
+ print('User ' + user_name + ' created')
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(self.user_alex)
def tearDown(self):
- print '\n'
+ print('\n')
for user in self.created_users:
try:
self.apps_client.DeleteUser(user.login.user_name)
- print 'User ' + user.login.user_name + ' deleted'
- except Exception, e:
- print e
+ print('User ' + user.login.user_name + ' deleted')
+ except Exception as e:
+ print(e)
# We reverse to delete sub OrgUnit first
self.created_org_units.reverse()
for org_unit_path in self.created_org_units:
try:
self.organization_client.DeleteOrgUnit(self.customer_id, org_unit_path)
- print 'OrgUnit ' + org_unit_path + ' deleted'
- except Exception, e:
- print e
+ print('OrgUnit ' + org_unit_path + ' deleted')
+ except Exception as e:
+ print(e)
def testOrganizationService(self):
@@ -136,9 +136,9 @@
try:
customer = self.organization_client.RetrieveCustomerId()
self.customer_id = customer['customerId']
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
- print 'tests RetrieveCustomerId successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+ print('tests RetrieveCustomerId successful')
# tests CreateOrgUnit method
orgUnit01_name = 'OrgUnit01-' + self.postfix
@@ -166,29 +166,29 @@
parent_org_unit_path='/',
description='OrgUnit Test 03',
block_inheritance=False)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(orgUnit01['orgUnitPath'], urllib.quote_plus(orgUnit01_name))
- self.assertEquals(orgUnit02['orgUnitPath'], urllib.quote_plus(orgUnit02_name))
- self.assertEquals(sub0rgUnit01['orgUnitPath'], urllib.quote_plus(orgUnit02_name) + '/' + urllib.quote_plus(sub0rgUnit01_name))
- self.assertEquals(orgUnit03['orgUnitPath'], urllib.quote_plus(orgUnit03_name))
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(orgUnit01['orgUnitPath'], urllib.parse.quote_plus(orgUnit01_name))
+ self.assertEqual(orgUnit02['orgUnitPath'], urllib.parse.quote_plus(orgUnit02_name))
+ self.assertEqual(sub0rgUnit01['orgUnitPath'], urllib.parse.quote_plus(orgUnit02_name) + '/' + urllib.parse.quote_plus(sub0rgUnit01_name))
+ self.assertEqual(orgUnit03['orgUnitPath'], urllib.parse.quote_plus(orgUnit03_name))
self.created_org_units.append(orgUnit01['orgUnitPath'])
self.created_org_units.append(orgUnit02['orgUnitPath'])
self.created_org_units.append(sub0rgUnit01['orgUnitPath'])
self.created_org_units.append(orgUnit03['orgUnitPath'])
- print 'tests CreateOrgUnit successful'
+ print('tests CreateOrgUnit successful')
# tests UpdateOrgUnit method
try:
updated_orgunit = self.organization_client.UpdateOrgUnit(self.customer_id,
org_unit_path=self.created_org_units[3],
description='OrgUnit Test 03 Updated description')
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(updated_orgunit['orgUnitPath'], self.created_org_units[3])
- print 'tests UpdateOrgUnit successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(updated_orgunit['orgUnitPath'], self.created_org_units[3])
+ print('tests UpdateOrgUnit successful')
# tests RetrieveOrgUnit method
try:
@@ -196,21 +196,21 @@
org_unit_path=self.created_org_units[1])
retrieved_suborgunit = self.organization_client.RetrieveOrgUnit(self.customer_id,
org_unit_path=self.created_org_units[2])
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(retrieved_orgunit['orgUnitPath'], self.created_org_units[1])
- self.assertEquals(retrieved_suborgunit['orgUnitPath'], self.created_org_units[2])
- print 'tests RetrieveOrgUnit successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(retrieved_orgunit['orgUnitPath'], self.created_org_units[1])
+ self.assertEqual(retrieved_suborgunit['orgUnitPath'], self.created_org_units[2])
+ print('tests RetrieveOrgUnit successful')
# tests RetrieveAllOrgUnits method
try:
retrieved_orgunits = self.organization_client.RetrieveAllOrgUnits(self.customer_id)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.assertTrue(len(retrieved_orgunits) >= len(self.created_org_units))
- print 'tests RetrieveAllOrgUnits successful'
+ print('tests RetrieveAllOrgUnits successful')
# tests MoveUserToOrgUnit method
try:
@@ -221,56 +221,56 @@
org_unit_path=self.created_org_units[1],
users_to_move=[self.user_taro.login.user_name + '@' + domain,
self.user_alex.login.user_name + '@' + domain])
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(updated_orgunit01['usersMoved'], self.user_yuji.login.user_name + '@' + domain)
- self.assertEquals(updated_orgunit02['usersMoved'], self.user_taro.login.user_name + '@' + domain + ',' + \
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(updated_orgunit01['usersMoved'], self.user_yuji.login.user_name + '@' + domain)
+ self.assertEqual(updated_orgunit02['usersMoved'], self.user_taro.login.user_name + '@' + domain + ',' + \
self.user_alex.login.user_name + '@' + domain)
- print 'tests MoveUserToOrgUnit successful'
+ print('tests MoveUserToOrgUnit successful')
# tests RetrieveSubOrgUnits method
try:
retrieved_suborgunits = self.organization_client.RetrieveSubOrgUnits(self.customer_id,
org_unit_path=self.created_org_units[1])
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_suborgunits), 1)
- self.assertEquals(retrieved_suborgunits[0]['orgUnitPath'], self.created_org_units[2])
- print 'tests RetrieveSubOrgUnits successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_suborgunits), 1)
+ self.assertEqual(retrieved_suborgunits[0]['orgUnitPath'], self.created_org_units[2])
+ print('tests RetrieveSubOrgUnits successful')
# tests RetrieveOrgUser method
trRefactoringTool: Refactored ./tests/gdata_tests/apps/organization/live_client_test.py
y:
retrieved_orguser = self.organization_client.RetrieveOrgUser(self.customer_id,
user_email=self.user_yuji.login.user_name + '@' + domain)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(retrieved_orguser['orgUserEmail'], self.user_yuji.login.user_name + '@' + domain)
- self.assertEquals(retrieved_orguser['orgUnitPath'], self.created_org_units[0])
- print 'tests RetrieveOrgUser successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(retrieved_orguser['orgUserEmail'], self.user_yuji.login.user_name + '@' + domain)
+ self.assertEqual(retrieved_orguser['orgUnitPath'], self.created_org_units[0])
+ print('tests RetrieveOrgUser successful')
# tests UpdateOrgUser method
try:
updated_orguser = self.organization_client.UpdateOrgUser(self.customer_id,
org_unit_path=self.created_org_units[0],
user_email=self.user_alex.login.user_name + '@' + domain)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(updated_orguser['orgUserEmail'], self.user_alex.login.user_name + '@' + domain)
- self.assertEquals(updated_orguser['orgUnitPath'], self.created_org_units[0])
- print 'tests UpdateOrgUser successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(updated_orguser['orgUserEmail'], self.user_alex.login.user_name + '@' + domain)
+ self.assertEqual(updated_orguser['orgUnitPath'], self.created_org_units[0])
+ print('tests UpdateOrgUser successful')
# tests RetrieveAllOrgUsers method
try:
retrieved_orgusers = self.organization_client.RetrieveAllOrgUsers(self.customer_id)
- except Exception, e:
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.assertTrue(len(retrieved_orgusers) >= len(self.created_users))
- print 'tests RetrieveAllOrgUsers successful'
+ print('tests RetrieveAllOrgUsers successful')
""" This test needs to create more than 100 test users
# tests RetrievePageOfOrgUsers method
@@ -293,11 +293,11 @@
try:
retrieved_orgusers = self.organization_client.RetrieveOrgUnitUsers(self.customer_id,
org_unit_path=self.created_org_units[0])
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_orgusers), 2)
- print 'tests RetrieveOrgUnitUsers successful'
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_orgusers), 2)
+ print('tests RetrieveOrgUnitUsers successful')
""" This test needs to create more than 100 test users
# tests RetrieveOrgUnitPageOfUsers method
@@ -324,7 +324,7 @@
NOTE: Please run these tests only with a test user account.
""")
- domain = raw_input('Google Apps domain: ')
- admin_email = '%s@%s' % (raw_input('Administrator username: '), domain)
+ domain = input('Google Apps domain: ')
+ admin_email = '%s@%s' % (input('Administrator username: '), domain)
admin_password = getpass.getpass('Administrator password: ')
unittest.main()
--- ./tests/gdata_tests/apps/organization/live_client_test.py (original)
+++ ./tests/gdata_tests/apps/organization/live_client_test.py (refactored)
@@ -117,18 +117,18 @@
parent_org_unit_path='/',
description=org_unit_description,
block_inheritance=False)
- self.assert_(isinstance(new_entry,
+ self.assertTrue(isinstance(new_entry,
gdata.apps.organization.data.OrgUnitEntry))
- self.assertEquals(new_entRefactoringTool: Refactored ./tests/gdata_tests/apps/organization/data_test.py
ry.org_unit_path, org_unit_path)
+ self.assertEqual(new_entry.org_unit_path, org_unit_path)
entry = self.client.RetrieveOrgUnit(customer_id, org_unit_path)
- self.assert_(isinstance(entry,
+ self.assertTrue(isinstance(entry,
gdata.apps.organization.data.OrgUnitEntry))
- self.assertEquals(entry.org_unit_name, org_unit_name)
- self.assertEquals(entry.org_unit_description, org_unit_description)
- self.assertEquals(entry.parent_org_unit_path, '')
- self.assertEquals(entry.org_unit_path, org_unit_path)
- self.assertEquals(entry.org_unit_block_inheritance, 'false')
+ self.assertEqual(entry.org_unit_name, org_unit_name)
+ self.assertEqual(entry.org_unit_description, org_unit_description)
+ self.assertEqual(entry.parent_org_unit_path, '')
+ self.assertEqual(entry.org_unit_path, org_unit_path)
+ self.assertEqual(entry.org_unit_block_inheritance, 'false')
self.client.DeleteOrgUnit(customer_id, org_unit_name)
--- ./tests/gdata_tests/apps/organization/data_test.py (original)
+++ ./tests/gdata_tests/apps/organization/data_test.py (refactored)
@@ -34,13 +34,13 @@
gdata.apps.organization.data.CustomerIdEntry)
def testCustomerIdEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.organization.data.CustomerIdEntry))
- self.assertEquals(self.entry.customer_id, 'C123A456B')
- self.assertEquals(self.entry.customer_org_unit_name, 'example.com')
- self.assertEquals(self.entry.customer_org_unit_description, 'example.com')
- self.assertEquals(self.entry.org_unit_name, 'example.com')
- self.assertEquals(self.entry.org_unit_description, 'tempdescription')
+ self.assertEqual(self.entry.customer_id, 'C123A456B')
+ self.assertEqual(self.entry.customer_org_unit_name, 'example.com')
+ self.assertEqual(self.entry.customer_org_unit_description, 'example.com')
+ self.assertEqual(self.entry.org_unit_name, 'example.com')
+ self.assertEqual(self.entry.org_unit_description, 'tempdescription')
class OrgUnitEntryTest(unittest.TestCase):
@@ -52,40 +52,40 @@
gdata.apps.organization.data.OrgUnitFeed)
def testOrgUnitEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.organization.data.OrgUnitEntry))
- self.assertEquals(self.entry.org_unit_description, 'New Test Org')
- self.assertEquals(self.entry.org_unit_name, 'Test Organization')
- self.assertEquals(self.entry.org_unit_path, 'Test/Test+Organization')
- self.assertEquals(self.entry.parent_org_unit_path, 'Test')
- self.assertEquals(self.entry.org_unit_block_inheritance, 'false')
+ self.assertEqual(self.entry.org_unit_description, 'New Test Org')
+ self.assertEqual(self.entry.org_unit_name, 'Test Organization')
+ self.assertEqual(self.entry.org_unit_path, 'Test/Test+Organization')
+ self.assertEqual(self.entry.parent_org_unit_path, 'Test')
+ self.assertEqual(self.entry.org_unit_block_inheritance, 'false')
def testOrgUnitFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.organization.data.OrgUnitFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.organization.data.OrgUnitEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.organization.data.OrgUnitEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orgunit/2.0/'
'C123A456B/testOrgUnit92'))
- self.assertEquals(self.feed.entry[0].org_unit_description, 'test92')
- self.RefactoringTool: Refactored ./tests/gdata_tests/apps/multidomain/live_client_test.py
assertEquals(self.feed.entry[0].org_unit_name, 'testOrgUnit92')
- self.assertEquals(self.feed.entry[0].org_unit_path, 'Test/testOrgUnit92')
- self.assertEquals(self.feed.entry[0].parent_org_unit_path, 'Test')
- self.assertEquals(self.feed.entry[0].org_unit_block_inheritance, 'false')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].org_unit_description, 'test92')
+ self.assertEqual(self.feed.entry[0].org_unit_name, 'testOrgUnit92')
+ self.assertEqual(self.feed.entry[0].org_unit_path, 'Test/testOrgUnit92')
+ self.assertEqual(self.feed.entry[0].parent_org_unit_path, 'Test')
+ self.assertEqual(self.feed.entry[0].org_unit_block_inheritance, 'false')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orgunit/2.0/'
'C123A456B/testOrgUnit93'))
- self.assertEquals(self.feed.entry[1].org_unit_description, 'test93')
- self.assertEquals(self.feed.entry[1].org_unit_name, 'testOrgUnit93')
- self.assertEquals(self.feed.entry[1].org_unit_path, 'Test/testOrgUnit93')
- self.assertEquals(self.feed.entry[1].parent_org_unit_path, 'Test')
- self.assertEquals(self.feed.entry[1].org_unit_block_inheritance, 'false')
+ self.assertEqual(self.feed.entry[1].org_unit_description, 'test93')
+ self.assertEqual(self.feed.entry[1].org_unit_name, 'testOrgUnit93')
+ self.assertEqual(self.feed.entry[1].org_unit_path, 'Test/testOrgUnit93')
+ self.assertEqual(self.feed.entry[1].parent_org_unit_path, 'Test')
+ self.assertEqual(self.feed.entry[1].org_unit_block_inheritance, 'false')
class OrgUserEntryTest(unittest.TestCase):
@@ -97,31 +97,31 @@
gdata.apps.organization.data.OrgUserFeed)
def testOrgUserEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.organization.data.OrgUserEntry))
- self.assertEquals(self.entry.user_email, 'admin@example.com')
- self.assertEquals(self.entry.org_unit_path, 'Test')
+ self.assertEqual(self.entry.user_email, 'admin@example.com')
+ self.assertEqual(self.entry.org_unit_path, 'Test')
def testOrgUserFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.organization.data.OrgUserFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.organization.data.OrgUserEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.organization.data.OrgUserEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orguser/2.0/'
'C123A456B/user720430%40example.com'))
- self.assertEquals(self.feed.entry[0].user_email, 'user720430@example.com')
- self.assertEquals(self.feed.entry[0].org_unit_path, 'Test')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].user_email, 'user720430@example.com')
+ self.assertEqual(self.feed.entry[0].org_unit_path, 'Test')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orguser/2.0/'
'C123A456B/user832648%40example.com'))
- self.assertEquals(self.feed.entry[1].user_email, 'user832648@example.com')
- self.assertEquals(self.feed.entry[1].org_unit_path, 'Test')
+ self.assertEqual(self.feed.entry[1].user_email, 'user832648@example.com')
+ self.assertEqual(self.feed.entry[1].org_unit_path, 'Test')
def suite():
--- ./tests/gdata_tests/apps/multidomain/live_client_test.py (original)
+++ ./tests/gdata_tests/apps/multidomain/live_client_test.py (refactored)
@@ -101,26 +101,26 @@
'51eea05d46317fadd5cad6787a8f562be90b4446', 'true',
hash_function='RefactoringTool: Refactored ./tests/gdata_tests/apps/multidomain/data_test.py
SHA-1')
- self.assert_(isinstance(new_entry,
+ self.assertTrue(isinstance(new_entry,
gdata.apps.multidomain.data.UserEntry))
- self.assertEquals(new_entry.first_name, 'Elizabeth')
- self.assertEquals(new_entry.last_name, 'Smith')
- self.assertEquals(new_entry.email, email)
- self.assertEquals(new_entry.password,
+ self.assertEqual(new_entry.first_name, 'Elizabeth')
+ self.assertEqual(new_entry.last_name, 'Smith')
+ self.assertEqual(new_entry.email, email)
+ self.assertEqual(new_entry.password,
'51eea05d46317fadd5cad6787a8f562be90b4446')
- self.assertEquals(new_entry.is_admin, 'true')
+ self.assertEqual(new_entry.is_admin, 'true')
fetched_entry = self.client.RetrieveUser(email=email)
- self.assertEquals(fetched_entry.first_name, 'Elizabeth')
- self.assertEquals(fetched_entry.last_name, 'Smith')
- self.assertEquals(fetched_entry.email, email)
- self.assertEquals(fetched_entry.is_admin, 'true')
+ self.assertEqual(fetched_entry.first_name, 'Elizabeth')
+ self.assertEqual(fetched_entry.last_name, 'Smith')
+ self.assertEqual(fetched_entry.email, email)
+ self.assertEqual(fetched_entry.is_admin, 'true')
new_entry.first_name = 'Joe'
new_entry.last_name = 'Brown'
updated_entry = self.client.UpdateUser(
email=email, user_entry=new_entry)
- self.assert_(isinstance(updated_entry,
+ self.assertTrue(isinstance(updated_entry,
gdata.apps.multidomain.data.UserEntry))
self.assertEqual(updated_entry.first_name, 'Joe')
self.assertEqual(updated_entry.last_name, 'Brown')
@@ -128,25 +128,25 @@
new_email = 'renamed_user%s@%s' % (rnd_number, self.client.domain)
renamed_entry = self.client.RenameUser(
old_email=email, new_email=new_email)
- self.assert_(isinstance(renamed_entry,
+ self.assertTrue(isinstance(renamed_entry,
gdata.apps.multidomain.data.UserRenameRequest))
self.assertEqual(renamed_entry.new_email, new_email)
new_alias = self.client.CreateAlias(new_email, alias)
- self.assert_(isinstance(new_alias,
+ self.assertTrue(isinstance(new_alias,
gdata.apps.multidomain.data.AliasEntry))
- self.assertEquals(new_alias.user_email, new_email)
- self.assertEquals(new_alias.alias_email, alias)
+ self.assertEqual(new_alias.user_email, new_email)
+ self.assertEqual(new_alias.alias_email, alias)
fetched_alias = self.client.RetrieveAlias(alias)
- self.assertEquals(fetched_alias.user_email, new_email)
- self.assertEquals(fetched_alias.alias_email, alias)
+ self.assertEqual(fetched_alias.user_email, new_email)
+ self.assertEqual(fetched_alias.alias_email, alias)
fetched_aliases = self.client.RetrieveAllUserAliases(new_email)
- self.assertEquals(fetched_aliases.entry[0].user_email, new_email)
- self.assertEquals(fetched_aliases.entry[0].alias_email, email)
- self.assertEquals(fetched_aliases.entry[1].user_email, new_email)
- self.assertEquals(fetched_aliases.entry[1].alias_email, alias)
+ self.assertEqual(fetched_aliases.entry[0].user_email, new_email)
+ self.assertEqual(fetched_aliases.entry[0].alias_email, email)
+ self.assertEqual(fetched_aliases.entry[1].user_email, new_email)
+ self.assertEqual(fetched_aliases.entry[1].alias_email, alias)
self.client.DeleteAlias(alias)
self.client.DeleteUser(new_email)
--- ./tests/gdata_tests/apps/multidomain/data_test.py (original)
+++ ./tests/gdata_tests/apps/multidomain/data_test.py (refactored)
@@ -36,45 +36,45 @@
gdata.apps.multidomain.data.UserFeed)
def testUserEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.multidomain.data.UserEntry))
- self.assertEquals(self.entry.first_name, 'Liz')
- self.assertEquals(self.entry.last_name, 'Smith')
- self.assertEquals(self.entry.email, 'liz@example.com')
- self.assertEquals(self.entry.password,
+ self.assertEqual(self.entry.first_name, 'Liz')
+ self.assertEqual(self.entry.last_name, 'Smith')
+ self.assertEqual(self.entry.email, 'liz@example.com')
+ self.assertEqual(self.entry.password,
'51eea05d46317fadd5cad6787a8f562be90b4446')
- self.assertEquals(self.entry.is_admin, 'true')
+ self.assertEqual(self.entry.is_admin, 'true')
def testUserFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.multidomain.data.UserFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.multidomain.data.UserEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.multidomain.data.UserEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/user/2.0/example.com/'
'admin%40example.com'))
- self.assertEquals(self.feed.entry[0].first_name, 'Joe')
- self.assertEquals(self.feed.entry[0].last_name, 'Brown')
- self.assertEquals(self.feed.entry[0].email, 'admin@example.com')
- self.assertEquals(self.feed.entry[0].is_admin, 'true')
- self.assertEquals(self.feed.entry[0].suspended, 'false')
- self.assertEquals(self.feed.entry[0].change_password_at_next_login, 'false')
- self.assertEquals(self.feed.entry[0].ip_whitelisted, 'false')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].first_name, 'Joe')
+ self.assertEqual(self.feed.entry[0].last_name, 'Brown')
+ self.assertEqual(self.feed.entry[0].email, 'admin@example.com')
+ self.assertEqual(self.feed.entry[0].is_admin, 'true')
+ self.assertEqual(self.feed.entry[0].suspended, 'false')
+ self.assertEqual(self.feed.entry[0].change_password_at_next_login, 'false')
+ self.assertEqual(self.feed.entry[0].ip_whitelisted, 'false')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/user/2.0/example.com/'
'liz%40example.com'))
- self.assertEquals(self.feed.entry[1].first_name, 'Elizabeth')
- self.assertEquals(self.feed.entry[1].last_name, 'Smith')
- self.assertEquals(self.feed.entry[1].email, 'liz@example.com')
- self.assertEquals(self.feed.entry[1].is_admin, 'true')
- self.assertEquals(self.feed.entry[1].suspended, 'false')
- self.assertEquals(self.feed.entry[1].change_password_at_next_login, 'false')
- self.assertEquals(self.feed.entry[1].ip_whitelisted, 'false')
+ self.assertEqual(self.feed.entry[1].first_name, 'Elizabeth')
+ self.assertEqual(self.feed.entry[1].last_name, 'Smith')
+ self.assertEqual(self.feed.entry[1].email, 'liz@example.com')
+ self.assertEqual(self.feed.entry[1].is_admin, 'true')
+ self.assertEqual(self.feed.entry[1].suspended, 'false')
+ self.assertEqual(self.feed.entry[1].change_password_at_next_login, 'false')
+ self.assertEqual(self.feed.entry[1].ip_whitelisted, 'false')
class UserRenameRequestTest(unittest.TestCase):
@@ -84,9 +84,9 @@
gdata.apps.multidomain.data.UserRenameRequest)
def testUserRenameRequestFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.multidomain.data.UserRenameRequest))
- self.assertEquals(self.entry.new_email, 'liz@newexample4liz.com')
+ self.assertEqual(self.entry.new_email, 'liz@newexample4liz.com')
class AliasEntryTest(unittest.TestCase):
@@ -98,32 +98,32 @@
gdata.apps.multidomain.data.AliasFeed)
def testAliasEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.multidomain.data.AliasEntry))
- self.assertEquals(self.entry.user_email, 'liz@example.com')
- self.assertEquals(self.entry.alias_email, 'helpdesk@gethelp_example.com')
+ self.assertEqual(self.entry.user_email, 'liz@example.com')
+ self.assertEqual(self.entry.alias_email, 'helpdesk@gethelp_example.com')
RefactoringTool: Refactored ./tests/gdata_tests/apps/migration/service_test.py
RefactoringTool: Refactored ./tests/gdata_tests/apps/live_client_test.py
def testAliasFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.multidomain.data.AliasFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.multidomain.data.AliasEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.multidomain.data.AliasEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/alias/2.0/gethelp_example.com/'
'helpdesk%40gethelp_example.com'))
- self.assertEquals(self.feed.entry[0].user_email, 'liz@example.com')
- self.assertEquals(self.feed.entry[0].alias_email,
+ self.assertEqual(self.feed.entry[0].user_email, 'liz@example.com')
+ self.assertEqual(self.feed.entry[0].alias_email,
'helpdesk@gethelp_example.com')
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/alias/2.0/gethelp_example.com/'
'support%40gethelp_example.com'))
- self.assertEquals(self.feed.entry[1].user_email, 'joe@example.com')
- self.assertEquals(self.feed.entry[1].alias_email,
+ self.assertEqual(self.feed.entry[1].user_email, 'joe@example.com')
+ self.assertEqual(self.feed.entry[1].alias_email,
'support@gethelp_example.com')
--- ./tests/gdata_tests/apps/migration/service_test.py (original)
+++ ./tests/gdata_tests/apps/migration/service_test.py (refactored)
@@ -52,7 +52,7 @@
mail_labels=['Test'])
def testImportMultipleMails(self):
- for i in xrange(1, 10):
+ for i in range(1, 10):
self.ms.AddMailEntry(mail_message=MESSAGE % ('Test thread %d' % i,
'Test thread'),
mail_item_properties=['IS_UNREAD'],
@@ -64,8 +64,8 @@
if __name__ == '__main__':
print("Google Apps Email Migration Service Tests\n\n"
"NOTE: Please run these tests only with a test user account.\n")
- domain = raw_input('Google Apps domain: ')
- admin_email = '%s@%s' % (raw_input('Administrator username: '), domain)
+ domain = input('Google Apps domain: ')
+ admin_email = '%s@%s' % (input('Administrator username: '), domain)
admin_password = getpass.getpass('Administrator password: ')
- username = raw_input('Test username: ')
+ username = input('Test username: ')
unittest.main()
--- ./tests/gdata_tests/apps/live_client_test.py (original)
+++ ./tests/gdata_tests/apps/live_client_test.py (refactored)
@@ -90,38 +90,38 @@
user_name=username, given_name='Elizabeth', family_name='Smith',
password='password', admin='true')
- self.assert_(isinstance(new_entry,
+ self.assertTrue(isinstance(new_entry,
gdata.apps.data.UserEntry))
- self.assertEquals(new_entry.name.given_name, 'Elizabeth')
- self.assertEquals(new_entry.name.family_name, 'Smith')
- self.assertEquals(new_entry.login.user_name, username)
- self.assertEquals(new_entry.login.admin, 'true')
+ self.assertEqual(new_entry.name.given_name, 'Elizabeth')
+ self.assertEqual(new_entry.name.family_name, 'Smith')
+ self.assertEqual(new_entry.login.user_name, username)
+ self.assertEqual(new_entry.login.admin, 'true')
fetched_entry = self.client.RetrieveUser(user_name=username)
- self.assertEquals(fetched_entry.name.given_name, 'Elizabeth')
- self.assertEquals(fetched_entry.name.family_name, 'Smith')
- self.assertEquals(fetched_entry.login.user_name, username)
- self.assertEquals(fetched_entry.login.admin, 'true')
+ self.assertEqual(fetched_entry.name.given_name, 'Elizabeth')
+ self.assertEqual(fetched_entry.name.family_name, 'Smith')
+ self.assertEqual(fetched_entry.login.user_name, username)
+ self.assertEqual(fetchedRefactoringTool: Refactored ./tests/gdata_tests/apps/groups/service_test.py
_entry.login.admin, 'true')
new_entry.name.given_name = 'Joe'
new_entry.name.family_name = 'Brown'
updated_entry = self.client.UpdateUser(
user_name=username, user_entry=new_entry)
- self.assert_(isinstance(updated_entry,
+ self.assertTrue(isinstance(updated_entry,
gdata.apps.data.UserEntry))
self.assertEqual(updated_entry.name.given_name, 'Joe')
self.assertEqual(updated_entry.name.family_name, 'Brown')
new_nickname = self.client.CreateNickname(user_name=username,
nickname=nickname)
- self.assert_(isinstance(new_nickname,
+ self.assertTrue(isinstance(new_nickname,
gdata.apps.data.NicknameEntry))
- self.assertEquals(new_nickname.login.user_name, username)
- self.assertEquals(new_nickname.nickname.name, nickname)
+ self.assertEqual(new_nickname.login.user_name, username)
+ self.assertEqual(new_nickname.nickname.name, nickname)
fetched_alias = self.client.RetrieveNickname(nickname)
- self.assertEquals(fetched_alias.login.user_name, username)
- self.assertEquals(fetched_alias.nickname.name, nickname)
+ self.assertEqual(fetched_alias.login.user_name, username)
+ self.assertEqual(fetched_alias.nickname.name, nickname)
self.client.DeleteNickname(nickname)
self.client.DeleteUser(username)
--- ./tests/gdata_tests/apps/groups/service_test.py (original)
+++ ./tests/gdata_tests/apps/groups/service_test.py (refactored)
@@ -67,8 +67,8 @@
self.user_yuji = self.apps_client.CreateUser(
user_name=user_name, family_name=family_name, given_name=given_name,
password=password, suspended=suspended)
- print 'User ' + user_name + ' created'
- except Exception, e:
+ print('User ' + user_name + ' created')
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(self.user_yuji)
@@ -83,26 +83,26 @@
self.user_taro = self.apps_client.CreateUser(
user_name=user_name, family_name=family_name, given_name=given_name,
password=password, suspended=suspended)
- print 'User ' + user_name + ' created'
- except Exception, e:
+ print('User ' + user_name + ' created')
+ except Exception as e:
self.fail('Unexpected exception occurred: %s' % e)
self.created_users.append(self.user_taro)
def tearDown(self):
- print '\n'
+ print('\n')
for user in self.created_users:
try:
self.apps_client.DeleteUser(user.login.user_name)
- print 'User ' + user.login.user_name + ' deleted'
- except Exception, e:
- print e
+ print('User ' + user.login.user_name + ' deleted')
+ except Exception as e:
+ print(e)
for group in self.created_groups:
try:
self.groups_client.DeleteGroup(group)
- print 'Group ' + group + ' deleted'
- except Exception, e:
- print e
+ print('Group ' + group + ' deleted')
+ except Exception as e:
+ print(e)
def test001GroupsMethods(self):
# tests CreateGroup method
@@ -113,11 +113,11 @@
'Testing', gdata.apps.groups.service.PERMISSION_OWNER)
created_group02 = self.groups_client.CreateGroup(group02_id, 'US Sales 2',
'Testing', gdata.apps.groups.service.PERMISSION_OWNER)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(created_group01['groupId'], group01_id)
- self.assertEquals(created_group02['groupId'], group02_id)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(created_group01['groupId'], group01_id)
+ self.assertEqual(created_group02['groupId'], group02_id)
self.created_groups.append(group01_id)
self.created_groups.append(group02_id)
@@ -125,26 +125,26 @@
try:
updated_group = self.groups_client.UpdateGroup(group01_id, 'Updated!',
'Testing', gdata.apps.groups.service.PERMISSION_OWNER)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(updated_group['groupName'], 'Updated!')
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(updated_group['groupName'], 'Updated!')
# tests RetrieveGroup method
try:
retrieved_group = self.groups_client.RetrieveGroup(group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(retrieved_group['groupId'], group01_id + '@' + domain)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(retrieved_group['groupId'], group01_id + '@' + domain)
# tests RetrieveAllGroups method
try:
retrieved_groups = self.groups_client.RetrieveAllGroups()
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_groups),
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_groups),
len(self.apps_client.RetrieveAllEmailLists().entry))
# tests AddMemberToGroup
@@ -155,10 +155,10 @@
self.user_taro.login.user_name, group02_id)
self.groups_client.AddMemberToGroup(
group01_id, group02_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(added_member['memberId'],
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(added_member['memberId'],
self.user_yuji.login.user_name)
# tests RetrieveGroups method
@@ -167,10 +167,10 @@
self.user_yuji.login.user_name, True)
retrieved_groups = self.groups_client.RetrieveGroups(
self.user_yuji.login.user_name, False)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_direct_groups), 1)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_direct_groups), 1)
# TODO: Enable this test after a directOnly bug is fixed
#self.assertEquals(len(retrieved_groups), 2)
@@ -178,85 +178,85 @@
try:
result = self.groups_client.IsMember(
self.user_yuji.login.user_name, group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(result, True)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(result, True)
# tests RetrieveMember method
try:
retrieved_member = self.groups_client.RetrieveMember(
self.user_yuji.login.user_name, group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(retrieved_member['memberId'],
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(retrieved_member['memberId'],
self.user_yuji.login.user_name + '@' + domain)
# tests RetrieveAllMembers method
try:
retrieved_members = self.groups_client.RetrieveAllMembers(group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_members), 1)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_members), 1)
# tests RemoveMemberFromGroup method
try:
self.groups_client.RemoveMemberFromGroup(self.user_yuji.login.user_name,
group01_id)
retrieved_members = self.groups_client.RetrieveAllMembers(group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_members), 0)
+ except Exception as e:
+ self.fail('Unexpected exception occurrRefactoringTool: Refactored ./tests/gdata_tests/apps/groups/live_client_test.py
ed: %s' % e)
+
+ self.assertEqual(len(retrieved_members), 0)
# tests AddOwnerToGroup
try:
added_owner = self.groups_client.AddOwnerToGroup(
self.user_yuji.login.user_name, group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(added_owner['email'],
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(added_owner['email'],
self.user_yuji.login.user_name)
# tests IsOwner method
try:
result = self.groups_client.IsOwner(
self.user_yuji.login.user_name, group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(result, True)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(result, True)
# tests RetrieveOwner method
try:
retrieved_owner = self.groups_client.RetrieveOwner(
self.user_yuji.login.user_name, group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(retrieved_owner['email'],
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(retrieved_owner['email'],
self.user_yuji.login.user_name + '@' + domain)
# tests RetrieveAllOwners method
try:
retrieved_owners = self.groups_client.RetrieveAllOwners(group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_owners), 1)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_owners), 1)
# tests RemoveOwnerFromGroup method
try:
self.groups_client.RemoveOwnerFromGroup(self.user_yuji.login.user_name,
group01_id)
retrieved_owners = self.groups_client.RetrieveAllOwners(group01_id)
- except Exception, e:
- self.fail('Unexpected exception occurred: %s' % e)
-
- self.assertEquals(len(retrieved_owners), 0)
+ except Exception as e:
+ self.fail('Unexpected exception occurred: %s' % e)
+
+ self.assertEqual(len(retrieved_owners), 0)
if __name__ == '__main__':
@@ -264,7 +264,7 @@
NOTE: Please run these tests only with a test user account.
""")
- domain = raw_input('Google Apps domain: ')
- admin_email = '%s@%s' % (raw_input('Administrator username: '), domain)
+ domain = input('Google Apps domain: ')
+ admin_email = '%s@%s' % (input('Administrator username: '), domain)
admin_password = getpass.getpass('Administrator password: ')
unittest.main()
--- ./tests/gdata_tests/apps/groups/live_client_test.py (original)
+++ ./tests/gdata_tests/apps/groups/live_client_test.py (refactored)
@@ -102,37 +102,37 @@
group_id=group_id, group_name=group_name, description='Test Group',
email_permission='Domain')
- self.assert_(isinstance(new_group,
+ self.assertTrue(isinstance(new_group,
gdata.apps.groups.data.GroupEntry))
- self.assertEquals(new_group.group_id, group_id)
- self.assertEquals(new_group.group_name, group_name)
- self.assertEquals(new_group.description, 'Test Group')
- self.assertEquals(new_group.email_permission, 'Domain')
+ self.assertEqual(new_group.group_id, group_id)
+ self.assertEqual(new_group.group_name, group_name)
+ self.assertEqual(new_group.description, 'Test Group')
+ self.assertEqual(new_group.email_permission, 'Domain')
fetched_entry = self.client.RetrieveGroup(group_id=group_id)
- self.assert_(isinstance(fetched_entry,
+ self.assertTrue(isinstance(fetched_entry,
gdata.apps.groups.data.GroupEntry))
- self.assertEquals(new_group.group_id, group_id)
- self.assertEquals(new_group.group_name, group_name)
- self.assertEquals(new_group.description, 'Test Group')
- RefactoringTool: Refactored ./tests/gdata_tests/apps/groups/data_test.py
self.assertEquals(new_group.email_permission, 'Domain')
+ self.assertEqual(new_group.group_id, group_id)
+ self.assertEqual(new_group.group_name, group_name)
+ self.assertEqual(new_group.description, 'Test Group')
+ self.assertEqual(new_group.email_permission, 'Domain')
new_group.group_name = 'updated name'
updated_group = self.client.UpdateGroup(
group_id=group_id, group_entry=new_group)
- self.assert_(isinstance(updated_group,
+ self.assertTrue(isinstance(updated_group,
gdata.apps.groups.data.GroupEntry))
self.assertEqual(updated_group.group_name, 'updated name')
new_member = self.client.AddMemberToGroup(group_id=group_id,
member_id=member_id)
- self.assert_(isinstance(new_member,
+ self.assertTrue(isinstance(new_member,
gdata.apps.groups.data.GroupMemberEntry))
- self.assertEquals(new_member.member_id, member_id)
+ self.assertEqual(new_member.member_id, member_id)
fetched_member = self.client.RetrieveGroupMember(group_id=group_id,
member_id=member_id)
- self.assertEquals(fetched_member.member_id, member_id)
+ self.assertEqual(fetched_member.member_id, member_id)
self.client.RemoveMemberFromGroup(group_id=group_id,
member_id=member_id)
--- ./tests/gdata_tests/apps/groups/data_test.py (original)
+++ ./tests/gdata_tests/apps/groups/data_test.py (refactored)
@@ -36,37 +36,37 @@
gdata.apps.groups.data.GroupFeed, 2)
def testGroupEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.groups.data.GroupEntry))
- self.assertEquals(self.entry.group_id, 'trial@srkapps.com')
- self.assertEquals(self.entry.group_name, 'Trial')
- self.assertEquals(self.entry.email_permission, 'Domain')
- self.assertEquals(self.entry.description, 'For try')
+ self.assertEqual(self.entry.group_id, 'trial@srkapps.com')
+ self.assertEqual(self.entry.group_name, 'Trial')
+ self.assertEqual(self.entry.email_permission, 'Domain')
+ self.assertEqual(self.entry.description, 'For try')
def testGroupFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.groups.data.GroupFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.groups.data.GroupEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.groups.data.GroupEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('http://apps-apis.google.com/a/feeds/group/2.0/srkapps.com/'
'firstgroup%40srkapps.com'))
- self.assertEquals(self.feed.entry[0].group_id, 'firstgroup@srkapps.com')
- self.assertEquals(self.feed.entry[0].group_name, 'FirstGroup')
- self.assertEquals(self.feed.entry[0].email_permission, 'Domain')
- self.assertEquals(self.feed.entry[0].description, 'First group')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].group_id, 'firstgroup@srkapps.com')
+ self.assertEqual(self.feed.entry[0].group_name, 'FirstGroup')
+ self.assertEqual(self.feed.entry[0].email_permission, 'Domain')
+ self.assertEqual(self.feed.entry[0].description, 'First group')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('http://apps-apis.google.com/a/feeds/group/2.0/srkapps.com/'
'trial%40srkapps.com'))
- self.assertEquals(self.feed.entry[1].group_id, 'trial@srkapps.com')
- self.assertEquals(self.feed.entry[1].group_name, 'Trial')
- self.assertEquals(self.feed.entry[1].email_permission, 'Domain')
- self.assertEquals(self.feed.entry[1].description, 'For try')
+ self.assertEqual(self.feed.entry[1].group_id, 'trial@srkapps.com')
+ self.assertEqual(self.feed.entry[1].group_name, 'Trial')
+ self.assertEqual(self.feed.entry[1].emaiRefactoringTool: Refactored ./tests/gdata_tests/apps/emailsettings/service_test.py
l_permission, 'Domain')
+ self.assertEqual(self.feed.entry[1].description, 'For try')
class GroupMemberEntryTest(unittest.TestCase):
@@ -78,35 +78,35 @@
gdata.apps.groups.data.GroupMemberFeed)
def testGroupMemberEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.groups.data.GroupMemberEntry))
- self.assertEquals(self.entry.member_id, 'abcd12310@srkapps.com')
- self.assertEquals(self.entry.member_type, 'User')
- self.assertEquals(self.entry.direct_member, 'true')
+ self.assertEqual(self.entry.member_id, 'abcd12310@srkapps.com')
+ self.assertEqual(self.entry.member_type, 'User')
+ self.assertEqual(self.entry.direct_member, 'true')
def testGroupMemberFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.groups.data.GroupMemberFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.groups.data.GroupMemberEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.groups.data.GroupMemberEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('http://apps-apis.google.com/a/feeds/group/2.0/srkapps.com/trial/'
'member/abcd12310%40srkapps.com'))
- self.assertEquals(self.feed.entry[0].member_id, 'abcd12310@srkapps.com')
- self.assertEquals(self.feed.entry[0].member_type, 'User')
- self.assertEquals(self.feed.entry[0].direct_member, 'true')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].member_id, 'abcd12310@srkapps.com')
+ self.assertEqual(self.feed.entry[0].member_type, 'User')
+ self.assertEqual(self.feed.entry[0].direct_member, 'true')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('http://apps-apis.google.com/a/feeds/group/2.0/srkapps.com/trial/'
'member/neha.technocrat%40srkapps.com'))
- self.assertEquals(self.feed.entry[1].member_id,
+ self.assertEqual(self.feed.entry[1].member_id,
'neha.technocrat@srkapps.com')
- self.assertEquals(self.feed.entry[1].member_type, 'User')
- self.assertEquals(self.feed.entry[1].direct_member, 'true')
+ self.assertEqual(self.feed.entry[1].member_type, 'User')
+ self.assertEqual(self.feed.entry[1].direct_member, 'true')
def suite():
--- ./tests/gdata_tests/apps/emailsettings/service_test.py (original)
+++ ./tests/gdata_tests/apps/emailsettings/service_test.py (refactored)
@@ -41,7 +41,7 @@
def testCreateLabel(self):
result = self.es.CreateLabel(username, label='New label!!!')
- self.assertEquals(result['label'], 'New label!!!')
+ self.assertEqual(result['label'], 'New label!!!')
def testCreateFilter(self):
result = self.es.CreateFilter(username,
@@ -54,9 +54,9 @@
label='label_foo',
should_mark_as_read=True,
should_archive=True)
- self.assertEquals(result['from'], 'from_foo')
- self.assertEquals(result['to'], 'to_foo')
- self.assertEquals(result['subject'], 'subject_foo')
+ self.assertEqual(result['from'], 'from_foo')
+ self.assertEqual(result['to'], 'to_foo')
+ self.assertEqual(result['subject'], 'subject_foo')
def testCreateSendAsAlias(self):
result = self.es.CreateSendAsAlias(username,
@@ -64,29 +64,29 @@
address='user2@sizzles.org',
reply_to='user3@sizzles.org',
make_default=True)
- self.assertEquals(result['name'], 'Send-as Alias')
+ self.assertEqual(result['name'], 'Send-as Alias')
def testUpdateWebClipSettings(self):
result = self.es.UpdateWebClipSettings(username, enable=True)
- self.assertEquals(result['enRefactoringTool: Refactored ./tests/gdata_tests/apps/emailsettings/live_client_test.py
able'], 'true')
+ self.assertEqual(result['enable'], 'true')
def testUpdateForwarding(self):
result = self.es.UpdateForwarding(username,
enable=True,
forward_to='user4@sizzles.org',
action=gdata.apps.emailsettings.service.KEEP)
- self.assertEquals(result['enable'], 'true')
+ self.assertEqual(result['enable'], 'true')
def testUpdatePop(self):
result = self.es.UpdatePop(username,
enable=True,
enable_for=gdata.apps.emailsettings.service.ALL_MAIL,
action=gdata.apps.emailsettings.service.ARCHIVE)
- self.assertEquals(result['enable'], 'true')
+ self.assertEqual(result['enable'], 'true')
def testUpdateImap(self):
result = self.es.UpdateImap(username, enable=True)
- self.assertEquals(result['enable'], 'true')
+ self.assertEqual(result['enable'], 'true')
def testUpdateVacation(self):
result = self.es.UpdateVacation(username,
@@ -94,15 +94,15 @@
subject='Hawaii',
message='Wish you were here!',
contacts_only=True)
- self.assertEquals(result['subject'], 'Hawaii')
+ self.assertEqual(result['subject'], 'Hawaii')
def testUpdateSignature(self):
result = self.es.UpdateSignature(username, signature='Signature')
- self.assertEquals(result['signature'], 'Signature')
+ self.assertEqual(result['signature'], 'Signature')
def testUpdateLanguage(self):
result = self.es.UpdateLanguage(username, language='fr')
- self.assertEquals(result['language'], 'fr')
+ self.assertEqual(result['language'], 'fr')
def testUpdateGeneral(self):
result = self.es.UpdateGeneral(username,
@@ -110,8 +110,8 @@
shortcuts=True,
arrows=True,
snippets=True,
- unicode=True)
- self.assertEquals(result['pageSize'], '100')
+ str=True)
+ self.assertEqual(result['pageSize'], '100')
if __name__ == '__main__':
@@ -119,8 +119,8 @@
NOTE: Please run these tests only with a test user account.
""")
- domain = raw_input('Google Apps domain: ')
- admin_email = '%s@%s' % (raw_input('Administrator username: '), domain)
+ domain = input('Google Apps domain: ')
+ admin_email = '%s@%s' % (input('Administrator username: '), domain)
admin_password = getpass.getpass('Administrator password: ')
- username = raw_input('Test username: ')
+ username = input('Test username: ')
unittest.main()
--- ./tests/gdata_tests/apps/emailsettings/live_client_test.py (original)
+++ ./tests/gdata_tests/apps/emailsettings/live_client_test.py (refactored)
@@ -76,7 +76,7 @@
username=conf.options.get_value('targetusername'),
name='status updates')
- self.assert_(isinstance(new_label,
+ self.assertTrue(isinstance(new_label,
gdata.apps.emailsettings.data.EmailSettingsLabel))
self.assertEqual(new_label.name, 'status updates')
@@ -96,7 +96,7 @@
from_address='alice@gmail.com',
has_the_word='project proposal', mark_as_read=True)
- self.assert_(isinstance(new_filter,
+ self.assertTrue(isinstance(new_filter,
gdata.apps.emailsettings.data.EmailSettingsFilter))
self.assertEqual(new_filter.from_address, 'alice@gmail.com')
self.assertEqual(new_filter.has_the_word, 'project proposal')
@@ -107,7 +107,7 @@
to_address='announcements@example.com',
label="announcements")
- self.assert_(isinstance(new_filter,
+ self.assertTrue(isinstance(new_filter,
gdata.apps.emailsettings.data.EmailSettingsFilter))
self.assertEqual(new_filter.to_address, 'announcements@example.com')
self.assertEqual(new_filter.label, 'announcements')
@@ -119,7 +119,7 @@
has_attachments=True,
archive=True)
- self.assert_(isinstance(new_filter,
+ self.assertTrue(isinstance(new_filter,
gdata.apps.emailsettings.data.EmailSettingsFilter))
self.assertEqual(new_filter.subject, 'urgent')
self.assertEqual(new_filter.does_not_have_the_word, 'spam')
@@ -139,7 +139,7 @@
reply_to='abc@gmail.com',
make_default=True)
- self.assert_(isinstance(new_sendas,
+ self.assertTrue(isinstance(new_sendas,
gdata.apps.emailsettings.data.EmailSettingsSendAsAlias))
self.assertEqual(new_sendas.name, 'Sales')
self.assertEqual(new_sendas.address,
@@ -158,7 +158,7 @@
username=conf.options.get_value('targetusername'),
enable=True)
- self.assert_(isinstance(new_webclip,
+ self.assertTrue(isinstance(new_webclip,
gdata.apps.emailsettings.data.EmailSettingsWebClip))
self.assertEqual(new_webclip.enable, 'True')
@@ -166,7 +166,7 @@
username=conf.options.get_value('targetusername'),
enable=False)
- self.assert_(isinstance(new_webclip,
+ self.assertTrue(isinstance(new_webclip,
gdata.apps.emailsettings.data.EmailSettingsWebClip))
self.assertEqual(new_webclip.enable, 'False')
@@ -183,7 +183,7 @@
forward_to=conf.options.get_value('appsusername'),
action='KEEP')
- self.assert_(isinstance(new_forwarding,
+ self.assertTrue(isinstance(new_forwarding,
gdata.apps.emailsettings.data.EmailSettingsForwarding))
self.assertEqual(new_forwarding.enable, 'True')
self.assertEqual(new_forwarding.forward_to,
@@ -194,7 +194,7 @@
username=conf.options.get_value('targetusername'),
enable=False)
- self.assert_(isinstance(new_forwarding,
+ self.assertTrue(isinstance(new_forwarding,
gdata.apps.emailsettings.data.EmailSettingsForwarding))
self.assertEqual(new_forwarding.enable, 'False')
@@ -209,7 +209,7 @@
username=conf.options.get_value('targetusername'),
enable=True, enable_for='MAIL_FROM_NOW_ON', action='KEEP')
- self.assert_(isinstance(new_pop,
+ self.assertTrue(isinstance(new_pop,
gdata.apps.emailsettings.data.EmailSettingsPop))
self.assertEqual(new_pop.enable, 'True')
self.assertEqual(new_pop.enable_for, 'MAIL_FROM_NOW_ON')
@@ -219,7 +219,7 @@
username=conf.options.get_value('targetusername'),
enable=False)
- self.assert_(isinstance(new_pop,
+ self.assertTrue(isinstance(new_pop,
gdata.apps.emailsettings.data.EmailSettingsPop))
self.assertEqual(new_pop.enable, 'False')
@@ -234,7 +234,7 @@
username=conf.options.get_value('targetusername'),
enable=True)
- self.assert_(isinstance(new_imap,
+ self.assertTrue(isinstance(new_imap,
gdata.apps.emailsettings.data.EmailSettingsImap))
self.assertEqual(new_imap.enable, 'True')
@@ -242,7 +242,7 @@
username=conf.options.get_value('targetusername'),
enable=False)
- self.assert_(isinstance(new_imap,
+ self.assertTrue(isinstance(new_imap,
gdata.apps.emailsettings.data.EmailSettingsImap))
self.assertEqual(new_imap.enable, 'False')
@@ -260,7 +260,7 @@
start_date='2011-12-05', end_date='2011-12-06',
contacts_only=True, domain_only=False)
- self.assert_(isinstance(new_vacation,
+ self.assertTrue(isinstance(new_vacation,
gdata.apps.emailsettings.data.EmailSettingsVacationResponder))
self.assertEqual(new_vacation.enable, 'True')
self.assertEqual(new_vacation.subject, 'Out of office')
@@ -274,7 +274,7 @@
username=conf.options.get_value('targetusername'),
enable=False)
- self.assert_(isinstance(new_vacation,
+ self.assertTrue(isinstance(new_vacation,
gdata.apps.emailsettings.data.EmailSettingsVacationResponder))
self.assertEqual(new_vacation.enable, 'False')
@@ -289,7 +289,7 @@
username=conf.options.get_value('targetusername'),
signature='Regards, Joe')
- self.assert_(isinstance(new_signature,
+ self.assertTrue(isinstance(new_signatureRefactoringTool: Refactored ./tests/gdata_tests/apps/emailsettings/data_test.py
,
gdata.apps.emailsettings.data.EmailSettingsSignature))
self.assertEqual(new_signature.signature_value, 'Regards, Joe')
@@ -297,7 +297,7 @@
username=conf.options.get_value('targetusername'),
signature='')
- self.assert_(isinstance(new_signature,
+ self.assertTrue(isinstance(new_signature,
gdata.apps.emailsettings.data.EmailSettingsSignature))
self.assertEqual(new_signature.signature_value, '')
@@ -312,7 +312,7 @@
username=conf.options.get_value('targetusername'),
language='es')
- self.assert_(isinstance(new_language,
+ self.assertTrue(isinstance(new_language,
gdata.apps.emailsettings.data.EmailSettingsLanguage))
self.assertEqual(new_language.language_tag, 'es')
@@ -327,7 +327,7 @@
username=conf.options.get_value('targetusername'),
page_size=25, arrows=True)
- self.assert_(isinstance(new_general,
+ self.assertTrue(isinstance(new_general,
gdata.apps.emailsettings.data.EmailSettingsGeneral))
self.assertEqual(new_general.page_size, '25')
self.assertEqual(new_general.arrows, 'True')
@@ -336,7 +336,7 @@
username=conf.options.get_value('targetusername'),
shortcuts=False, snippets=True, use_unicode=False)
- self.assert_(isinstance(new_general,
+ self.assertTrue(isinstance(new_general,
gdata.apps.emailsettings.data.EmailSettingsGeneral))
self.assertEqual(new_general.shortcuts, 'False')
self.assertEqual(new_general.snippets, 'True')
--- ./tests/gdata_tests/apps/emailsettings/data_test.py (original)
+++ ./tests/gdata_tests/apps/emailsettings/data_test.py (refactored)
@@ -30,7 +30,7 @@
def testName(self):
self.entry.name = 'test label'
- self.assertEquals(self.entry.name, 'test label')
+ self.assertEqual(self.entry.name, 'test label')
class EmailSettingsFilterTest(unittest.TestCase):
@@ -40,43 +40,43 @@
def testFrom(self):
self.entry.from_address = 'abc@example.com'
- self.assertEquals(self.entry.from_address, 'abc@example.com')
+ self.assertEqual(self.entry.from_address, 'abc@example.com')
def testTo(self):
self.entry.to_address = 'to@example.com'
- self.assertEquals(self.entry.to_address, 'to@example.com')
+ self.assertEqual(self.entry.to_address, 'to@example.com')
def testFrom(self):
self.entry.from_address = 'abc@example.com'
- self.assertEquals(self.entry.from_address, 'abc@example.com')
+ self.assertEqual(self.entry.from_address, 'abc@example.com')
def testSubject(self):
self.entry.subject = 'Read me'
- self.assertEquals(self.entry.subject, 'Read me')
+ self.assertEqual(self.entry.subject, 'Read me')
def testHasTheWord(self):
self.entry.has_the_word = 'important'
- self.assertEquals(self.entry.has_the_word, 'important')
+ self.assertEqual(self.entry.has_the_word, 'important')
def testDoesNotHaveTheWord(self):
self.entry.does_not_have_the_word = 'spam'
- self.assertEquals(self.entry.does_not_have_the_word, 'spam')
+ self.assertEqual(self.entry.does_not_have_the_word, 'spam')
def testHasAttachments(self):
self.entry.has_attachments = True
- self.assertEquals(self.entry.has_attachments, True)
+ self.assertEqual(self.entry.has_attachments, True)
def testLabel(self):
self.entry.label = 'Trip reports'
- self.assertEquals(self.entry.label, 'Trip reports')
+ self.assertEqual(self.entry.label, 'Trip reports')
def testMarkHasRead(self):
self.entry.mark_has_read = True
- self.assertEquals(self.entry.mark_has_read, True)
+ self.assertEqual(self.entry.mark_has_read, True)
def testArchive(self):
self.entry.archive = True
- self.assertEquals(self.entry.archive, True)
+ self.assertEqual(self.entry.archive, True)
class EmailSettingsSendAsAliasTest(unittest.TestCase):
@@ -86,19 +86,19 @@
def testName(self):
self.entry.name = 'Sales'
- self.assertEquals(self.entry.name, 'Sales')
+ self.assertEqual(self.entry.name, 'Sales')
def testAddress(self):
self.entry.address = 'sales@example.com'
- self.assertEquals(self.entry.address, 'sales@example.com')
+ self.assertEqual(self.entry.address, 'sales@example.com')
def testReplyTo(self):
self.entry.reply_to = 'support@example.com'
- self.assertEquals(self.entry.reply_to, 'support@example.com')
+ self.assertEqual(self.entry.reply_to, 'support@example.com')
def testMakeDefault(self):
self.entry.make_default = True
- self.assertEquals(self.entry.make_default, True)
+ self.assertEqual(self.entry.make_default, True)
class EmailSettingsWebClipTest(unittest.TestCase):
@@ -108,7 +108,7 @@
def testEnable(self):
self.entry.enable = True
- self.assertEquals(self.entry.enable, True)
+ self.assertEqual(self.entry.enable, True)
class EmailSettingsForwardingTest(unittest.TestCase):
@@ -118,15 +118,15 @@
def testEnable(self):
self.entry.enable = True
- self.assertEquals(self.entry.enable, True)
+ self.assertEqual(self.entry.enable, True)
def testForwardTo(self):
self.entry.forward_to = 'fred@example.com'
- self.assertEquals(self.entry.forward_to, 'fred@example.com')
+ self.assertEqual(self.entry.forward_to, 'fred@example.com')
def testAction(self):
self.entry.action = 'KEEP'
- self.assertEquals(self.entry.action, 'KEEP')
+ self.assertEqual(self.entry.action, 'KEEP')
class EmailSettingsPopTest(unittest.TestCase):
@@ -136,15 +136,15 @@
def testEnable(self):
self.entry.enable = True
- self.assertEquals(self.entry.enable, True)
+ self.assertEqual(self.entry.enable, True)
def testForwardTo(self):
self.entry.enable_for = 'ALL_MAIL'
- self.assertEquals(self.entry.enable_for, 'ALL_MAIL')
+ self.assertEqual(self.entry.enable_for, 'ALL_MAIL')
def testAction(self):
self.entry.action = 'KEEP'
- self.assertEquals(self.entry.action, 'KEEP')
+ self.assertEqual(self.entry.action, 'KEEP')
class EmailSettingsImapTest(unittest.TestCase):
@@ -154,7 +154,7 @@
def testEnable(self):
self.entry.enable = True
- self.assertEquals(self.entry.enable, True)
+ self.assertEqual(self.entry.enable, True)
class EmailSettingsVacationResponderTest(unittest.TestCase):
@@ -164,31 +164,31 @@
def testEnable(self):
self.entry.enable = True
- self.assertEquals(self.entry.enable, True)
+ self.assertEqual(self.entry.enable, True)
def testSubject(self):
self.entry.subject = 'On vacation!'
- self.assertEquals(self.entry.subject, 'On vacation!')
+ self.assertEqual(self.entry.subject, 'On vacation!')
def testMessage(self):
self.entry.message = 'See you on September 1st'
- self.assertEquals(self.entry.message, 'See you on September 1st')
+ self.assertEqual(self.entry.message, 'See you on September 1st')
def testStartDate(self):
self.entry.start_date = '2011-12-05'
- self.assertEquals(self.entry.start_date, '2011-12-05')
+ self.assertEqual(self.entry.start_date, '2011-12-05')
def testEndDate(self):
self.entry.end_date = '2011-12-06'
- self.assertEquals(self.entry.end_date, '2011-12-06')
+ self.assertEqual(self.entry.end_date, '2011-12-06')
def testContactsOnly(self):
self.entry.contacts_only = True
- self.assertEquals(self.entry.contacts_only, True)
+ self.assertEqual(self.entry.contacts_only, True)
def testDomainOnly(self):
self.entry.domain_only = True
- self.assertEquals(self.entry.domain_only, True)
+ self.assertEqual(self.entry.domain_only, True)
class EmailSettingsSignatureTest(unittest.TestCase):
@@ -198,7 +198,7 @@
def testValue(self):
self.entry.signature_value = 'Regards, Joe'
- self.assertEquals(self.entry.signature_value, 'Regards, Joe')
+ self.assertEqual(self.entry.signature_value, 'Regards, Joe')
class EmailSettingsLanguageTest(unittest.TestCase):
@@ -208,7 +208,7 @@
def testLanguage(self):
self.entry.language_tag = 'es'
- self.assertEquals(self.entry.language_tag, 'es')
+ self.assertEqual(self.entry.language_tag, 'es')
class EmailRefactoringTool: Refactored ./tests/gdata_tests/apps/data_test.py
SettingsGeneralTest(unittest.TestCase):
@@ -218,23 +218,23 @@
def testPageSize(self):
self.entry.page_size = 25
- self.assertEquals(self.entry.page_size, 25)
+ self.assertEqual(self.entry.page_size, 25)
def testShortcuts(self):
self.entry.shortcuts = True
- self.assertEquals(self.entry.shortcuts, True)
+ self.assertEqual(self.entry.shortcuts, True)
def testArrows(self):
self.entry.arrows = True
- self.assertEquals(self.entry.arrows, True)
+ self.assertEqual(self.entry.arrows, True)
def testSnippets(self):
self.entry.snippets = True
- self.assertEquals(self.entry.snippets, True)
+ self.assertEqual(self.entry.snippets, True)
def testUnicode(self):
self.entry.use_unicode = True
- self.assertEquals(self.entry.use_unicode, True)
+ self.assertEqual(self.entry.use_unicode, True)
def suite():
--- ./tests/gdata_tests/apps/data_test.py (original)
+++ ./tests/gdata_tests/apps/data_test.py (refactored)
@@ -36,41 +36,41 @@
gdata.apps.data.UserFeed)
def testUserEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.data.UserEntry))
- self.assertEquals(self.entry.name.given_name, 'abcd33')
- self.assertEquals(self.entry.name.family_name, 'efgh3')
- self.assertEquals(self.entry.login.user_name, 'abcd12310')
- self.assertEquals(self.entry.login.suspended, 'false')
- self.assertEquals(self.entry.login.admin, 'false')
- self.assertEquals(self.entry.quota.limit, '25600')
+ self.assertEqual(self.entry.name.given_name, 'abcd33')
+ self.assertEqual(self.entry.name.family_name, 'efgh3')
+ self.assertEqual(self.entry.login.user_name, 'abcd12310')
+ self.assertEqual(self.entry.login.suspended, 'false')
+ self.assertEqual(self.entry.login.admin, 'false')
+ self.assertEqual(self.entry.quota.limit, '25600')
def testUserFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed, gdata.apps.data.UserFeed))
- self.assert_(isinstance(self.feed.entry[0], gdata.apps.data.UserEntry))
- self.assert_(isinstance(self.feed.entry[1], gdata.apps.data.UserEntry))
- self.assertEquals(self.feed.entry[0].find_edit_link(),
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed, gdata.apps.data.UserFeed))
+ self.assertTrue(isinstance(self.feed.entry[0], gdata.apps.data.UserEntry))
+ self.assertTrue(isinstance(self.feed.entry[1], gdata.apps.data.UserEntry))
+ self.assertEqual(self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/srkapps.com/user/2.0/user8306'))
- self.assertEquals(self.feed.entry[0].name.given_name, 'FirstName8306')
- self.assertEquals(self.feed.entry[0].name.family_name, 'LastName8306')
- self.assertEquals(self.feed.entry[0].login.user_name, 'user8306')
- self.assertEquals(self.feed.entry[0].login.admin, 'false')
- self.assertEquals(self.feed.entry[0].login.suspended, 'false')
- self.assertEquals(self.feed.entry[0].login.change_password, 'false')
- self.assertEquals(self.feed.entry[0].login.ip_whitelisted, 'false')
- self.assertEquals(self.feed.entry[0].quota.limit, '25600')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].name.given_name, 'FirstName8306')
+ self.assertEqual(self.feed.entry[0].name.family_name, 'LastName8306')
+ self.assertEqual(self.feed.entry[0].login.user_name, 'user8306')
+ self.assertEqual(self.feed.entry[0].login.admin, 'false')
+ self.assertEqual(self.feed.entry[0].login.suspended, 'false')
+ self.assertEqual(self.feed.entry[0].login.change_password, 'false')
+ self.assertEqual(self.feed.entry[0].login.ip_whitelisted, 'false')
+ self.assertEqual(self.feed.entry[0].quota.limit, '25600')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/srkapps.com/user/2.0/user8307'))
- self.assertEquals(self.feed.entry[1].name.given_name, 'FirstName8307')
- self.assertEqualRefactoringTool: Refactored ./tests/gdata_tests/analytics/query_test.py
s(self.feed.entry[1].name.family_name, 'LastName8307')
- self.assertEquals(self.feed.entry[1].login.user_name, 'user8307')
- self.assertEquals(self.feed.entry[1].login.admin, 'false')
- self.assertEquals(self.feed.entry[1].login.suspended, 'false')
- self.assertEquals(self.feed.entry[1].login.change_password, 'false')
- self.assertEquals(self.feed.entry[1].login.ip_whitelisted, 'false')
- self.assertEquals(self.feed.entry[1].quota.limit, '25600')
+ self.assertEqual(self.feed.entry[1].name.given_name, 'FirstName8307')
+ self.assertEqual(self.feed.entry[1].name.family_name, 'LastName8307')
+ self.assertEqual(self.feed.entry[1].login.user_name, 'user8307')
+ self.assertEqual(self.feed.entry[1].login.admin, 'false')
+ self.assertEqual(self.feed.entry[1].login.suspended, 'false')
+ self.assertEqual(self.feed.entry[1].login.change_password, 'false')
+ self.assertEqual(self.feed.entry[1].login.ip_whitelisted, 'false')
+ self.assertEqual(self.feed.entry[1].quota.limit, '25600')
class NicknameEntryTest(unittest.TestCase):
@@ -82,31 +82,31 @@
gdata.apps.data.NicknameFeed)
def testNicknameEntryFromString(self):
- self.assert_(isinstance(self.entry,
+ self.assertTrue(isinstance(self.entry,
gdata.apps.data.NicknameEntry))
- self.assertEquals(self.entry.nickname.name, 'nehag')
- self.assertEquals(self.entry.login.user_name, 'neha')
+ self.assertEqual(self.entry.nickname.name, 'nehag')
+ self.assertEqual(self.entry.login.user_name, 'neha')
def testNicknameFeedFromString(self):
- self.assertEquals(len(self.feed.entry), 2)
- self.assert_(isinstance(self.feed,
+ self.assertEqual(len(self.feed.entry), 2)
+ self.assertTrue(isinstance(self.feed,
gdata.apps.data.NicknameFeed))
- self.assert_(isinstance(self.feed.entry[0],
+ self.assertTrue(isinstance(self.feed.entry[0],
gdata.apps.data.NicknameEntry))
- self.assert_(isinstance(self.feed.entry[1],
+ self.assertTrue(isinstance(self.feed.entry[1],
gdata.apps.data.NicknameEntry))
- self.assertEquals(
+ self.assertEqual(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/srkapps.net/'
'nickname/2.0/nehag'))
- self.assertEquals(self.feed.entry[0].nickname.name, 'nehag')
- self.assertEquals(self.feed.entry[0].login.user_name, 'neha')
- self.assertEquals(
+ self.assertEqual(self.feed.entry[0].nickname.name, 'nehag')
+ self.assertEqual(self.feed.entry[0].login.user_name, 'neha')
+ self.assertEqual(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/srkapps.net/'
'nickname/2.0/richag'))
- self.assertEquals(self.feed.entry[1].nickname.name, 'richag')
- self.assertEquals(self.feed.entry[1].login.user_name, 'richa')
+ self.assertEqual(self.feed.entry[1].nickname.name, 'richag')
+ self.assertEqual(self.feed.entry[1].login.user_name, 'richa')
def suite():
--- ./tests/gdata_tests/analytics/query_test.py (original)
+++ ./tests/gdata_tests/analytics/query_test.py (refactored)
@@ -32,33 +32,33 @@
def testAccountFeed(self):
"""Tests Account Feed queries."""
queryTest1 = client.AccountFeedQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'https://www.google.com/analytics/feeds/accounts/default')
queryTest2 = client.AccountFeedQuery({'max-results': 50})
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'https://www.google.com/analytics/feeds/accounts/default'
'?max-results=50')
queryTest3 = client.AccountFeedQuery()
queryTest3.query['max-results'] = 100
- self.assertEquals(str(queryTest3),
+ self.assertEqual(str(queryTest3),
'https://www.google.com/analytics/feeds/accounts/default'
'?max-results=100')
def testDataFeed(self):
"""Tests Data Feed queries."""
queryTest1 = client.DataFeedQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'https://www.google.com/analytics/feeds/data')
queryTest2 = client.DataFeedQuery({'ids': 'ga:1234'})
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'https://www.google.com/analytics/feeds/data?ids=ga%3A1234')
queryTest3 = client.DataFeedQuery()
queryTest3.query['ids'] = 'ga:1234'
- self.assertEquals(str(queryTest3),
+ self.assertEqual(str(queryTest3),
'https://www.google.com/analytics/feeds/data?ids=ga%3A1234')
@@ -72,40 +72,40 @@
def testAccountFeedQuery(self):
"""Tests Account Feed queries."""
queryTest1 = client.AccountQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'%s/accounts' % self.base_url)
queryTest2 = client.AccountQuery({'max-results': 50})
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'%s/accounts?max-results=50' % self.base_url)
def testWebPropertyFeedQuery(self):
"""Tests Web Property Feed queries."""
queryTest1 = client.WebPropertyQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'%s/accounts/~all/webproperties' % self.base_url)
queryTest2 = client.WebPropertyQuery('123')
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'%s/accounts/123/webproperties' % self.base_url)
queryTest3 = client.WebPropertyQuery('123', {'max-results': 100})
- self.assertEquals(str(queryTest3),
+ self.assertEqual(str(queryTest3),
'%s/accounts/123/webproperties?max-results=100' % self.base_url)
def testProfileFeedQuery(self):
"""Tests Profile Feed queries."""
queryTest1 = client.ProfileQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'%s/accounts/~all/webproperties/~all/profiles' % self.base_url)
queryTest2 = client.ProfileQuery('123', 'UA-123-1')
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'%s/accounts/123/webproperties/UA-123-1/profiles' % self.base_url)
queryTest3 = client.ProfileQuery('123', 'UA-123-1',
{'max-results': 100})
- self.assertEquals(str(queryTest3),
+ self.assertEqual(str(queryTest3),
'%s/accounts/123/webproperties/UA-123-1/profiles?max-results=100'
% self.base_url)
@@ -113,25 +113,25 @@
queryTest4.acct_id = '123'
queryTest4.web_prop_id = 'UA-123-1'
queryTest4.query['max-results'] = 100
- self.assertEquals(str(queryTest4),
+ self.assertEqual(str(queryTest4),
'%s/accounts/123/webproperties/UA-123-1/profiles?max-results=100'
% self.base_url)
def testGoalFeedQuery(self):
"""Tests Goal Feed queries."""
queryTest1 = client.GoalQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'%s/accounts/~all/webproperties/~all/profiles/~all/goals'
% self.base_url)
queryTest2 = client.GoalQuery('123', 'UA-123-1', '555')
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'%s/accounts/123/webproperties/UA-123-1/profiles/555/goals'
% self.base_url)
queryTest3 = client.GoalQuery('123', 'UA-123-1', '555',
{'max-results': 100})
- self.assertEquals(str(queryTest3),
+ self.assertEqual(str(queryTest3),
'%s/accounts/123/webproperties/UA-123-1/profiles/555/goals'
'?max-results=100' % self.base_url)
@@ -140,19 +140,19 @@
queryTest4.web_prop_id = 'UA-123-1'
queryTest4.profile_id = '555'
queryTest4.query['max-results'] = 100
- self.assertEquals(str(queryTest3),
+ self.assertEqual(str(queryTest3),
'%s/accounts/123/webproperties/UA-123-1/profiles/555/goals'
'?max-results=100' % self.base_url)
def testAdvSegQuery(self):
"""Tests Advanced Segment Feed queries."""
queryTest1 = client.AdvSegQuery()
- self.assertEquals(str(queryTest1),
+ self.assertEqual(str(queryTest1),
'%s/segments'
% self.base_url)
RefactoringTool: Refactored ./tests/gdata_tests/analytics/live_client_test.py
RefactoringTool: Refactored ./tests/gdata_tests/analytics/data_test.py
queryTest2 = client.AdvSegQuery({'max-results': 100})
- self.assertEquals(str(queryTest2),
+ self.assertEqual(str(queryTest2),
'%s/segments?max-results=100'
% self.base_url)
--- ./tests/gdata_tests/analytics/live_client_test.py (original)
+++ ./tests/gdata_tests/analytics/live_client_test.py (refactored)
@@ -62,7 +62,7 @@
})
feed = self.client.GetAccountFeed(account_query)
- self.assert_(feed.entry is not None)
+ self.assertTrue(feed.entry is not None)
properties = [
'ga:accountId',
@@ -76,7 +76,7 @@
entry = feed.entry[0]
for prop in properties:
property = entry.GetProperty(prop)
- self.assertEquals(property.name, prop)
+ self.assertEqual(property.name, prop)
def testDataFeed(self):
"""Tests if the Data Feed exists."""
@@ -98,10 +98,10 @@
})
feed = self.client.GetDataFeed(data_query)
- self.assert_(feed.entry is not None)
- self.assertEquals(feed.start_date.text, start_date)
- self.assertEquals(feed.end_date.text, end_date)
- self.assertEquals(feed.entry[0].GetMetric(metrics).name, metrics)
+ self.assertTrue(feed.entry is not None)
+ self.assertEqual(feed.start_date.text, start_date)
+ self.assertEqual(feed.end_date.text, end_date)
+ self.assertEqual(feed.entry[0].GetMetric(metrics).name, metrics)
def testManagementFeed(self):
"""Tests of the Management Feed exists."""
@@ -113,7 +113,7 @@
account_query = gdata.analytics.client.AccountQuery()
feed = self.client.GetManagementFeed(account_query)
- self.assert_(feed.entry is not None)
+ self.assertTrue(feed.entry is not None)
def tearDown(self):
"""Closes client connection."""
--- ./tests/gdata_tests/analytics/data_test.py (original)
+++ ./tests/gdata_tests/analytics/data_test.py (refactored)
@@ -49,95 +49,95 @@
"""Tests Segment class in Google Analytics Account Feed."""
segment = self.feed.segment[0]
- self.assertEquals(segment.id, 'gaid::-11')
- self.assertEquals(segment.name, 'Visits from iPhones')
+ self.assertEqual(segment.id, 'gaid::-11')
+ self.assertEqual(segment.name, 'Visits from iPhones')
def testSegmentDefinition(self):
"""Tests Definition class in Google Analytics Account Feed."""
definition = self.feed.segment[0].definition
- self.assertEquals(definition.text, 'ga:operatingSystem==iPhone')
+ self.assertEqual(definition.text, 'ga:operatingSystem==iPhone')
def testEntryTableId(self):
"""Tests custom classes in Google Analytics Account Feed."""
entry = self.feed.entry[0]
- self.assertEquals(entry.table_id.text, 'ga:1174')
+ self.assertEqual(entry.table_id.text, 'ga:1174')
def testEntryProperty(self):
"""Tests the property classes in Google Analytics Account Feed."""
property = self.feed.entry[0].property
- self.assertEquals(property[0].name, 'ga:accountId')
- self.assertEquals(property[0].value, '30481')
-
- self.assertEquals(property[1].name, 'ga:accountName')
- self.assertEquals(property[1].value, 'Google Store')
-
- self.assertEquals(property[2].name, 'ga:profileId')
- self.assertEquals(property[2].value, '1174')
-
- self.assertEquals(property[3].name, 'ga:webPropertyId')
- self.assertEquals(property[3].value, 'UA-30481-1')
-
- self.assertEquals(property[4].name, 'ga:currency')
- self.assertEquals(property[4].value, 'USD')
-
- self.assertEquals(property[5].name, 'ga:timezone')
- self.assertEquals(property[5].value, 'America/Los_Angeles')
+ self.assertEqual(property[0].name, 'ga:accountId')
+ self.assertEqual(property[0].value, '30481')
+
+ self.assertEqual(property[1].name, 'ga:accountName')
+ self.assertEqual(property[1].value, 'Google Store')
+
+ self.assertEqual(property[2].name, 'ga:profileId')
+ self.assertEqual(property[2].value, '1174')
+
+ self.assertEqual(property[3].name, 'ga:webPropertyId')
+ self.assertEqual(property[3].value, 'UA-30481-1')
+
+ self.assertEqual(property[4].name, 'ga:currency')
+ self.assertEqual(property[4].value, 'USD')
+
+ self.assertEqual(property[5].name, 'ga:timezone')
+ self.assertEqual(property[5].value, 'America/Los_Angeles')
def testEntryGetProperty(self):
"""Tests GetProperty inherited class in the AccountEntry class."""
entry = self.feed.entry[0]
- self.assertEquals(entry.GetProperty('ga:accountId').value, '30481')
- self.assertEquals(entry.GetProperty('ga:accountName').value, 'Google Store')
- self.assertEquals(entry.GetProperty('ga:profileId').value, '1174')
- self.assertEquals(entry.GetProperty('ga:webPropertyId').value, 'UA-30481-1')
- self.assertEquals(entry.GetProperty('ga:currency').value, 'USD')
- self.assertEquals(entry.GetProperty('ga:timezone').value, 'America/Los_Angeles')
+ self.assertEqual(entry.GetProperty('ga:accountId').value, '30481')
+ self.assertEqual(entry.GetProperty('ga:accountName').value, 'Google Store')
+ self.assertEqual(entry.GetProperty('ga:profileId').value, '1174')
+ self.assertEqual(entry.GetProperty('ga:webPropertyId').value, 'UA-30481-1')
+ self.assertEqual(entry.GetProperty('ga:currency').value, 'USD')
+ self.assertEqual(entry.GetProperty('ga:timezone').value, 'America/Los_Angeles')
def testGoal(self):
"""Tests Goal class in Google Anlaytics Account Feed."""
goal = self.feed.entry[0].goal[0]
- self.assertEquals(goal.number, '1')
- self.assertEquals(goal.name, 'Completing Order')
- self.assertEquals(goal.value, '10.0')
- self.assertEquals(goal.active, 'true')
+ self.assertEqual(goal.number, '1')
+ self.assertEqual(goal.name, 'Completing Order')
+ self.assertEqual(goal.value, '10.0')
+ self.assertEqual(goal.active, 'true')
def testDestination(self):
"""Tests Destination class in Google Analytics Account Feed."""
destination = self.feed.entry[0].goal[0].destination
- self.assertEquals(destination.expression, '/purchaseComplete.html')
- self.assertEquals(destination.case_sensitive, 'false')
- self.assertEquals(destination.match_type, 'regex')
- self.assertEquals(destination.step1_required, 'false')
+ self.assertEqual(destination.expression, '/purchaseComplete.html')
+ self.assertEqual(destination.case_sensitive, 'false')
+ self.assertEqual(destination.match_type, 'regex')
+ self.assertEqual(destination.step1_required, 'false')
def testStep(self):
"""Tests Step class in Google Analytics Account Feed."""
step = self.feed.entry[0].goal[0].destination.step[0]
- self.assertEquals(step.number, '1')
- self.assertEquals(step.name, 'View Product Categories')
- self.assertEquals(step.path, '/Apps|Accessories|Fun|Kid\+s|Office')
+ self.assertEqual(step.number, '1')
+ self.assertEqual(step.name, 'View Product Categories')
+ self.assertEqual(step.path, '/Apps|Accessories|Fun|Kid\+s|Office')
def testEngagemet(self):
"""Tests Engagement class in Google Analytics Account Feed."""
engagement = self.feed.entry[0].goal[1].engagement
- self.assertEquals(engagement.type, 'timeOnSite')
- self.assertEquals(engagement.comparison, '>')
- self.assertEquals(engagement.threshold_value, '300')
+ self.assertEqual(engagement.type, 'timeOnSite')
+ self.assertEqual(engagement.comparison, '>')
+ self.assertEqual(engagement.threshold_value, '300')
def testCustomVariable(self):
"""Tests CustomVariable class in Google Analytics Account Feed."""
customVar = self.feed.entry[0].custom_variable[0]
- self.assertEquals(customVar.index, '1')
- self.assertEquals(customVar.name, 'My Custom Variable')
- self.assertEquals(customVar.scope, '3')
+ self.assertEqual(customVar.index, '1')
+ self.assertEqual(customVar.name, 'My Custom Variable')
+ self.assertEqual(customVar.scope, '3')
class DataFeedTest(unittest.TestCase):
@@ -152,124 +152,124 @@
def testDataFeed(self):
"""Tests custom classes in Google Analytics Data Feed."""
- self.assertEquals(self.feed.start_date.text, '2008-10-01')
- self.assertEquals(self.feed.end_date.text, '2008-10-31')
+ self.assertEqual(self.feed.start_date.text, '2008-10-01')
+ self.assertEqual(self.feed.end_date.text, '2008-10-31')
def testAggregates(self):
"""Tests Aggregates class in Google Analytics Data Feed."""
- self.assert_(self.feed.aggregates is not None)
+ self.assertTrue(self.feed.aggregates is not None)
def testContainsSampledData(self):
"""Tests ContainsSampledData class in Google Analytics Data Feed."""
contains_sampled_data = self.feed.contains_sampled_data.text
- self.assertEquals(contains_sampled_data, 'true')
+ self.assertEqual(contains_sampled_data, 'true')
self.assertTrue(self.feed.HasSampledData())
def testAggregatesElements(self):
"""Tests Metrics class in Aggregates class."""
metric = self.feed.aggregates.metric[0]
- self.assertEquals(metric.confidence_interval, '0.0')
- self.assertEquals(metric.name, 'ga:visits')
- self.assertEquals(metric.type, 'integer')
- self.assertEquals(metric.value, '136540')
+ self.assertEqual(metric.confidence_interval, '0.0')
+ self.assertEqual(metric.name, 'ga:visits')
+ self.assertEqual(metric.type, 'integer')
+ self.assertEqual(metric.value, '136540')
metric = self.feed.aggregates.GetMetric('ga:visits')
- self.assertEquals(metric.confidence_interval, '0.0')
- self.assertEquals(metric.name, 'ga:visits')
- self.assertEquals(metric.type, 'integer')
- self.assertEquals(metric.value, '136540')
+ self.assertEqual(metric.confidence_interval, '0.0')
+ self.assertEqual(metric.name, 'ga:visits')
+ self.assertEqual(metric.type, 'integer')
+ self.assertEqual(metric.value, '136540')
def testDataSource(self):
"""Tests DataSources class in Google Analytics Data Feed."""
- self.assert_(self.feed.data_source[0] is not None)
+ self.assertTrue(self.feed.data_source[0] is not None)
def testDataSourceTableId(self):
"""Tests TableId class in the DataSource class."""
table_id = self.feed.data_source[0].table_id
- self.assertEquals(table_id.text, 'ga:1174')
+ self.assertEqual(table_id.text, 'ga:1174')
def testDataSourceTableName(self):
"""Tests TableName class in the DataSource class."""
table_name = self.feed.data_source[0].table_name
- self.assertEquals(table_name.text, 'www.googlestore.com')
+ self.assertEqual(table_name.text, 'www.googlestore.com')
def testDataSourceProperty(self):
"""Tests Property class in the DataSource class."""
property = self.feed.data_source[0].property
- self.assertEquals(property[0].name, 'ga:profileId')
- self.assertEquals(property[0].value, '1174')
-
- self.assertEquals(property[1].name, 'ga:webPropertyId')
- self.assertEquals(property[1].value, 'UA-30481-1')
-
- self.assertEquals(property[2].name, 'ga:accountName')
- self.assertEquals(property[2].value, 'Google Store')
+ self.assertEqual(property[0].name, 'ga:profileId')
+ self.assertEqual(property[0].value, '1174')
+
+ self.assertEqual(property[1].name, 'ga:webPropertyId')
+ self.assertEqual(property[1].value, 'UA-30481-1')
+
+ self.assertEqual(property[2].name, 'ga:accountName')
+ self.assertEqual(property[2].value, 'Google Store')
def testDataSourceGetProperty(self):
"""Tests GetProperty utility method in the DataSource class."""
ds = self.feed.data_source[0]
- self.assertEquals(ds.GetProperty('ga:profileId').value, '1174')
- self.assertEquals(ds.GetProperty('ga:webPropertyId').value, 'UA-30481-1')
- self.assertEquals(ds.GetProperty('ga:accountName').value, 'Google Store')
+ self.assertEqual(ds.GetProperty('ga:profileId').value, '1174')
+ self.assertEqual(ds.GetProperty('ga:webPropertyId').value, 'UA-30481-1')
+ self.assertEqual(ds.GetProperty('ga:accountName').value, 'Google Store')
def testSegment(self):
"""Tests Segment class in DataFeed class."""
segment = self.feed.segment
- self.assertEquals(segment.id, 'gaid::-11')
- self.assertEquals(segment.name, 'Visits from iPhones')
+ self.assertEqual(segment.id, 'gaid::-11')
+ self.assertEqual(segment.name, 'Visits from iPhones')
def testSegmentDefinition(self):
"""Tests Definition class in Segment class."""
definition = self.feed.segment.definition
- self.assertEquals(definition.text, 'ga:operatingSystem==iPhone')
+ self.assertEqual(definition.text, 'ga:operatingSystem==iPhone')
def testEntryDimension(self):
"""Tests Dimension class in Entry class."""
dim = self.feed.entry[0].dimension[0]
- self.assertEquals(dim.name, 'ga:source')
- self.assertEquals(dim.value, 'blogger.com')
+ self.assertEqual(dim.name, 'ga:source')
+ self.assertEqual(dim.value, 'blogger.com')
def testEntryGetDimension(self):
"""Tests GetDimension utility method in the Entry class."""
dim = self.feed.entry[0].GetDimension('ga:source')
- self.assertEquals(dim.name, 'ga:source')
- self.assertEquals(dim.value, 'blogger.com')
+ self.assertEqual(dim.name, 'ga:source')
+ self.assertEqual(dim.value, 'blogger.com')
error = self.feed.entry[0].GetDimension('foo')
- self.assertEquals(error, None)
+ self.assertEqual(error, None)
def testEntryMetric(self):
"""Tests Metric class in Entry class."""
met = self.feed.entry[0].metric[0]
- self.assertEquals(met.confidence_interval, '0.0')
- self.assertEquals(met.name, 'ga:visits')
- self.assertEquals(met.type, 'integer')
- self.assertEquals(met.value, '68140')
+ self.assertEqual(met.confidence_interval, '0.0')
+ self.assertEqual(met.name, 'ga:visits')
+ self.assertEqual(met.type, 'integer')
+ self.assertEqual(met.value, '68140')
def testEntryGetMetric(self):
"""Tests GetMetric utility method in the Entry class."""
met = self.feed.entry[0].GetMetric('ga:visits')
- self.assertEquals(met.confidence_interval, '0.0')
- self.assertEquals(met.name, 'ga:visits')
- self.assertEquals(met.type, 'integer')
- self.assertEquals(met.value, '68140')
+ self.assertEqual(met.confidence_interval, '0.0')
+ self.assertEqual(met.name, 'ga:visits')
+ self.assertEqual(met.type, 'integer')
+ self.assertEqual(met.value, '68140')
error = self.feed.entry[0].GetMetric('foo')
- self.assertEquals(error, None)
+ self.assertEqual(error, None)
def testEntryGetObject(self):
"""Tests GetObjectOf utility method in Entry class."""
@@ -277,17 +277,17 @@
entry = self.feed.entry[0]
dimension = entry.GetObject('ga:source')
- self.assertEquals(dimension.name, 'ga:source')
- self.assertEquals(dimension.value, 'blogger.com')
+ self.assertEqual(dimension.name, 'ga:source')
+ self.assertEqual(dimension.value, 'blogger.com')
metric = entry.GetObject('ga:visits')
- self.assertEquals(metric.name, 'ga:visits')
- self.assertEquals(metric.value, '68140')
- self.assertEquals(metric.type, 'integer')
- self.assertEquals(metric.confidence_interval, '0.0')
+ self.assertEqual(metric.name, 'ga:visits')
+ self.assertEqual(metric.value, '68140')
+ self.assertEqual(metric.type, 'integer')
+ self.assertEqual(metric.confidence_interval, '0.0')
error = entry.GetObject('foo')
- self.assertEquals(error, None)
+ self.assertEqual(error, None)
class ManagementFeedProfileTest(unittest.TestCase):
@@ -318,37 +318,37 @@
"""Tests property classes in Managment Entry class."""
property = self.feed.entry[0].property
- self.assertEquals(property[0].name, 'ga:accountId')
- self.assertEquals(property[0].value, '30481')
+ self.assertEqual(property[0].name, 'ga:accountId')
+ self.assertEqual(property[0].value, '30481')
def testEntryGetProperty(self):
"""Tests GetProperty helper method in Management Entry class."""
entry = self.feed.entry[0]
- self.assertEquals(entry.GetProperty('ga:accountId').value, '30481')
+ self.assertEqual(entry.GetProperty('ga:accountId').value, '30481')
def testGetParentLinks(self):
"""Tests GetParentLinks utility method."""
parent_links = self.feed.entry[0].GetParentLinks()
- self.assertEquals(len(parent_links), 1)
+ self.assertEqual(len(parent_links), 1)
parent_link = parent_links[0]
- self.assertEquals(parent_link.rel,
+ self.assertEqual(parent_link.rel,
'http://schemas.google.com/ga/2009#parent')
- self.assertEquals(parent_link.type,
+ self.assertEqual(parent_link.type,
'application/atom+xml')
- self.assertEquals(parent_link.href,
+ self.assertEqual(parent_link.href,
'https://www.google.com/analytics/feeds/datasources'
'/ga/accounts/30481/webproperties/UA-30481-1')
- self.assertEquals(parent_link.target_kind,
+ self.assertEqual(parent_link.target_kind,
'analytics#webproperty')
def testGetChildLinks(self):
"""Tests GetChildLinks utility method."""
child_links = self.feed.entry[0].GetChildLinks()
- self.assertEquals(len(child_links), 1)
+ self.assertEqual(len(child_links), 1)
self.ChildLinkTestHelper(child_links[0])
@@ -359,19 +359,19 @@
self.ChildLinkTestHelper(child_link)
child_link = self.feed.entry[0].GetChildLink('foo_bar')
- self.assertEquals(child_link, None)
+ self.assertEqual(child_link, None)
def ChildLinkTestHelper(self, child_link):
"""Common method to test a child link."""
- self.assertEquals(child_link.rel,
+ self.assertEqual(child_link.rel,
'http://schemas.google.com/ga/2009#child')
- self.assertEquals(child_link.type,
+ self.assertEqual(child_link.type,
'application/atom+xml')
- self.assertEquals(child_link.href,
+ self.assertEqual(child_link.href,
'https://www.google.com/analytics/feeds/datasources'
'/ga/accounts/30481/webproperties/UA-30481-1/profiles/1174/goals')
- self.assertEquals(child_link.target_kind,
+ self.assertEqual(child_link.target_kind,
'analytics#goals')
@@ -388,35 +388,35 @@
"""Tests Goal class in Google Anlaytics Account Feed."""
goal = self.feed.entry[0].goal
- self.assertEquals(goal.number, '1')
- self.assertEquals(goal.name, 'Completing Order')
- self.assertEquals(goal.value, '10.0')
- self.assertEquals(goal.active, 'true')
+ self.assertEqual(goal.number, '1')
+ self.assertEqual(goal.name, 'Completing Order')
+ self.assertEqual(goal.value, '10.0')
+ self.assertEqual(goal.active, 'true')
def testGoalDestination(self):
"""Tests Destination class in Google Analytics Account Feed."""
destination = self.feed.entry[0].goal.destination
- self.assertEquals(destination.expression, '/purchaseComplete.html')
- self.assertEquals(destination.case_sensitive, 'false')
- self.assertEquals(destination.match_type, 'regex')
- self.assertEquals(destination.step1_required, 'false')
+ self.assertEqual(destination.expression, '/purchaseComplete.html')
+ self.assertEqual(destination.case_sensitive, 'false')
+ self.assertEqual(destination.match_type, 'regex')
+ self.assertEqual(destination.step1_required, 'false')
def testGoalDestinationStep(self):
"""Tests Step class in Google Analytics Account Feed."""
step = self.feed.entry[0].goal.destination.step[0]
- self.assertEquals(step.number, '1')
- self.assertEquals(step.name, 'View Product Categories')
- self.assertEquals(step.path, '/Apps|Accessories')
+ self.assertEqual(step.number, '1')
+ self.assertEqual(step.name, 'View Product Categories')
+ self.assertEqual(step.path, '/Apps|Accessories')
def testGoalEngagemet(self):
"""Tests Engagement class in Google Analytics Account Feed."""
engagement = self.feed.entry[1].goal.engagement
- self.assertEquals(engagement.type, 'timeOnSite')
- self.assertEquals(engagement.comparison, '>')
- self.assertEquals(engagement.threshold_value, '300')
+ self.assertEqual(engagement.type, 'timeOnSite')
+ self.assertEqual(engagement.comparison, '>')
+ self.assertEqual(engagement.threshold_value, '300')
class ManagementFeedAdvSegTest(unittest.TestCase):
@@ -432,14 +432,14 @@
"""Tests Segment class in ManagementEntry class."""
segment = self.feed.entry[0].segment
- self.assertEquals(segment.id, 'gaid::0'RefactoringTool: Refactored ./tests/gdata_test.py
)
- self.assertEquals(segment.name, 'Sources Form Google')
+ self.assertEqual(segment.id, 'gaid::0')
+ self.assertEqual(segment.name, 'Sources Form Google')
def testSegmentDefinition(self):
"""Tests Definition class in Segment class."""
definition = self.feed.entry[0].segment.definition
- self.assertEquals(definition.text, 'ga:source=~^\Qgoogle\E')
+ self.assertEqual(definition.text, 'ga:source=~^\Qgoogle\E')
def suite():
--- ./tests/gdata_test.py (original)
+++ ./tests/gdata_test.py (refactored)
@@ -36,9 +36,9 @@
def testToAndFromString(self):
self.start_index.text = '1'
- self.assert_(self.start_index.text == '1')
+ self.assertTrue(self.start_index.text == '1')
new_start_index = gdata.StartIndexFromString(self.start_index.ToString())
- self.assert_(self.start_index.text == new_start_index.text)
+ self.assertTrue(self.start_index.text == new_start_index.text)
class ItemsPerPageTest(unittest.TestCase):
@@ -48,10 +48,10 @@
def testToAndFromString(self):
self.items_per_page.text = '10'
- self.assert_(self.items_per_page.text == '10')
+ self.assertTrue(self.items_per_page.text == '10')
new_items_per_page = gdata.ItemsPerPageFromString(
self.items_per_page.ToString())
- self.assert_(self.items_per_page.text == new_items_per_page.text)
+ self.assertTrue(self.items_per_page.text == new_items_per_page.text)
class GDataEntryTest(unittest.TestCase):
@@ -59,16 +59,16 @@
def testIdShouldBeCleaned(self):
entry = gdata.GDataEntryFromString(test_data.XML_ENTRY_1)
element_tree = ElementTree.fromstring(test_data.XML_ENTRY_1)
- self.assert_(element_tree.findall(
+ self.assertTrue(element_tree.findall(
'{http://www.w3.org/2005/Atom}id')[0].text != entry.id.text)
- self.assert_(entry.id.text == 'http://www.google.com/test/id/url')
+ self.assertTrue(entry.id.text == 'http://www.google.com/test/id/url')
def testGeneratorShouldBeCleaned(self):
feed = gdata.GDataFeedFromString(test_data.GBASE_FEED)
element_tree = ElementTree.fromstring(test_data.GBASE_FEED)
- self.assert_(element_tree.findall('{http://www.w3.org/2005/Atom}generator'
+ self.assertTrue(element_tree.findall('{http://www.w3.org/2005/Atom}generator'
)[0].text != feed.generator.text)
- self.assert_(feed.generator.text == 'GoogleBase')
+ self.assertTrue(feed.generator.text == 'GoogleBase')
def testAllowsEmptyId(self):
entry = gdata.GDataEntry()
@@ -84,28 +84,28 @@
self.entry = gdata.GDataEntryFromString(test_data.XML_ENTRY_1)
def testLinkFinderGetsLicenseLink(self):
- self.assertEquals(isinstance(self.entry.GetLicenseLink(), atom.Link),
+ self.assertEqual(isinstance(self.entry.GetLicenseLink(), atom.Link),
True)
- self.assertEquals(self.entry.GetLicenseLink().href,
+ self.assertEqual(self.entry.GetLicenseLink().href,
'http://creativecommons.org/licenses/by-nc/2.5/rdf')
- self.assertEquals(self.entry.GetLicenseLink().rel, 'license')
+ self.assertEqual(self.entry.GetLicenseLink().rel, 'license')
def testLinkFinderGetsAlternateLink(self):
- self.assertEquals(isinstance(self.entry.GetAlternateLink(), atom.Link),
+ self.assertEqual(isinstance(self.entry.GetAlternateLink(), atom.Link),
True)
- self.assertEquals(self.entry.GetAlternateLink().href,
+ self.assertEqual(self.entry.GetAlternateLink().href,
'http://www.provider-host.com/123456789')
- self.assertEquals(self.entry.GetAlternateLink().rel, 'alternate')
+ self.assertEqual(self.entry.GetAlternateLink().rel, 'alternate')
class GDataFeedTest(unittest.TestCase):
def testCorrectConversionToElementTree(self):
test_feed = gdata.GDataFeedFromString(test_data.GBASE_FEED)
- self.assert_(test_feed.total_results is not None)
+ self.assertTrue(test_feed.total_results is not None)
element_tree = test_feed._ToElementTree()
feed = element_tree.find('{http://www.w3.org/2005/Atom}feed')
- self.assert_(element_tree.find(
+ self.assertTrue(element_tree.find(
'{http://a9.com/-/spec/opensearchrss/1.0/}totalResults') is not None)
def testAllowsEmptyId(self):
@@ -121,23 +121,23 @@
def testCorrectConversionFromAndToString(self):
batch_entry = gdata.BatchEntryFromString(test_data.BATCH_ENTRY)
- self.assertEquals(batch_entry.batch_id.text, 'itemB')
- self.assertEquals(batch_entry.id.text,
+ self.assertEqual(batch_entry.batch_id.text, 'itemB')
+ self.assertEqual(batch_entry.id.text,
'http://www.google.com/base/feeds/items/'
'2173859253842813008')
- self.assertEquals(batch_entry.batch_operation.type, 'insert')
- self.assertEquals(batch_entry.batch_status.code, '201')
- self.assertEquals(batch_entry.batch_status.reason, 'Created')
+ self.assertEqual(batch_entry.batch_operation.type, 'insert')
+ self.assertEqual(batch_entry.batch_status.code, '201')
+ self.assertEqual(batch_entry.batch_status.reason, 'Created')
new_entry = gdata.BatchEntryFromString(str(batch_entry))
- self.assertEquals(batch_entry.batch_id.text, new_entry.batch_id.text)
- self.assertEquals(batch_entry.id.text, new_entry.id.text)
- self.assertEquals(batch_entry.batch_operation.type,
+ self.assertEqual(batch_entry.batch_id.text, new_entry.batch_id.text)
+ self.assertEqual(batch_entry.id.text, new_entry.id.text)
+ self.assertEqual(batch_entry.batch_operation.type,
new_entry.batch_operation.type)
- self.assertEquals(batch_entry.batch_status.code,
+ self.assertEqual(batch_entry.batch_status.code,
new_entry.batch_status.code)
- self.assertEquals(batch_entry.batch_status.reason,
+ self.assertEqual(batch_entry.batch_status.reason,
new_entry.batch_status.reason)
@@ -151,44 +151,44 @@
def testConvertRequestFeed(self):
batch_feed = gdata.BatchFeedFromString(test_data.BATCH_FEED_REQUEST)
- self.assertEquals(len(batch_feed.entry), 4)
+ self.assertEqual(len(batch_feed.entry), 4)
for entry in batch_feed.entry:
- self.assert_(isinstance(entry, gdata.BatchEntry))
- self.assertEquals(batch_feed.title.text, 'My Batch Feed')
+ self.assertTrue(isinstance(entry, gdata.BatchEntry))
+ self.assertEqual(batch_feed.title.text, 'My Batch Feed')
new_feed = gdata.BatchFeedFromString(str(batch_feed))
- self.assertEquals(len(new_feed.entry), 4)
+ self.assertEqual(len(new_feed.entry), 4)
for entry in new_feed.entry:
- self.assert_(isinstance(entry, gdata.BatchEntry))
- self.assertEquals(new_feed.title.text, 'My Batch Feed')
+ self.assertTrue(isinstance(entry, gdata.BatchEntry))
+ self.assertEqual(new_feed.title.text, 'My Batch Feed')
def testConvertResultFeed(self):
batch_feed = gdata.BatchFeedFromString(test_data.BATCH_FEED_RESULT)
- self.assertEquals(len(batch_feed.entry), 4)
+ self.assertEqual(len(batch_feed.entry), 4)
for entry in batch_feed.entry:
- self.assert_(isinstance(entry, gdata.BatchEntry))
+ self.assertTrue(isinstance(entry, gdata.BatchEntry))
if entry.id.text == ('http://www.google.com/base/feeds/items/'
'2173859253842813008'):
- self.assertEquals(entry.batch_operation.type, 'insert')
- self.assertEquals(entry.batch_id.text, 'itemB')
- self.assertEquals(entry.batch_status.code, '201')
- self.assertEquals(entry.batch_status.reason, 'Created')
- self.assertEquals(batch_feed.title.text, 'My Batch')
+ self.assertEqual(entry.batch_operation.type, 'insert')
+ self.assertEqual(entry.batch_id.text, 'itemB')
+ self.assertEqual(entry.batch_status.code, '201')
+ self.assertEqual(entry.batch_status.reason, 'Created')
+ self.assertEqual(batch_feed.title.text, 'My Batch')
new_feed = gdata.BatchFeedFromString(str(batch_feed))
- self.assertEquals(len(new_feed.entry), 4)
+ self.assertEqual(len(new_feed.entry), 4)
for entry in new_feed.entry:
- self.assert_(isinstance(entry, gdata.BatchEntry))
+ self.assertTrue(isinstance(entry, gdata.BatchEntry))
if entry.id.text == ('http://www.google.com/base/feeds/items/'
'2173859253842813008'):
- self.assertEquals(entry.batch_operation.type, 'insert')
- self.assertEquals(entry.batch_id.text, 'itemB')
- self.assertEquals(entry.batch_status.code, '201')
- self.assertEquals(entry.batch_status.reason, 'Created')
- self.assertEquals(new_feed.title.text, 'My Batch')
+ self.assertEqual(entry.batch_operation.type, 'insert')
+ self.assertEqual(entry.batch_id.text, 'itemB')
+ self.assertEqual(entry.batch_status.code, '201')
+ self.assertEqual(entry.batch_status.reason, 'Created')
+ self.assertEqual(new_feed.title.text, 'My Batch')
def testAddBatchEntry(self):
try:
@@ -199,43 +199,43 @@
new_entry = self.batch_feed.AddBatchEntry(
id_url_string='http://example.com/1')
- self.assertEquals(len(self.batch_feed.entry), 1)
- self.assertEquals(self.batch_feed.entry[0].id.text,
+ self.assertEqual(len(self.batch_feed.entry), 1)
+ self.assertEqual(self.batch_feed.entry[0].id.text,
'http://example.com/1')
- self.assertEquals(self.batch_feed.entry[0].batch_id.text, '0')
- self.assertEquals(new_entry.id.text, 'http://example.com/1')
- self.assertEquals(new_entry.batch_id.text, '0')
+ self.assertEqual(self.batch_feed.entry[0].batch_id.text, '0')
+ self.assertEqual(new_entry.id.text, 'http://example.com/1')
+ self.assertEqual(new_entry.batch_id.text, '0')
to_add = gdata.BatchEntry(atom_id=atom.Id(text='originalId'))
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
batch_id_string='foo')
- self.assertEquals(new_entry.batch_id.text, 'foo')
- self.assertEquals(new_entry.id.text, 'originalId')
+ self.assertEqual(new_entry.batch_id.text, 'foo')
+ self.assertEqual(new_entry.id.text, 'originalId')
to_add = gdata.BatchEntry(atom_id=atom.Id(text='originalId'),
batch_id=gdata.BatchId(text='bar'))
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
id_url_string='newId',
batch_id_string='foo')
- self.assertEquals(new_entry.batch_id.text, 'foo')
- self.assertEquals(new_entry.id.text, 'originalId')
+ self.assertEqual(new_entry.batch_id.text, 'foo')
+ self.assertEqual(new_entry.id.text, 'originalId')
to_add = gdata.BatchEntry(atom_id=atom.Id(text='originalId'),
batch_id=gdata.BatchId(text='bar'))
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
id_url_string='newId')
- self.assertEquals(new_entry.batch_id.text, 'bar')
- self.assertEquals(new_entry.id.text, 'originalId')
+ self.assertEqual(new_entry.batch_id.text, 'bar')
+ self.assertEqual(new_entry.id.text, 'originalId')
to_add = gdata.BatchEntry(atom_id=atom.Id(text='originalId'),
batch_id=gdata.BatchId(text='bar'),
batch_operation=gdata.BatchOperation(
op_type=gdata.BATCH_INSERT))
- self.assertEquals(to_add.batch_operation.type, gdata.BATCH_INSERT)
+ self.assertEqual(to_add.batch_operation.type, gdata.BATCH_INSERT)
new_entry = self.batch_feed.AddBatchEntry(entry=to_add,
id_url_string='newId', batch_id_string='foo',
operation_string=gdata.BATCH_UPDATE)
- self.assertEquals(new_entry.batch_operation.type, gdata.BATCH_UPDATE)
+ self.assertEqual(new_entry.batch_operation.type, gdata.BATCH_UPDATE)
def testAddInsert(self):
@@ -243,16 +243,16 @@
first_entry = gdata.BatchEntry(
atom_id=atom.Id(text='http://example.com/1'), text='This is a test1')
self.batch_feed.AddInsert(first_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.BATCH_INSERT)
- self.assertEquals(self.batch_feed.entry[0].batch_id.text, '0')
+ self.assertEqual(self.batch_feed.entry[0].batch_id.text, '0')
second_entry = gdata.BatchEntry(
atom_id=atom.Id(text='http://example.com/2'), text='This is a test2')
self.batch_feed.AddInsert(second_entry, batch_id_string='foo')
- self.assertEquals(self.batch_feed.entry[1].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[1].batch_operation.type,
gdata.BATCH_INSERT)
- self.assertEquals(self.batch_feed.entry[1].batch_id.text, 'foo')
+ self.assertEqual(self.batch_feed.entry[1].batch_id.text, 'foo')
third_entry = gdata.BatchEntry(
@@ -263,44 +263,44 @@
self.batch_feed.AddInsert(third_entry)
# The batch entry should not have the original operation, it should
# have been changed to an insert.
- self.assertEquals(self.batch_feed.entry[2].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[2].batch_operation.type,
gdata.BATCH_INSERT)
- self.assertEquals(self.batch_feed.entry[2].batch_id.text, '2')
+ self.assertEqual(self.batch_feed.entry[2].batch_id.text, '2')
def testAddDelete(self):
# Try deleting an entry
delete_entry = gdata.BatchEntry(
atom_id=atom.Id(text='http://example.com/1'), text='This is a test')
self.batch_feed.AddDelete(entry=delete_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.BATCH_DELETE)
- self.assertEquals(self.batch_feed.entry[0].id.text,
+ self.assertEqual(self.batch_feed.entry[0].id.text,
'http://example.com/1')
- self.assertEquals(self.batch_feed.entry[0].text, 'This is a test')
+ self.assertEqual(self.batch_feed.entry[0].text, 'This is a test')
# Try deleting a URL
self.batch_feed.AddDelete(url_string='http://example.com/2')
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.BATCH_DELETE)
- self.assertEquals(self.batch_feed.entry[1].id.text,
+ self.assertEqual(self.batch_feed.entry[1].id.text,
'http://example.com/2')
- self.assert_(self.batch_feed.entry[1].text is None)
+ self.assertTrue(self.batch_feed.entry[1].text is None)
def testAddQuery(self):
# Try querying with an existing batch entry
delete_entry = gdata.BatchEntry(
atom_id=atom.Id(text='http://example.com/1'))
self.batch_feed.AddQuery(entry=delete_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.BATCH_QUERY)
- self.assertEquals(self.batch_feed.entry[0].id.text,
+ self.assertEqual(self.batch_feed.entry[0].id.text,
'http://example.com/1')
# Try querying a URL
self.batch_feed.AddQuery(url_string='http://example.com/2')
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.BATCH_QUERY)
- self.assertEquals(self.batch_feed.entry[1].id.text,
+ self.assertEqual(self.batch_feed.entry[1].id.text,
'http://example.com/2')
def testAddUpdate(self):
@@ -308,11 +308,11 @@
delete_entry = gdata.BatchEntry(
atom_id=atom.Id(text='http://example.com/1'), text='This is a test')
self.batch_feed.AddUpdate(entry=delete_entry)
- self.assertEquals(self.batch_feed.entry[0].batch_operation.type,
+ self.assertEqual(self.batch_feed.entry[0].batch_operation.type,
gdata.BATCH_UPDATE)
- self.assertEquals(self.batch_feed.entry[0].id.text,
+ self.assertEquaRefactoringTool: Refactored ./tests/coverage.py
l(self.batch_feed.entry[0].id.text,
'http://example.com/1')
- self.assertEquals(self.batch_feed.entry[0].text, 'This is a test')
+ self.assertEqual(self.batch_feed.entry[0].text, 'This is a test')
class ExtendedPropertyTest(unittest.TestCase):
@@ -321,28 +321,28 @@
ep = gdata.ExtendedProperty(name='blobby')
ep.SetXmlBlob('')
extension = ep.GetXmlBlobExtensionElement()
- self.assertEquals(extension.tag, 'some_xml')
- self.assert_(extension.namespace is None)
- self.assertEquals(extension.attributes['attr'], 'test')
+ self.assertEqual(extension.tag, 'some_xml')
+ self.assertTrue(extension.namespace is None)
+ self.assertEqual(extension.attributes['attr'], 'test')
ep2 = gdata.ExtendedPropertyFromString(ep.ToString())
extension = ep2.GetXmlBlobExtensionElement()
- self.assertEquals(extension.tag, 'some_xml')
- self.assert_(extension.namespace is None)
- self.assertEquals(extension.attributes['attr'], 'test')
+ self.assertEqual(extension.tag, 'some_xml')
+ self.assertTrue(extension.namespace is None)
+ self.assertEqual(extension.attributes['attr'], 'test')
def testGettersShouldReturnNoneWithNoBlob(self):
ep = gdata.ExtendedProperty(name='no blob')
- self.assert_(ep.GetXmlBlobExtensionElement() is None)
- self.assert_(ep.GetXmlBlobString() is None)
+ self.assertTrue(ep.GetXmlBlobExtensionElement() is None)
+ self.assertTrue(ep.GetXmlBlobString() is None)
def testGettersReturnCorrectTypes(self):
ep = gdata.ExtendedProperty(name='has blob')
ep.SetXmlBlob('')
- self.assert_(isinstance(ep.GetXmlBlobExtensionElement(),
+ self.assertTrue(isinstance(ep.GetXmlBlobExtensionElement(),
atom.ExtensionElement))
- self.assert_(isinstance(ep.GetXmlBlobString(), str))
+ self.assertTrue(isinstance(ep.GetXmlBlobString(), str))
class FeedLinkTest(unittest.TestCase):
@@ -350,7 +350,7 @@
def testCorrectFromStringType(self):
link = gdata.FeedLinkFromString(
'')
- self.assert_(isinstance(link, gdata.FeedLink))
+ self.assertTrue(isinstance(link, gdata.FeedLink))
self.assertEqual(link.count_hint, '5')
--- ./tests/coverage.py (original)
+++ ./tests/coverage.py (refactored)
@@ -46,6 +46,7 @@
import re
import string
import sys
+import atexit
import types
@@ -110,16 +111,16 @@
def __init__(self):
global the_coverage
if the_coverage:
- raise self.error, "Only one coverage object allowed."
+ raise self.error("Only one coverage object allowed.")
self.cache = os.environ.get(self.cache_env, self.cache_default)
self.restore()
self.analysis_cache = {}
def help(self, error=None):
if error:
- print error
- print
- print __doc__
+ print(error)
+ print()
+ print(__doc__)
sys.exit(1)
def command_line(self):
@@ -135,14 +136,14 @@
'-r': 'report',
'-x': 'execute',
}
- short_opts = string.join(map(lambda o: o[1:], optmap.keys()), '')
- long_opts = optmap.values()
+ short_opts = string.join([o[1:] for o in list(optmap.keys())], '')
+ long_opts = list(optmap.values())
options, args = getopt.getopt(sys.argv[1:], short_opts,
long_opts)
for o, a in options:
- if optmap.has_key(o):
+ if o in optmap:
settings[optmap[o]] = 1
- elif optmap.has_key(o + ':'):
+ elif o + ':' in optmap:
settings[optmap[o + ':']] = a
elif o[2:] in long_opts:
settings[o[2:]] = 1
@@ -179,9 +180,9 @@
# script, change sys.path so that it matches what the script
# would have found if it had been run normally.
sys.path[0] = os.path.dirname(sys.argv[0])
- execfile(sys.argv[0], __main__.__dict__)
+ exec(compile(open(sys.argv[0], "rb").read(), sys.argv[0], 'exec'), __main__.__dict__)
if not args:
- args = self.cexecuted.keys()
+ args = list(self.cexecuted.keys())
ignore_errors = settings.get('ignore-errors')
show_missing = settings.get('show-missing')
directory = settings.get('directory=')
@@ -227,7 +228,7 @@
import marshal
cexecuted = marshal.load(cache)
cache.close()
- if isinstance(cexecuted, types.DictType):
+ if isinstance(cexecuted, dict):
self.cexecuted = cexecuted
except:
pass
@@ -237,7 +238,7 @@
# normalized case). See [GDR 2001-12-04b, 3.3].
def canonical_filename(self, filename):
- if not self.canonical_filename_cache.has_key(filename):
+ if filename not in self.canonical_filename_cache:
f = filename
if os.path.isabs(f) and not os.path.exists(f):
f = os.path.basename(f)
@@ -257,9 +258,9 @@
def canonicalize_filenames(self):
global c
- for filename, lineno in c.keys():
+ for filename, lineno in list(c.keys()):
f = self.canonical_filename(filename)
- if not self.cexecuted.has_key(f):
+ if f not in self.cexecuted:
self.cexecuted[f] = {}
self.cexecuted[f][lineno] = 1
c = {}
@@ -269,7 +270,7 @@
def morf_filename(self, morf):
if isinstance(morf, types.ModuleType):
if not hasattr(morf, '__file__'):
- raise self.error, "Module has no __file__ attribute."
+ raise self.error("Module has no __file__ attribute.")
file = morf.__file__
else:
file = morf
@@ -282,24 +283,24 @@
# in the source code.
def analyze_morf(self, morf):
- if self.analysis_cache.has_key(morf):
+ if morf in self.analysis_cache:
return self.analysis_cache[morf]
filename = self.morf_filename(morf)
ext = os.path.splitext(filename)[1]
if ext == '.pyc':
if not os.path.exists(filename[0:-1]):
- raise self.error, ("No source for compiled code '%s'."
+ raise self.error("No source for compiled code '%s'."
% filename)
filename = filename[0:-1]
elif ext != '.py':
- raise self.error, "File '%s' not Python source." % filename
+ raise self.error("File '%s' not Python source." % filename)
source = open(filename, 'r')
import parser
tree = parser.suite(source.read()).totuple(1)
source.close()
statements = {}
self.find_statements(tree, statements)
- lines = statements.keys()
+ lines = list(statements.keys())
lines.sort()
result = filename, lines
self.analysis_cache[morf] = result
@@ -372,16 +373,16 @@
else:
return "%d-%d" % (start, end)
import string
- return string.join(map(stringify, pairs), ", ")
+ return string.join(list(map(stringify, pairs)), ", ")
def analysis(self, morf):
filename, statements = self.analyze_morf(morf)
self.canonicalize_filenames()
- if not self.cexecuted.has_key(filename):
+ if filename not in self.cexecuted:
self.cexecuted[filename] = {}
missing = []
for line in statements:
- if not self.cexecuted[filename].has_key(line):
+ if line not in self.cexecuted[filename]:
missing.append(line)
return (filename, statements, missing,
self.format_lines(statements, missing))
@@ -393,9 +394,9 @@
return os.path.splitext(os.path.basename(morf))[0]
def report(self, morfs, show_missing=1, ignore_errors=0):
- if not isinstance(morfs, types.ListType):
+ if not isinstance(morfs, list):
morfsRefactoringTool: Refactored ./tests/atom_tests/url_test.py
= [morfs]
- max_name = max([5,] + map(len, map(self.morf_name, morfs)))
+ max_name = max([5,] + list(map(len, list(map(self.morf_name, morfs)))))
fmt_name = "%%- %ds " % max_name
fmt_err = fmt_name + "%s: %s"
header = fmt_name % "Name" + " Stmts Exec Cover"
@@ -403,8 +404,8 @@
if show_missing:
header = header + " Missing"
fmt_coverage = fmt_coverage + " %s"
- print header
- print "-" * len(header)
+ print(header)
+ print("-" * len(header))
total_statements = 0
total_executed = 0
for morf in morfs:
@@ -420,7 +421,7 @@
args = (name, n, m, pc)
if show_missing:
args = args + (readable,)
- print fmt_coverage % args
+ print(fmt_coverage % args)
total_statements = total_statements + n
total_executed = total_executed + m
except KeyboardInterrupt:
@@ -428,9 +429,9 @@
except:
if not ignore_errors:
type, msg = sys.exc_info()[0:2]
- print fmt_err % (name, type, msg)
+ print(fmt_err % (name, type, msg))
if len(morfs) > 1:
- print "-" * len(header)
+ print("-" * len(header))
if total_statements > 0:
pc = 100.0 * total_executed / total_statements
else:
@@ -438,7 +439,7 @@
args = ("TOTAL", total_statements, total_executed, pc)
if show_missing:
args = args + ("",)
- print fmt_coverage % args
+ print(fmt_coverage % args)
# annotate(morfs, ignore_errors).
@@ -503,11 +504,11 @@
the_coverage = coverage()
# Module functions call methods in the singleton object.
-def start(*args, **kw): return apply(the_coverage.start, args, kw)
-def stop(*args, **kw): return apply(the_coverage.stop, args, kw)
-def erase(*args, **kw): return apply(the_coverage.erase, args, kw)
-def analysis(*args, **kw): return apply(the_coverage.analysis, args, kw)
-def report(*args, **kw): return apply(the_coverage.report, args, kw)
+def start(*args, **kw): return the_coverage.start(*args, **kw)
+def stop(*args, **kw): return the_coverage.stop(*args, **kw)
+def erase(*args, **kw): return the_coverage.erase(*args, **kw)
+def analysis(*args, **kw): return the_coverage.analysis(*args, **kw)
+def report(*args, **kw): return the_coverage.report(*args, **kw)
# Save coverage data when Python exits. (The atexit module wasn't
# introduced until Python 2.0, so use sys.exitfunc when it's not
@@ -516,7 +517,7 @@
import atexit
atexit.register(the_coverage.save)
except ImportError:
- sys.exitfunc = the_coverage.save
+ atexit.register(the_coverage.save)
# Command-line interface.
if __name__ == '__main__':
--- ./tests/atom_tests/url_test.py (original)
+++ ./tests/atom_tests/url_test.py (refactored)
@@ -27,48 +27,48 @@
def testParseUrl(self):
url = atom.url.parse_url('http://www.google.com/calendar/feeds')
- self.assert_(url.protocol == 'http')
- self.assert_(url.port is None)
- self.assert_(url.host == 'www.google.com')
- self.assert_(url.path == '/calendar/feeds')
- self.assert_(url.params == {})
+ self.assertTrue(url.protocol == 'http')
+ self.assertTrue(url.port is None)
+ self.assertTrue(url.host == 'www.google.com')
+ self.assertTrue(url.path == '/calendar/feeds')
+ self.assertTrue(url.params == {})
url = atom.url.parse_url('http://example.com:6091/calendar/feeds')
- self.assert_(url.protocol == 'http')
- self.assert_(url.host == 'example.com')
- self.assert_(url.port == '6091')
- self.assert_(url.path == '/calendar/feeds')
- self.assert_(url.params == {})
+ self.assertTrue(url.protocol == 'http')
+ self.assertTrue(url.host == 'example.com')
+ self.assertTrue(url.port == '6091')
+ self.assertTrue(url.path == '/calendar/feeds')
+ self.assertTrue(url.params == {})
url = atRefactoringTool: Refactored ./tests/atom_tests/token_store_test.py
om.url.parse_url('/calendar/feeds?foo=bar')
- self.assert_(url.protocol is None)
- self.assert_(url.host is None)
- self.assert_(url.path == '/calendar/feeds')
- self.assert_(len(url.params.keys()) == 1)
- self.assert_('foo' in url.params)
- self.assert_(url.params['foo'] == 'bar')
+ self.assertTrue(url.protocol is None)
+ self.assertTrue(url.host is None)
+ self.assertTrue(url.path == '/calendar/feeds')
+ self.assertTrue(len(list(url.params.keys())) == 1)
+ self.assertTrue('foo' in url.params)
+ self.assertTrue(url.params['foo'] == 'bar')
url = atom.url.parse_url('/calendar/feeds?my+foo=bar%3Dx')
- self.assert_(len(url.params.keys()) == 1)
- self.assert_('my foo' in url.params)
- self.assert_(url.params['my foo'] == 'bar=x')
+ self.assertTrue(len(list(url.params.keys())) == 1)
+ self.assertTrue('my foo' in url.params)
+ self.assertTrue(url.params['my foo'] == 'bar=x')
def testUrlToString(self):
url = atom.url.Url(port=80)
url.host = 'example.com'
- self.assert_(str(url), '//example.com:80')
+ self.assertTrue(str(url), '//example.com:80')
url = atom.url.Url(protocol='http', host='example.com', path='/feed')
url.params['has spaces'] = 'sneaky=values?&!'
- self.assert_(url.to_string() == (
+ self.assertTrue(url.to_string() == (
'http://example.com/feed?has+spaces=sneaky%3Dvalues%3F%26%21'))
def testGetRequestUri(self):
url = atom.url.Url(protocol='http', host='example.com', path='/feed')
url.params['has spaces'] = 'sneaky=values?&!'
- self.assert_(url.get_request_uri() == (
+ self.assertTrue(url.get_request_uri() == (
'/feed?has+spaces=sneaky%3Dvalues%3F%26%21'))
- self.assert_(url.get_param_string() == (
+ self.assertTrue(url.get_param_string() == (
'has+spaces=sneaky%3Dvalues%3F%26%21'))
def testComparistons(self):
@@ -76,16 +76,16 @@
params={'x':'1', 'y':'2'})
url2 = atom.url.Url(host='example.com', port=80, path='/feed',
params={'y':'2', 'x':'1'})
- self.assertEquals(url1, url2)
+ self.assertEqual(url1, url2)
url3 = atom.url.Url(host='example.com', port=81, path='/feed',
params={'x':'1', 'y':'2'})
- self.assert_(url1 != url3)
- self.assert_(url2 != url3)
+ self.assertTrue(url1 != url3)
+ self.assertTrue(url2 != url3)
url4 = atom.url.Url(protocol='ftp', host='example.com', path='/feed',
params={'x':'1', 'y':'2'})
- self.assert_(url1 != url4)
- self.assert_(url2 != url4)
- self.assert_(url3 != url4)
+ self.assertTrue(url1 != url4)
+ self.assertTrue(url2 != url4)
+ self.assertTrue(url3 != url4)
def suite():
--- ./tests/atom_tests/token_store_test.py (original)
+++ ./tests/atom_tests/token_store_test.py (refactored)
@@ -33,23 +33,23 @@
self.tokens.add_token(self.token)
def testAddAndFindTokens(self):
- self.assert_(self.tokens.find_token('http://example.com/') == self.token)
- self.assert_(self.tokens.find_token('http://example.org/') == self.token)
- self.assert_(self.tokens.find_token('http://example.org/foo?ok=1') == (
+ self.assertTrue(self.tokens.find_token('http://example.com/') == self.token)
+ self.assertTrue(self.tokens.find_token('http://example.org/') == self.token)
+ self.assertTrue(self.tokens.find_token('http://example.org/foo?ok=1') == (
self.token))
- self.assert_(isinstance(self.tokens.find_token('http://example.net/'),
+ self.assertTrue(isinstance(self.tokens.find_token('http://example.net/'),
atom.http_interface.GenericToken))
- self.assert_(isinstance(self.tokens.find_token('example.com/'),
+ self.assertTrue(isinstance(self.tokens.find_token('example.com/'),
atom.http_interface.GenericToken))
def testFindTokenUsingMultipleUrls(self):
- self.assert_(self.tokens.find_token(
+ self.assertTrue(self.tokens.find_token(
'http://example.com/') == self.token)
- self.assert_(self.tokens.find_token(
+ sRefactoringTool: Refactored ./tests/atom_tests/service_test.py
elf.assertTrue(self.tokens.find_token(
'http://example.org/bar') == self.token)
- self.assert_(isinstance(self.tokens.find_token(''),
+ self.assertTrue(isinstance(self.tokens.find_token(''),
atom.http_interface.GenericToken))
- self.assert_(isinstance(self.tokens.find_token(
+ self.assertTrue(isinstance(self.tokens.find_token(
'http://example.net/'),
atom.http_interface.GenericToken))
@@ -59,14 +59,14 @@
atom.url.Url(host='www.example.net')])
token_store = atom.token_store.TokenStore()
token_store.add_token(token)
- self.assert_(token_store.find_token(
+ self.assertTrue(token_store.find_token(
'http://www.example.com/foobar') == token)
- self.assert_(token_store.find_token(
+ self.assertTrue(token_store.find_token(
'https://www.example.com:443/foobar') == token)
- self.assert_(token_store.find_token(
+ self.assertTrue(token_store.find_token(
'http://www.example.net/xyz') == token)
- self.assert_(token_store.find_token('http://www.example.org/') != token)
- self.assert_(isinstance(token_store.find_token('http://example.org/'),
+ self.assertTrue(token_store.find_token('http://www.example.org/') != token)
+ self.assertTrue(isinstance(token_store.find_token('http://example.org/'),
atom.http_interface.GenericToken))
--- ./tests/atom_tests/service_test.py (original)
+++ ./tests/atom_tests/service_test.py (refactored)
@@ -26,121 +26,121 @@
def testBuildUriWithNoParams(self):
x = atom.service.BuildUri('/base/feeds/snippets')
- self.assert_(x == '/base/feeds/snippets')
+ self.assertTrue(x == '/base/feeds/snippets')
def testBuildUriWithParams(self):
# Add parameters to a URI
x = atom.service.BuildUri('/base/feeds/snippets', url_params={'foo': 'bar',
'bq': 'digital camera'})
- self.assert_(x == '/base/feeds/snippets?foo=bar&bq=digital+camera')
- self.assert_(x.startswith('/base/feeds/snippets'))
- self.assert_(x.count('?') == 1)
- self.assert_(x.count('&') == 1)
- self.assert_(x.index('?') < x.index('&'))
- self.assert_(x.index('bq=digital+camera') != -1)
+ self.assertTrue(x == '/base/feeds/snippets?foo=bar&bq=digital+camera')
+ self.assertTrue(x.startswith('/base/feeds/snippets'))
+ self.assertTrue(x.count('?') == 1)
+ self.assertTrue(x.count('&') == 1)
+ self.assertTrue(x.index('?') < x.index('&'))
+ self.assertTrue(x.index('bq=digital+camera') != -1)
# Add parameters to a URI that already has parameters
x = atom.service.BuildUri('/base/feeds/snippets?bq=digital+camera',
url_params={'foo': 'bar', 'max-results': '250'})
- self.assert_(x.startswith('/base/feeds/snippets?bq=digital+camera'))
- self.assert_(x.count('?') == 1)
- self.assert_(x.count('&') == 2)
- self.assert_(x.index('?') < x.index('&'))
- self.assert_(x.index('max-results=250') != -1)
- self.assert_(x.index('foo=bar') != -1)
+ self.assertTrue(x.startswith('/base/feeds/snippets?bq=digital+camera'))
+ self.assertTrue(x.count('?') == 1)
+ self.assertTrue(x.count('&') == 2)
+ self.assertTrue(x.index('?') < x.index('&'))
+ self.assertTrue(x.index('max-results=250') != -1)
+ self.assertTrue(x.index('foo=bar') != -1)
def testBuildUriWithoutParameterEscaping(self):
x = atom.service.BuildUri('/base/feeds/snippets',
url_params={'foo': ' bar', 'bq': 'digital camera'},
escape_params=False)
- self.assert_(x.index('foo= bar') != -1)
- self.assert_(x.index('bq=digital camera') != -1)
+ self.assertTrue(x.index('foo= bar') != -1)
+ self.assertTrue(x.index('bq=digital camera') != -1)
def testParseHttpUrl(self):
atom_service = atom.service.AtomService('code.google.com')
- self.assertEquals(atom_service.server, 'code.google.com')
+ self.assertEqual(atom_service.server, 'code.google.com')
(host, port, ssl, path) = atom.service.ProcessUrl(atom_service,
'http://www.google.com/service/subservice?name=value')
- self.assertEquals(ssl, False)
- self.assertEquals(host, 'www.google.com')
- self.assertEquals(port, 80)
- self.assertEquals(path, '/service/subservice?name=value')
+ self.assertEqual(ssl, False)
+ self.assertEqual(host, 'www.google.com')
+ self.assertEqual(port, 80)
+ self.assertEqual(path, '/service/subservice?name=value')
def testParseHttpUrlWithPort(self):
atom_service = atom.service.AtomService('code.google.com')
- self.assertEquals(atom_service.server, 'code.google.com')
+ self.assertEqual(atom_service.server, 'code.google.com')
(host, port, ssl, path) = atom.service.ProcessUrl(atom_service,
'http://www.google.com:12/service/subservice?name=value&newname=newvalue')
- self.assertEquals(ssl, False)
- self.assertEquals(host, 'www.google.com')
- self.assertEquals(port, 12)
- self.assert_(path.startswith('/service/subservice?'))
- self.assert_(path.find('name=value') >= len('/service/subservice?'))
- self.assert_(path.find('newname=newvalue') >= len('/service/subservice?'))
+ self.assertEqual(ssl, False)
+ self.assertEqual(host, 'www.google.com')
+ self.assertEqual(port, 12)
+ self.assertTrue(path.startswith('/service/subservice?'))
+ self.assertTrue(path.find('name=value') >= len('/service/subservice?'))
+ self.assertTrue(path.find('newname=newvalue') >= len('/service/subservice?'))
def testParseHttpsUrl(self):
atom_service = atom.service.AtomService('code.google.com')
- self.assertEquals(atom_service.server, 'code.google.com')
+ self.assertEqual(atom_service.server, 'code.google.com')
(host, port, ssl, path) = atom.service.ProcessUrl(atom_service,
'https://www.google.com/service/subservice?name=value&newname=newvalue')
- self.assertEquals(ssl, True)
- self.assertEquals(host, 'www.google.com')
- self.assertEquals(port, 443)
- self.assert_(path.startswith('/service/subservice?'))
- self.assert_(path.find('name=value') >= len('/service/subservice?'))
- self.assert_(path.find('newname=newvalue') >= len('/service/subservice?'))
+ self.assertEqual(ssl, True)
+ self.assertEqual(host, 'www.google.com')
+ self.assertEqual(port, 443)
+ self.assertTrue(path.startswith('/service/subservice?'))
+ self.assertTrue(path.find('name=value') >= len('/service/subservice?'))
+ self.assertTrue(path.find('newname=newvalue') >= len('/service/subservice?'))
def testParseHttpsUrlWithPort(self):
atom_service = atom.service.AtomService('code.google.com')
- self.assertEquals(atom_service.server, 'code.google.com')
+ self.assertEqual(atom_service.server, 'code.google.com')
(host, port, ssl, path) = atom.service.ProcessUrl(atom_service,
'https://www.google.com:13981/service/subservice?name=value&newname=newvalue')
- self.assertEquals(ssl, True)
- self.assertEquals(host, 'www.google.com')
- self.assertEquals(port, 13981)
- self.assert_(path.startswith('/service/subservice?'))
- self.assert_(path.find('name=value') >= len('/service/subservice?'))
- self.assert_(path.find('newname=newvalue') >= len('/service/subservice?'))
+ self.assertEqual(ssl, True)
+ self.assertEqual(host, 'www.google.com')
+ self.assertEqual(port, 13981)
+ self.assertTrue(path.startswith('/service/subservice?'))
+ self.assertTrue(path.find('name=value') >= len('/service/subservice?'))
+ self.assertTrue(path.find('newname=newvalue') >= len('/service/subservice?'))
def testSetBasicAuth(self):
client = atom.service.AtomService()
client.UseBasicAuth('foo', 'bar')
token = client.token_store.find_token('http://')
- self.assert_(isinstance(token, atom.service.BasicAuthToken))
- self.assertEquals(token.auth_header, 'Basic Zm9vOmJhcg==')
+ self.assertTrue(isinstance(token, atom.service.BasicAuthToken))
+ self.assertEqual(token.auth_header, 'Basic Zm9vOmJhcg==')
client.UseBasicAuth('','')
token = client.token_store.find_token('http://')
- self.assert_(isinstance(toRefactoringTool: Refactored ./tests/atom_tests/mock_server_test.py
ken, atom.service.BasicAuthToken))
- self.assertEquals(token.auth_header, 'Basic Og==')
+ self.assertTrue(isinstance(token, atom.service.BasicAuthToken))
+ self.assertEqual(token.auth_header, 'Basic Og==')
def testProcessUrlWithStringForService(self):
(server, port, ssl, uri) = atom.service.ProcessUrl(
service='www.google.com', url='/base/feeds/items')
- self.assertEquals(server, 'www.google.com')
- self.assertEquals(port, 80)
- self.assertEquals(ssl, False)
- self.assert_(uri.startswith('/base/feeds/items'))
+ self.assertEqual(server, 'www.google.com')
+ self.assertEqual(port, 80)
+ self.assertEqual(ssl, False)
+ self.assertTrue(uri.startswith('/base/feeds/items'))
client = atom.service.AtomService()
client.server = 'www.google.com'
client.ssl = True
(server, port, ssl, uri) = atom.service.ProcessUrl(
service=client, url='/base/feeds/items')
- self.assertEquals(server, 'www.google.com')
- self.assertEquals(ssl, True)
- self.assert_(uri.startswith('/base/feeds/items'))
+ self.assertEqual(server, 'www.google.com')
+ self.assertEqual(ssl, True)
+ self.assertTrue(uri.startswith('/base/feeds/items'))
(server, port, ssl, uri) = atom.service.ProcessUrl(service=None,
url='https://www.google.com/base/feeds/items')
- self.assertEquals(server, 'www.google.com')
- self.assertEquals(port, 443)
- self.assertEquals(ssl, True)
- self.assert_(uri.startswith('/base/feeds/items'))
+ self.assertEqual(server, 'www.google.com')
+ self.assertEqual(port, 443)
+ self.assertEqual(ssl, True)
+ self.assertTrue(uri.startswith('/base/feeds/items'))
def testHostHeaderContainsNonDefaultPort(self):
client = atom.service.AtomService()
--- ./tests/atom_tests/mock_server_test.py (original)
+++ ./tests/atom_tests/mock_server_test.py (refactored)
@@ -45,10 +45,10 @@
'Header2':'1', 'Header3':'c'})
bad_verb = atom.mock_service.MockRequest('POST', 'http://www.google.com',
data='post data', extra_headers={'Header1':'a', 'Header2':'b'})
- self.assertEquals(self.request_thumbprint.IsMatch(matching_request), True)
- self.assertEquals(self.request_thumbprint.IsMatch(bad_url), False)
- self.assertEquals(self.request_thumbprint.IsMatch(bad_header), True)
- self.assertEquals(self.request_thumbprint.IsMatch(bad_verb), False)
+ self.assertEqual(self.request_thumbprint.IsMatch(matching_request), True)
+ self.assertEqual(self.request_thumbprint.IsMatch(bad_url), False)
+ self.assertEqual(self.request_thumbprint.IsMatch(bad_header), True)
+ self.assertEqual(self.request_thumbprint.IsMatch(bad_verb), False)
class HttpRequestTest(unittest.TestCase):
@@ -65,14 +65,14 @@
atom.mock_service.recordings.append((recorded_request, recorded_response))
# Try a couple of GET requests which should match the recorded request.
response = self.client.Get('http://example.com/', converter=str)
- self.assertEquals(response, 'Got it')
+ self.assertEqual(response, 'Got it')
self.client.server = 'example.com'
raw_response = self.client.handler.HttpRequest(self.client, 'GET', None,
'/')
- self.assertEquals(raw_response.read(), 'Got it')
- self.assertEquals(raw_response.status, 200)
- self.assertEquals(raw_response.reason, 'OK')
+ self.assertEqual(raw_response.read(), 'Got it')
+ self.assertEqual(raw_response.status, 200)
+ self.assertEqual(raw_response.reason, 'OK')
class RecordRealHttpRequestsTest(unittest.TestCase):
@@ -88,9 +88,9 @@
# Enter 'replay' mode
atom.mock_service.real_request_handler = None
mock_response = atom.mock_service.HttpRequest(client, 'GET', None, 'http://www.google.com/')
- self.assertEquals(real_response.reason, mock_response.reason)
- self.assertEquals(real_response.status, mock_response.status)
- self.assertEquals(real_response.read(), mock_response.read())
+ self.assertEqual(real_response.reason, mock_response.reason)
+ self.assertEqual(real_response.status, mock_response.sRefactoringTool: Refactored ./tests/atom_tests/mock_http_test.py
RefactoringTool: Refactored ./tests/atom_tests/mock_http_core_test.py
tatus)
+ self.assertEqual(real_response.read(), mock_response.read())
if __name__ == '__main__':
--- ./tests/atom_tests/mock_http_test.py (original)
+++ ./tests/atom_tests/mock_http_test.py (refactored)
@@ -36,9 +36,9 @@
response = self.client.request('GET', 'http://example.com/hooray')
- self.assertEquals(len(self.client.recordings), 1)
- self.assertEquals(response.status, 200)
- self.assertEquals(response.read(), 'Hooray!')
+ self.assertEqual(len(self.client.recordings), 1)
+ self.assertEqual(response.status, 200)
+ self.assertEqual(response.read(), 'Hooray!')
def testRecordResponse(self):
# Turn on pass-through record mode.
@@ -46,8 +46,8 @@
live_response = self.client.request('GET',
'https://www.blogger.com/feeds/7986894085536788407/posts/default?max-results=1')
live_response_body = live_response.read()
- self.assertEquals(live_response.status, 200)
- self.assertEquals(live_response_body.startswith('hi