def test_module_invalid_schema_param(self): """ tests module with invalid schema parameters """ invalid_params = {"data": "mockdata/ex_all.yml", "schema": "hello"} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) output = results['failed'] and "File not found" in results["msg"] assert_equal(output, True)
def test_module_unsupported_params(self): """ tests module with unsupported parameters """ invalid_params = {"test": "params"} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) msg = "unsupported parameter for module" output = results['failed'] and msg in results["msg"] assert_equal(output, True)
def test_module_empty_params(self): """ tests module with no parameters """ invalid_params = {} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) msg = "missing required arguments" output = results['failed'] and msg in results["msg"] assert_equal(output, True)
def test_module_empty_file(self): """ tests module with empty file """ tf = tempfile.NamedTemporaryFile() invalid_params = {"output_file": tf.name} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) output = results['failed'] and results["msg"]["content"] == None os.remove(tf.name) assert_equal(output, True)
def test_module_dir_params(self): """ tests module with dir params """ dir_name = tempfile.mkdtemp() invalid_params = {"data": dir_name, "schema": dir_name} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) msg = "Recursive directory not supported" output = results['failed'] and msg in results["msg"] os.removedirs(dir_name) assert_equal(output, True)
def test_module_empty_file(self): """ tests module with empty file """ tf = tempfile.NamedTemporaryFile(delete=False) invalid_params = {"output_file": tf.name} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) output = results['failed'] and results["msg"]["content"] is None tf.close() os.unlink(tf.name) assert_equal(output, True)
def test_module_yaml_file(self): """ tests module with yaml file """ tf = tempfile.NamedTemporaryFile(delete=False) tf.write("testkey: testval") tf_name = tf.name tf.close() invalid_params = {"output_file": tf_name} self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) output = results['changed'] os.remove(tf_name) assert_equal(output, True)
def test_module_dir_params(self): """ tests module with dir params """ dir_name = tempfile.mkdtemp() invalid_params = { "stack_name": "testname", "state": "present", "template": dir_name } self.options["module_args"] = json.dumps(invalid_params) results = run_module(self.options) output = results[ 'failed'] and "Recursive directory not supported" in results["msg"] assert_equal(output, True) os.removedirs(dir_name)