def test_get_params_types(self): runner = RunnerType() runner_params = { 'foo': {'immutable': True, 'required': True}, 'bar': {'description': 'Some param.', 'type': 'string'} } runner.runner_parameters = runner_params orig_runner_params = copy.deepcopy(runner.runner_parameters) action = Action() action.parameters = { 'foo': {'immutable': False}, # Should not be allowed by API. 'stuff': {'description': 'Some param.', 'type': 'string', 'required': True} } orig_action_params = copy.deepcopy(action.parameters) params, rqd, opt, imm = ActionRunCommand._get_params_types(runner, action) self.assertEqual(len(list(params.keys())), 3) self.assertTrue('foo' in imm, '"foo" param should be in immutable set.') self.assertTrue('foo' not in rqd, '"foo" param should not be in required set.') self.assertTrue('foo' not in opt, '"foo" param should not be in optional set.') self.assertTrue('bar' in opt, '"bar" param should be in optional set.') self.assertTrue('bar' not in rqd, '"bar" param should not be in required set.') self.assertTrue('bar' not in imm, '"bar" param should not be in immutable set.') self.assertTrue('stuff' in rqd, '"stuff" param should be in required set.') self.assertTrue('stuff' not in opt, '"stuff" param should be in optional set.') self.assertTrue('stuff' not in imm, '"stuff" param should be in immutable set.') self.assertEqual(runner.runner_parameters, orig_runner_params, 'Runner params modified.') self.assertEqual(action.parameters, orig_action_params, 'Action params modified.')
def test_get_params_types(self): runner = RunnerType() runner_params = { "foo": { "immutable": True, "required": True }, "bar": { "description": "Some param.", "type": "string" }, } runner.runner_parameters = runner_params orig_runner_params = copy.deepcopy(runner.runner_parameters) action = Action() action.parameters = { "foo": { "immutable": False }, # Should not be allowed by API. "stuff": { "description": "Some param.", "type": "string", "required": True }, } orig_action_params = copy.deepcopy(action.parameters) params, rqd, opt, imm = ActionRunCommand._get_params_types( runner, action) self.assertEqual(len(list(params.keys())), 3) self.assertIn("foo", imm, '"foo" param should be in immutable set.') self.assertNotIn("foo", rqd, '"foo" param should not be in required set.') self.assertNotIn("foo", opt, '"foo" param should not be in optional set.') self.assertIn("bar", opt, '"bar" param should be in optional set.') self.assertNotIn("bar", rqd, '"bar" param should not be in required set.') self.assertNotIn("bar", imm, '"bar" param should not be in immutable set.') self.assertIn("stuff", rqd, '"stuff" param should be in required set.') self.assertNotIn("stuff", opt, '"stuff" param should not be in optional set.') self.assertNotIn("stuff", imm, '"stuff" param should not be in immutable set.') self.assertEqual(runner.runner_parameters, orig_runner_params, "Runner params modified.") self.assertEqual(action.parameters, orig_action_params, "Action params modified.")