def test_config_dne(self): env = base.get_env("/test/support/", "/test/support/validations/") base.set_log_level() response, status = get("config", 'monkeys', log_level="fatal", env=env) expects = {'Errors': ['No config matching monkeys. Register new resources with \'mason apply\'']} assert(response == expects) assert(status == 404)
def test_good_configs(self): env = base.get_env("/.tmp/", "/test/support/validations/") response, status = apply(from_root("/test/support/"), env=env, log_level="fatal") assert(len(response["Info"]) == 20) assert(len(response["Errors"]) == 8) assert(status == 200) response, status = get("config", env=env, log_level="fatal") assert(len(response["Configs"]) == 4)
def test_config_exists(self): env = base.get_env("/test/support/", "/test/support/validations/") response, status = get("config", '5', env=env) expects = [{'current': False, 'execution_client': [], 'id': '5', 'metastore_client': [{'name': 'test'}], 'scheduler_client': [], 'storage_client': []}] assert(response['Configs'] == expects) assert(status == 200)
def test_good_operators(self): env = base.get_env("/.tmp/", "/test/support/validations/") response, status = apply(from_root("/test/support/"), env=env, log_level="fatal") assert(len(response["Info"]) == 20) assert(len(response["Errors"]) == 8) assert(status == 200) response, status = get("operator", env=env, log_level="fatal") assert(len(response["Operators"]) == 6) operators = sorted(list(map(lambda o: o["command"], response["Operators"]))) assert(operators == ["operator1", "operator2", "operator3", "operator4", "operator5", "operator6"])
def test_namespace(self): env = base.get_env("/test/support/") response, status = get("operator", "namespace1", env=env, log_level="fatal") operators = [{'namespace': 'namespace1', 'command': 'operator1', 'description': 'Test Operator', 'parameters': {'required': ['test_param'], 'optional': []}, 'supported_configurations': [{'metastore': 'test'}]}, {'namespace': 'namespace1', 'command': 'operator2', 'description': 'Test Operator', 'parameters': {'required': ['test_param'], 'optional': []}, 'supported_configurations': [{'metastore': 'test'}]}] assert(sorted(response['Operators'], key=lambda o: o['command']) == operators) # type: ignore assert(status == 200)
def test_config_malformed(self): env = base.get_env("/test/support/", "/test/support/validations/") base.set_log_level() response, status = get("config", "0", log_level="fatal", env=env) assert(response['Errors'][0][0:18] == "Malformed resource") assert(status == 400)
def test_command_dne(self): env = base.get_env("/test/support/") response, status = get("operator", "namespace1", "bad_command", "fatal", env) expects = {'Errors' : ['No operator matching namespace1:bad_command. Register new resources with \'mason apply\'']} assert(response == expects) assert(status == 404)
def test_command_malformed(self): env = base.get_env("/test/support/") response, status = get("operator", "namespace1", "operator3", env=env) assert(response['Errors'][0][0:18] == "Malformed resource") assert(status == 400)
def test_command_exists(self): env = base.get_env("/test/support/") response, status = get("operator", "namespace1", "operator1", env=env) expects = {'Operators': [{'command': 'operator1', 'description': 'Test Operator', 'namespace': 'namespace1', 'parameters': {'optional': [], 'required': ['test_param']}, 'supported_configurations': [{'metastore': 'test'}]}]} assert(response == expects) assert(status == 200)