From e8344e9a3433838aec72daf63ea1a277ce8dc8e2 Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Fri, 12 Apr 2024 00:59:32 -0700 Subject: [PATCH] Fixes for failing TestTokenQueries print assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_run_script_empty () and test_run_script_show() were failing - Was occurring because I had used logging.debug() instead of print() - Hence std output stream was unable to get the print(“storage not configured”) statement Some more fixes: - db.conf incorrectly read instead of webserver.conf in config.py in emisison/net/api - TestPush had an incomplete test, that was used just for testing purposes to invoke calls on importing the pni module. - TestWebserver.py changed print() statements to logging.debug() --- emission/core/config.py | 2 +- emission/net/api/config.py | 2 +- emission/tests/netTests/TestPush.py | 8 -------- emission/tests/netTests/TestWebserver.py | 12 ++++++------ 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/emission/core/config.py b/emission/core/config.py index e1c0d13c4..6612732c2 100644 --- a/emission/core/config.py +++ b/emission/core/config.py @@ -25,7 +25,7 @@ def get_config_data(): # Check if all DB environment variables are not set # if check_unset_env_vars(): # print("All DB environment variables are set to None") - logging.debug("storage not configured, falling back to sample, default configuration") + print("storage not configured, falling back to sample, default configuration") ret_val = get_config_data_from_env() return ret_val diff --git a/emission/net/api/config.py b/emission/net/api/config.py index 030bcf322..31e0e34c0 100644 --- a/emission/net/api/config.py +++ b/emission/net/api/config.py @@ -28,7 +28,7 @@ def check_unset_env_vars(): def get_config_data(): try: - config_file = open('conf/storage/db.conf') + config_file = open('conf/net/api/webserver.conf') ret_val = json.load(config_file) config_file.close() except: diff --git a/emission/tests/netTests/TestPush.py b/emission/tests/netTests/TestPush.py index 8fb1e1456..865ffa0b7 100644 --- a/emission/tests/netTests/TestPush.py +++ b/emission/tests/netTests/TestPush.py @@ -189,14 +189,6 @@ def testFcmNoMapping(self): # and there will be no entries in the token mapping database self.assertEqual(edb.get_push_token_mapping_db().count_documents({}), 0) - def testNoEnvVarSetUp(self): - self.tearDown() - import emission.net.ext_service.push.notify_interface as pni - # import emission.net.ext_service.push.config as pc - # print("Fetching push config from ENV variables by deleting existing non-sample JSON file") - # self.tearDown() - # self.assertRaises(TypeError, pc.get_config_data()) - self.setUp() if __name__ == '__main__': import emission.tests.common as etc diff --git a/emission/tests/netTests/TestWebserver.py b/emission/tests/netTests/TestWebserver.py index 588944623..2c3a634d9 100644 --- a/emission/tests/netTests/TestWebserver.py +++ b/emission/tests/netTests/TestWebserver.py @@ -35,19 +35,19 @@ def setUp(self): # Setting webserver environment variables with test values os.environ[env_var_name] = env_var_value - print("Finished setting up test webserver environment variables") - print("Current original values are = %s" % self.originalWebserverEnvVars) - print("Current modified values are = %s" % self.testModifiedEnvVars) + logging.debug("Finished setting up test webserver environment variables") + logging.debug("Current original values are = %s" % self.originalWebserverEnvVars) + logging.debug("Current modified values are = %s" % self.testModifiedEnvVars) def tearDown(self): - print("Deleting test webserver environment variables") + logging.debug("Deleting test webserver environment variables") for env_var_name, env_var_value in self.testModifiedEnvVars.items(): del os.environ[env_var_name] # Restoring original webserver environment variables for env_var_name, env_var_value in self.originalWebserverEnvVars.items(): os.environ[env_var_name] = env_var_value - print("Finished restoring original webserver environment variables") - print("Restored original values are = %s" % self.originalWebserverEnvVars) + logging.debug("Finished restoring original webserver environment variables") + logging.debug("Restored original values are = %s" % self.originalWebserverEnvVars) def test404Redirect(self): from emission.net.api.bottle import response