From 8503a8a1df2c6af0fefc7551e5890c71a8fb0ad3 Mon Sep 17 00:00:00 2001 From: Matthew Aynalem Date: Wed, 13 Mar 2019 06:36:31 -0700 Subject: [PATCH] fixes #169 post_processor/Manifest: add custom_data attribute --- src/packerlicious/post_processor.py | 1 + .../test_post_processor_manifest.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/packerlicious/post_processor.py b/src/packerlicious/post_processor.py index 613a45a..893b8a2 100644 --- a/src/packerlicious/post_processor.py +++ b/src/packerlicious/post_processor.py @@ -320,6 +320,7 @@ class Manifest(PackerPostProcessor): props = { 'output': (str, False), + 'custom_data': (dict, False), 'strip_path': (validator.boolean, False), } diff --git a/tests/packerlicious/test_post_processor_manifest.py b/tests/packerlicious/test_post_processor_manifest.py index b41152c..086567f 100644 --- a/tests/packerlicious/test_post_processor_manifest.py +++ b/tests/packerlicious/test_post_processor_manifest.py @@ -1,4 +1,6 @@ import packerlicious.post_processor as post_processor +from packerlicious.template import Template +import json class TestManifestPostProcessor(object): @@ -7,3 +9,30 @@ def test_no_required_fields(self): b = post_processor.Manifest() b.to_dict() + + def test_custom_data(self): + expected_json = """ + { + "post-processors": [ + { + "type": "manifest", + "output": "manifest.json", + "strip_path": "true", + "custom_data": { + "my_custom_data": "example" + } + } + ] + } + """ + p = post_processor.Manifest( + output="manifest.json", + strip_path=True, + custom_data={'my_custom_data': 'example'} + ) + t = Template() + t.add_post_processor(p) + + to_json = t.to_json() + assert to_json == json.dumps(json.loads(expected_json), sort_keys=True, indent=2, + separators=(',', ': '))