From f48a2980f5bad29aec1ccf13c2fc8ccfd517d4f3 Mon Sep 17 00:00:00 2001 From: "Christopher K. Hoadley" Date: Tue, 31 Dec 2019 15:33:48 -0600 Subject: [PATCH] Use SitesInformation() object in tests. For now, use the new SitesInformation() object to calculate the original JSON dictionary: the rest of the code will be updated in the future. --- sherlock/tests/base.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sherlock/tests/base.py b/sherlock/tests/base.py index 553d01c..a749f53 100644 --- a/sherlock/tests/base.py +++ b/sherlock/tests/base.py @@ -9,6 +9,7 @@ import unittest import sherlock from result import QueryStatus from result import QueryResult +from sites import SitesInformation import warnings @@ -29,10 +30,16 @@ class SherlockBaseTest(unittest.TestCase): #TODO: Figure out how to fix the code so this is not needed. warnings.simplefilter("ignore", ResourceWarning) - # Load the data file with all site information. - data_file_path = os.path.join(os.path.dirname(os.path.realpath(sherlock.__file__)), "resources/data.json") - with open(data_file_path, "r", encoding="utf-8") as raw: - self.site_data_all = json.load(raw) + #Create object with all information about sites we are aware of. + sites = SitesInformation() + + #Create original dictionary from SitesInformation() object. + #Eventually, the rest of the code will be updated to use the new object + #directly, but this will glue the two pieces together. + site_data_all = {} + for site in sites: + site_data_all[site.name] = site.information + self.site_data_all = site_data_all # Load excluded sites list, if any excluded_sites_path = os.path.join(os.path.dirname(os.path.realpath(sherlock.__file__)), "tests/.excluded_sites") @@ -116,7 +123,7 @@ class SherlockBaseTest(unittest.TestCase): with self.subTest(f"Checking Username '{username}' " f"{check_type_text} on Site '{site}'" ): - self.assertEqual(result['status'].status, + self.assertEqual(result['status'].status, exist_result_desired) return