Add information about a claimed and an unclaimed username to the site information. This will allow the tests to directly source the information from the JSON data. It will also allow people who add new sites to also add test data (which will automatically get tested). Add a new test method which finds all sites of a given detect algorithm, and which also has test vectors, and runs tests against them.

At the current time, the test vectors are optional.  But, once when there is finally complete coverage, then they will be required.  Anyone who adds a site without also adding test data will trigger a failure.
pull/160/head
Christopher K. Hoadley 6 years ago
parent aa67a3d792
commit be59b91107

@ -221,7 +221,9 @@
"rank": 921,
"regexCheck": "^[a-zA-Z][a-zA-Z0-9_-]*$",
"url": "https://dribbble.com/{}",
"urlMain": "https://dribbble.com/"
"urlMain": "https://dribbble.com/",
"username_claimed": "blue",
"username_unclaimed": "noonewouldeverusethis7"
},
"EVE Online": {
"errorType": "response_url",

@ -205,11 +205,7 @@ class SherlockSiteCoverageTests(SherlockBaseTest):
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['noonewouldeverusethis7'],
["Dribbble"
],
exist_check=False
)
self.detect_type_check("message", exist_check=False)
return
@ -227,10 +223,6 @@ class SherlockSiteCoverageTests(SherlockBaseTest):
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['blue'],
["Dribbble"
],
exist_check=True
)
self.detect_type_check("message", exist_check=True)
return

@ -105,3 +105,50 @@ class SherlockBaseTest(unittest.TestCase):
self.assertEqual(result['exists'], exist_result_desired)
return
def detect_type_check(self, detect_type, exist_check=True):
"""Username Exist Check.
Keyword Arguments:
self -- This object.
detect_type -- String corresponding to detection algorithm
which is desired to be tested.
Note that only sites which have documented
usernames which exist and do not exist
will be tested.
exist_check -- Boolean which indicates if this should be
a check for Username existence,
or non-existence.
Return Value:
N/A.
Runs tests on all sites using the indicated detection algorithm
and which also has test vectors specified.
Will trigger an assert if Username does not have the expected
existence state.
"""
for site, site_data in self.site_data_all.items():
if (
(site_data["errorType"] != detect_type) or
(site_data.get("username_claimed") is None) or
(site_data.get("username_unclaimed") is None)
):
# This is either not a site we are interested in, or the
# site does not contain the required information to do
# the tests.
pass
else:
# We should run a test on this site.
# Figure out which type of user
if exist_check:
username_list = [site_data.get("username_claimed")]
else:
username_list = [site_data.get("username_unclaimed")]
self.username_check(username_list,
[site],
exist_check=exist_check
)
return

Loading…
Cancel
Save