def test_get_env(self, mock_os): """Get Linux env_variable value""" def_value = "42" test_data = {"my_test_key_1": "my_test_value_1", "fake_path": "fake_path_value", "empty_env": " "} test_results = ["my_test_value_1", "fake_path_value", def_value] # Mock os.environ mock_os.environ = test_data test_cases_keys = test_data.keys() test_cases_keys.append("SHOULD_BE_NONEXISTENT_VARIABLE_FOR_SMM_TESTING_ONLY") test_results.append(def_value) for index, key in enumerate(test_cases_keys): self.assertEqual(get_env(key, def_value), test_results[index])
def test_get_env(self, mock_os): """Get Linux env_variable value""" def_value = '42' test_data = {"my_test_key_1": "my_test_value_1", "fake_path": "fake_path_value", "empty_env": " "} test_results = ["my_test_value_1", "fake_path_value", def_value] # Mock os.environ mock_os.environ = test_data test_cases_keys = test_data.keys() test_cases_keys.append( "SHOULD_BE_NONEXISTENT_VARIABLE_FOR_SMM_TESTING_ONLY") test_results.append(def_value) for index, key in enumerate(test_cases_keys): self.assertEqual(get_env(key, def_value), test_results[index])
from smm.utils import get_env, get_abs_path # Templates tmpl_missing_key = string.Template('Missing key [$key].') DB_FILE_NAME = 'smmdbstore.json' DB_DEF_PATH = '~/.smmdbstore/' DB_FILE_NAME_BKP = '.' + DB_FILE_NAME + '.backup' GROUP_ID = '__groups__' DATA_ID = '__data__' COUNT_ID = '__count__' OWNER_ID = '__owner__' COMM_TEXT = 'text' COMM_GROUP = 'group' COMM_DESC = 'description' DB_PATH = get_env('SMMENVDBPATH', def_value=get_abs_path('~/.smmdbstore')) INIT_STATE = { DATA_ID: {}, GROUP_ID: [], COUNT_ID: 0, OWNER_ID: "anonymous" } class SmmDBCorrupted(Exception): pass class SmmDBKeyError(Exception): pass
from smm.utils import get_env, get_abs_path # Templates tmpl_missing_key = string.Template('Missing key [$key].') DB_FILE_NAME = 'smmdbstore.json' DB_DEF_PATH = '~/.smmdbstore/' DB_FILE_NAME_BKP = '.' + DB_FILE_NAME + '.backup' GROUP_ID = '__groups__' DATA_ID = '__data__' COUNT_ID = '__count__' OWNER_ID = '__owner__' COMM_TEXT = 'text' COMM_GROUP = 'group' COMM_DESC = 'description' DB_PATH = get_env('SMMENVDBPATH', def_value=get_abs_path('~/.smmdbstore')) INIT_STATE = {DATA_ID: {}, GROUP_ID: [], COUNT_ID: 0, OWNER_ID: "anonymous"} class SmmDBCorrupted(Exception): pass class SmmDBKeyError(Exception): pass class SmmDBKeyDuplicate(Exception): pass