From 39ba095b6d9f8be395bdaf33c63ab4f691e24cbd Mon Sep 17 00:00:00 2001 From: Michael William Boldt Date: Thu, 27 Oct 2016 15:12:53 -0500 Subject: [PATCH] Default job properties to empty, not undefined. --- tile_generator/config.py | 6 ++++-- tile_generator/config_unittest.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tile_generator/config.py b/tile_generator/config.py index 78144883..ac03daad 100644 --- a/tile_generator/config.py +++ b/tile_generator/config.py @@ -55,7 +55,8 @@ # ways depending on the package type. We normalize all these so that the rest of # the code can rely on a single format # -# Normalize Jobs - Ensure that job type and template are set for every job +# Normalize Jobs - Ensure that job type, template, and properties are set for +# every job package_types = { 'app': { 'flags': [ 'is_cf', 'requires_cf_cli', 'is_app' ] }, @@ -145,7 +146,8 @@ def normalize_jobs(self): for job in release.get('jobs', []): job['type'] = job.get('type', job['name']) job['template'] = job.get('template', job['type']) - + job['properties'] = job.get('properties', {}) + def release_for_package(self, package): release_name = package['name'] if package.get('is_bosh_release', False) else self['name'] release = self.release_by_name(release_name) diff --git a/tile_generator/config_unittest.py b/tile_generator/config_unittest.py index 039faeee..b38f0896 100644 --- a/tile_generator/config_unittest.py +++ b/tile_generator/config_unittest.py @@ -324,6 +324,17 @@ def test_purge_service_broker_is_overridden(self): config.add_defaults() self.assertFalse(config['purge_service_brokers']) + def test_normalize_jobs_default_job_properties(self): + config = Config({ + 'releases': [{ + 'jobs': [{ + 'name': 'my-job' + }] + }] + }) + config.normalize_jobs() + self.assertEqual(config['releases'][0]['jobs'][0]['properties'], {}) + @mock.patch('os.path.getsize') class TestVMDiskSize(unittest.TestCase): def test_min_vm_disk_size(self, mock_getsize):