def test__render_filenames_success(): """ Test if _render_filenames succeeds. """ path = "salt://saltines" dest = "/srv/salt/cheese" saltenv = "base" template = "jinja" file_data = "/srv/salt/biscuits" mock_jinja = lambda *args, **kwargs: {"result": True, "data": file_data} ret = (file_data, file_data) # salt.utils.files.fopen can only be mocked once with patch.dict(templates.TEMPLATE_REGISTRY, {"jinja": mock_jinja}): with patch("salt.utils.files.fopen", mock_open(read_data=file_data)): assert cp._render_filenames(path, dest, saltenv, template) == ret # saltenv=None should default to "base" when not set in config assert ( cp._render_filenames(path, dest, saltenv=None, template=template) == ret )
def test__render_filenames_success(self): ''' Test if _render_filenames succeeds. ''' path = 'salt://saltines' dest = '/srv/salt/cheese' saltenv = 'base' template = 'jinja' file_data = '/srv/salt/biscuits' mock_jinja = lambda *args, **kwargs: {'result': True, 'data': file_data} ret = (file_data, file_data) # salt.utils.fopen can only be mocked once with patch.dict(templates.TEMPLATE_REGISTRY, {'jinja': mock_jinja}): with patch('salt.utils.fopen', mock_open(read_data=file_data)): self.assertEqual(cp._render_filenames( path, dest, saltenv, template), ret)
def test__render_filenames_success(self): ''' Test if _render_filenames succeeds. ''' path = 'salt://saltines' dest = '/srv/salt/cheese' saltenv = 'base' template = 'jinja' file_data = '/srv/salt/biscuits' mock_jinja = lambda *args, **kwargs: {'result': True, 'data': file_data} ret = (file_data, file_data) # salt.utils.fopen can only be mocked once with patch.dict(templates.TEMPLATE_REGISTRY, {'jinja': mock_jinja}): with patch('salt.utils.fopen', mock_open(read_data=file_data)): self.assertEqual(cp._render_filenames( path, dest, saltenv, template), ret)