diff --git a/CHANGELOG.md b/CHANGELOG.md index 954845d..e576918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.3.1] - 2024-12-02 + +### Fixed +- Fixed the `req_payload` property of `CFSLayerBase` to include properties in + the CFS request payload even when their values are `False`. For example, + include the value of `ims_require_dkms` even when it's set to `False`. + ## [2.3.0] - 2024-11-18 ### Added diff --git a/csm_api_client/service/cfs.py b/csm_api_client/service/cfs.py index 868312d..90f6b4e 100644 --- a/csm_api_client/service/cfs.py +++ b/csm_api_client/service/cfs.py @@ -277,7 +277,7 @@ def req_payload(self) -> Dict: req_payload = {**self.additional_data} for cfs_prop, attr in self.CFS_PROPS_TO_ATTRS.items(): value = getattr(self, attr, None) - if value: + if value is not None: set_val_by_path(req_payload, cfs_prop, value) return req_payload diff --git a/pyproject.toml b/pyproject.toml index 4314517..88c3178 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "csm-api-client" -version = "2.3.0" +version = "2.3.1" description = "Python client library for CSM APIs" authors = [ "Ryan Haasken ", diff --git a/tests/service/test_cfs.py b/tests/service/test_cfs.py index 1aac40c..0dccb9f 100644 --- a/tests/service/test_cfs.py +++ b/tests/service/test_cfs.py @@ -609,7 +609,7 @@ def test_req_payload(self): self.assertEqual(expected_payload, cfs_layer.req_payload) def test_payload_with_ims_require_dkms(self): - """Test req_payload property of CFSV2ConfigurationLayer with ims_require_dkms.""" + """Test req_payload property of CFSV2ConfigurationLayer with ims_require_dkms set to True.""" cfs_layer = CFSV2ConfigurationLayer( clone_url=self.clone_url, name=self.name, commit=self.commit, playbook=self.playbook, @@ -627,6 +627,25 @@ def test_payload_with_ims_require_dkms(self): } self.assertEqual(expected_payload, cfs_layer.req_payload) + def test_payload_with_ims_require_dkms_false(self): + """Test req_payload property of CFSV2ConfigurationLayer with ims_require_dkms set to False.""" + cfs_layer = CFSV2ConfigurationLayer( + clone_url=self.clone_url, name=self.name, + commit=self.commit, playbook=self.playbook, + ims_require_dkms=False, additional_data=self.additional_data + ) + expected_payload = { + 'commit': self.commit, + 'name': self.name, + 'cloneUrl': self.clone_url, + 'playbook': self.playbook, + 'specialParameters': { + 'imsRequireDkms': False, + 'future_cfs_layer_special_parameter': 'special_value' + } + } + self.assertEqual(expected_payload, cfs_layer.req_payload) + def test_from_cfs(self): """Test from_cfs class method of CFSV2ConfigurationLayer.""" cfs_layer_data = { @@ -767,7 +786,7 @@ def test_req_payload(self): self.assertEqual(expected_payload, cfs_layer.req_payload) def test_payload_with_ims_require_dkms(self): - """Test req_payload property of CFSV2ConfigurationLayer with ims_require_dkms.""" + """Test req_payload property of CFSV3ConfigurationLayer with ims_require_dkms set to True""" cfs_layer = CFSV3ConfigurationLayer( clone_url=self.clone_url, name=self.name, commit=self.commit, playbook=self.playbook, @@ -785,6 +804,25 @@ def test_payload_with_ims_require_dkms(self): } self.assertEqual(expected_payload, cfs_layer.req_payload) + def test_payload_with_ims_require_dkms_false(self): + """Test req_payload property of CFSV3ConfigurationLayer with ims_require_dkms set to False""" + cfs_layer = CFSV3ConfigurationLayer( + clone_url=self.clone_url, name=self.name, + commit=self.commit, playbook=self.playbook, + ims_require_dkms=False, additional_data=self.additional_data + ) + expected_payload = { + 'commit': self.commit, + 'name': self.name, + 'clone_url': self.clone_url, + 'playbook': self.playbook, + 'special_parameters': { + 'ims_require_dkms': False, + 'future_cfs_layer_special_parameter': 'special_value' + } + } + self.assertEqual(expected_payload, cfs_layer.req_payload) + def test_from_cfs(self): """Test from_cfs class method of CFSV3ConfigurationLayer.""" cfs_layer_data = {