From 87c3e8e09130bfa5e44f7a3ae1bf0eeb027a69c2 Mon Sep 17 00:00:00 2001 From: Siddharth Dushantha Date: Sun, 5 Feb 2023 19:05:30 +0100 Subject: [PATCH] fixed tests --- sherlock/sites.py | 3 +-- sherlock/tests/all.py | 59 +++---------------------------------------- 2 files changed, 4 insertions(+), 58 deletions(-) diff --git a/sherlock/sites.py b/sherlock/sites.py index 67b3402..9bef100 100644 --- a/sherlock/sites.py +++ b/sherlock/sites.py @@ -9,7 +9,7 @@ import secrets class SiteInformation: def __init__(self, name, url_home, url_username_format, username_claimed, - username_unclaimed, information, is_nsfw): + information, is_nsfw, username_unclaimed=secrets.token_urlsafe(10)): """Create Site Information Object. Contains information about a specific website. @@ -164,7 +164,6 @@ class SitesInformation: site_data[site_name]["urlMain"], site_data[site_name]["url"], site_data[site_name]["username_claimed"], - site_data[site_name]["username_unclaimed"], site_data[site_name], site_data[site_name].get("isNSFW",False) diff --git a/sherlock/tests/all.py b/sherlock/tests/all.py index fd16853..1ff2e19 100644 --- a/sherlock/tests/all.py +++ b/sherlock/tests/all.py @@ -4,7 +4,7 @@ This module contains various tests. """ from tests.base import SherlockBaseTest import unittest - +import secrets class SherlockDetectTests(SherlockBaseTest): def test_detect_true_via_message(self): @@ -54,7 +54,7 @@ class SherlockDetectTests(SherlockBaseTest): #Ensure that the site's detection method has not changed. self.assertEqual("message", site_data["errorType"]) - self.username_check([site_data["username_unclaimed"]], + self.username_check([secrets.token_urlsafe(10)], [site], exist_check=False ) @@ -108,66 +108,13 @@ class SherlockDetectTests(SherlockBaseTest): #Ensure that the site's detection method has not changed. self.assertEqual("status_code", site_data["errorType"]) - self.username_check([site_data["username_unclaimed"]], + self.username_check([secrets.token_urlsafe(10)], [site], exist_check=False ) return - def test_detect_true_via_response_url(self): - """Test Username Does Exist (Via Response URL). - - This test ensures that the "response URL" detection mechanism of - ensuring that a Username does exist works properly. - - Keyword Arguments: - self -- This object. - - Return Value: - Nothing. - Will trigger an assert if detection mechanism did not work as expected. - """ - - site = "VK" - site_data = self.site_data_all[site] - - #Ensure that the site's detection method has not changed. - self.assertEqual("response_url", site_data["errorType"]) - - self.username_check([site_data["username_claimed"]], - [site], - exist_check=True - ) - - return - - def test_detect_false_via_response_url(self): - """Test Username Does Not Exist (Via Response URL). - - This test ensures that the "response URL" detection mechanism of - ensuring that a Username does *not* exist works properly. - - Keyword Arguments: - self -- This object. - - Return Value: - Nothing. - Will trigger an assert if detection mechanism did not work as expected. - """ - - site = "VK" - site_data = self.site_data_all[site] - - #Ensure that the site's detection method has not changed. - self.assertEqual("response_url", site_data["errorType"]) - - self.username_check([site_data["username_unclaimed"]], - [site], - exist_check=False - ) - - return class SherlockSiteCoverageTests(SherlockBaseTest):