def test_render_jinja_template_j2_environment_config(mock_environment, stack_group_config, expected_keys): filename = "vpc.j2" sceptre_user_data = {"vpc_id": "10.0.0.0/16"} template = Template(path=filename, sceptre_user_data=sceptre_user_data, stack_group_config=stack_group_config) jinja_template_dir = os.path.join( os.getcwd(), "tests/fixtures/templates" ) template._render_jinja_template( template_dir=jinja_template_dir, filename=filename, jinja_vars={"sceptre_user_data": sceptre_user_data} ) assert list(mock_environment.call_args.kwargs) == expected_keys
def test_render_jinja_template(filename, sceptre_user_data, expected): jinja_template_dir = os.path.join( os.getcwd(), "tests/fixtures/templates" ) template = Template(path=filename, sceptre_user_data=sceptre_user_data, stack_group_config={}) result = template._render_jinja_template( template_dir=jinja_template_dir, filename=filename, jinja_vars={"sceptre_user_data": sceptre_user_data} ) expected_yaml = yaml.safe_load(expected) result_yaml = yaml.safe_load(result) assert expected_yaml == result_yaml