Skip to content

Commit

Permalink
#141 renamed file to better reflect its purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
bugy committed Feb 14, 2019
1 parent 927a290 commit 7cc0627
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/config/config_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os

from model import script_configs
from model import script_config
from utils import os_utils, file_utils

LOGGER = logging.getLogger('config_service')
Expand All @@ -21,7 +21,7 @@ def list_configs(self, user):
def load_script(path, content):
try:
json_object = json.loads(content)
short_config = script_configs.read_short(path, json_object)
short_config = script_config.read_short(path, json_object)

if short_config is None:
return None
Expand All @@ -39,7 +39,7 @@ def create_config_model(self, name, user, parameter_values=None):
def find_and_load(path, content):
try:
json_object = json.loads(content)
short_config = script_configs.read_short(path, json_object)
short_config = script_config.read_short(path, json_object)

if short_config is None:
return None
Expand Down Expand Up @@ -95,7 +95,7 @@ def _load_script_config(self, path, content_or_json_dict, user, parameter_values
json_object = json.loads(content_or_json_dict)
else:
json_object = content_or_json_dict
config = script_configs.ConfigModel(
config = script_config.ConfigModel(
json_object,
path,
user.get_username(),
Expand Down
4 changes: 2 additions & 2 deletions src/execution/execution_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional, Dict, Callable, Any

from execution.executor import ScriptExecutor
from model import script_configs
from model import script_config
from utils import audit_utils

LOGGER = logging.getLogger('script_server.execution_service')
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_running_executions(self):

return result

def get_config(self, execution_id) -> Optional[script_configs.ConfigModel]:
def get_config(self, execution_id) -> Optional[script_config.ConfigModel]:
return self._get_for_execution_info(execution_id,
lambda i: i.config)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tests/execution_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from execution import executor
from execution.execution_service import ExecutionService
from model.script_configs import ConfigModel
from model.script_config import ConfigModel
from tests import test_utils
from tests.test_utils import mock_object, create_audit_names, _MockProcessWrapper

Expand Down
32 changes: 16 additions & 16 deletions src/tests/model_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest

from config.constants import PARAM_TYPE_MULTISELECT, FILE_TYPE_FILE, FILE_TYPE_DIR
from model import script_configs, model_helper
from model import script_config, model_helper
from model.model_helper import read_list, read_dict, normalize_incoming_values, fill_parameter_values, resolve_env_vars, \
InvalidFileException
from tests import test_utils
Expand All @@ -13,71 +13,71 @@ class TestDefaultValue(unittest.TestCase):
env_key = 'test_val'

def test_no_value(self):
default = script_configs._resolve_default(None, None, None)
default = script_config._resolve_default(None, None, None)

self.assertEqual(default, None)

def test_empty_value(self):
default = script_configs._resolve_default('', None, None)
default = script_config._resolve_default('', None, None)

self.assertEqual(default, '')

def test_text_value(self):
default = script_configs._resolve_default('text', None, None)
default = script_config._resolve_default('text', None, None)

self.assertEqual(default, 'text')

def test_unicode_value(self):
default = script_configs._resolve_default(u'text', None, None)
default = script_config._resolve_default(u'text', None, None)

self.assertEqual(default, u'text')

def test_int_value(self):
default = script_configs._resolve_default(5, None, None)
default = script_config._resolve_default(5, None, None)

self.assertEqual(default, 5)

def test_bool_value(self):
default = script_configs._resolve_default(True, None, None)
default = script_config._resolve_default(True, None, None)

self.assertEqual(default, True)

def test_env_variable(self):
os.environ[self.env_key] = 'text'

default = script_configs._resolve_default('$$test_val', None, None)
default = script_config._resolve_default('$$test_val', None, None)

self.assertEqual(default, 'text')

def test_missing_env_variable(self):
self.assertRaises(Exception, script_configs._resolve_default, '$$test_val', None, None)
self.assertRaises(Exception, script_config._resolve_default, '$$test_val', None, None)

def test_auth_username(self):
default = script_configs._resolve_default('${auth.username}', 'buggy', None)
default = script_config._resolve_default('${auth.username}', 'buggy', None)
self.assertEqual('buggy', default)

def test_auth_username_when_none(self):
default = script_configs._resolve_default('${auth.username}', None, None)
default = script_config._resolve_default('${auth.username}', None, None)
self.assertEqual('', default)

def test_auth_username_when_inside_text(self):
default = script_configs._resolve_default('__${auth.username}__', 'usx', None)
default = script_config._resolve_default('__${auth.username}__', 'usx', None)
self.assertEqual('__usx__', default)

def test_auth_audit_name(self):
default = script_configs._resolve_default('${auth.audit_name}', None, '127.0.0.1')
default = script_config._resolve_default('${auth.audit_name}', None, '127.0.0.1')
self.assertEqual('127.0.0.1', default)

def test_auth_audit_name_when_none(self):
default = script_configs._resolve_default('${auth.audit_name}', None, None)
default = script_config._resolve_default('${auth.audit_name}', None, None)
self.assertEqual('', default)

def test_auth_audit_name_when_inside_text(self):
default = script_configs._resolve_default('__${auth.audit_name}__', None, 'usx')
default = script_config._resolve_default('__${auth.audit_name}__', None, 'usx')
self.assertEqual('__usx__', default)

def test_auth_username_and_audit_name(self):
default = script_configs._resolve_default('${auth.username}:${auth.audit_name}', 'buggy', 'localhost')
default = script_config._resolve_default('${auth.username}:${auth.audit_name}', 'buggy', 'localhost')
self.assertEqual('buggy:localhost', default)

def tearDown(self):
Expand Down
2 changes: 1 addition & 1 deletion src/tests/parameter_server_file_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest

from config.constants import PARAM_TYPE_SERVER_FILE, FILE_TYPE_FILE, FILE_TYPE_DIR
from model.script_configs import WrongParameterUsageException, InvalidValueException
from model.script_config import WrongParameterUsageException, InvalidValueException
from tests import test_utils
from tests.test_utils import create_script_param_config, create_files

Expand Down
2 changes: 1 addition & 1 deletion src/tests/script_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import config.constants
from config.constants import PARAM_TYPE_SERVER_FILE, PARAM_TYPE_MULTISELECT
from model.script_configs import ConfigModel, InvalidValueException, _TemplateProperty, ParameterNotFoundException
from model.script_config import ConfigModel, InvalidValueException, _TemplateProperty, ParameterNotFoundException
from react.properties import ObservableDict, ObservableList
from tests import test_utils
from tests.test_utils import create_script_param_config, create_parameter_model, create_parameter_model_from_config, \
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import utils.file_utils as file_utils
import utils.os_utils as os_utils
from execution.process_base import ProcessWrapper
from model.script_configs import ConfigModel, ParameterModel
from model.script_config import ConfigModel, ParameterModel
from react.properties import ObservableDict
from utils import audit_utils

Expand Down
2 changes: 1 addition & 1 deletion src/web/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from model import model_helper
from model.external_model import to_short_execution_log, to_long_execution_log, parameter_to_external
from model.model_helper import is_empty
from model.script_configs import InvalidValueException, ParameterNotFoundException, WrongParameterUsageException
from model.script_config import InvalidValueException, ParameterNotFoundException, WrongParameterUsageException
from model.server_conf import ServerConfig
from utils import file_utils as file_utils
from utils import tornado_utils, audit_utils
Expand Down

0 comments on commit 7cc0627

Please sign in to comment.