Skip to content

Commit

Permalink
Fixes for failing TestTokenQueries print assertions
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Apr 12, 2024
1 parent ea57afa commit e8344e9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion emission/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion emission/net/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 0 additions & 8 deletions emission/tests/netTests/TestPush.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions emission/tests/netTests/TestWebserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8344e9

Please sign in to comment.