Change tests so that all sites that share a common username are executed in parallel. Just the little bit of extra processing halves the time taken for the tests (~15s verus ~34s). This will only get worse as the test coverage improves...

This commit is contained in:
Christopher K. Hoadley 2019-02-03 11:14:45 -06:00
parent 5eb06e3502
commit dea8c29351
1 changed files with 20 additions and 6 deletions

View File

@ -128,6 +128,10 @@ class SherlockBaseTest(unittest.TestCase):
existence state. existence state.
""" """
#Dictionary of sites that should be tested for having a username.
#This will allow us to test sites with a common username in parallel.
sites_by_username = {}
for site, site_data in self.site_data_all.items(): for site, site_data in self.site_data_all.items():
if ( if (
(site_data["errorType"] != detect_type) or (site_data["errorType"] != detect_type) or
@ -143,12 +147,22 @@ class SherlockBaseTest(unittest.TestCase):
# Figure out which type of user # Figure out which type of user
if exist_check: if exist_check:
username_list = [site_data.get("username_claimed")] username = site_data.get("username_claimed")
else: else:
username_list = [site_data.get("username_unclaimed")] username = site_data.get("username_unclaimed")
self.username_check(username_list,
[site], # Add this site to the list of sites corresponding to this
exist_check=exist_check # username.
) if username in sites_by_username:
sites_by_username[username].append(site)
else:
sites_by_username[username] = [site]
# Check on the username availability against all of the sites.
for username, site_list in sites_by_username.items():
self.username_check([username],
site_list,
exist_check=exist_check
)
return return