From 68aa35f35f21476085e25ad2e3da51a1961948e4 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 13 Jan 2020 11:13:42 -0600 Subject: [PATCH] Add unit tests and release note for dns_publish_fixed_ip Follow-up to https://review.opendev.org/#/c/679834/ which added the options and lacked both a release note and minimal option-handling unit tests. Change-Id: Ibb2820add9b2fedaf5a8b1a77babf043f6641724 Signed-off-by: Dean Troyer --- .../tests/unit/network/v2/test_subnet.py | 38 +++++++++++++++++++ .../notes/bug-1784879-9b632174d4af853f.yaml | 8 ++++ 2 files changed, 46 insertions(+) create mode 100644 releasenotes/notes/bug-1784879-9b632174d4af853f.yaml diff --git a/openstackclient/tests/unit/network/v2/test_subnet.py b/openstackclient/tests/unit/network/v2/test_subnet.py index 9903b0423a..d34be18cb2 100644 --- a/openstackclient/tests/unit/network/v2/test_subnet.py +++ b/openstackclient/tests/unit/network/v2/test_subnet.py @@ -460,6 +460,44 @@ class TestCreateSubnet(TestSubnet): self.assertEqual(self.columns, columns) self.assertItemEqual(self.data, data) + def _test_create_with_dns(self, publish_dns=True): + arglist = [ + "--subnet-range", self._subnet.cidr, + "--network", self._subnet.network_id, + self._subnet.name, + ] + if publish_dns: + arglist += ['--dns-publish-fixed-ip'] + else: + arglist += ['--no-dns-publish-fixed-ip'] + verifylist = [ + ('name', self._subnet.name), + ('subnet_range', self._subnet.cidr), + ('network', self._subnet.network_id), + ('ip_version', self._subnet.ip_version), + ('gateway', 'auto'), + ] + verifylist.append(('dns_publish_fixed_ip', publish_dns)) + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + columns, data = (self.cmd.take_action(parsed_args)) + + self.network.create_subnet.assert_called_once_with( + cidr=self._subnet.cidr, + ip_version=self._subnet.ip_version, + name=self._subnet.name, + network_id=self._subnet.network_id, + dns_publish_fixed_ip=publish_dns, + ) + self.assertEqual(self.columns, columns) + self.assertItemEqual(self.data, data) + + def test_create_with_dns(self): + self._test_create_with_dns(publish_dns=True) + + def test_create_with_no_dns(self): + self._test_create_with_dns(publish_dns=False) + def _test_create_with_tag(self, add_tags=True): arglist = [ "--subnet-range", self._subnet.cidr, diff --git a/releasenotes/notes/bug-1784879-9b632174d4af853f.yaml b/releasenotes/notes/bug-1784879-9b632174d4af853f.yaml new file mode 100644 index 0000000000..67085731d0 --- /dev/null +++ b/releasenotes/notes/bug-1784879-9b632174d4af853f.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Add ``--dns-publish-fixed-ip`` and ``--no-dns-publish-fixed-ip`` + options to ``create subnet`` and ``set subnet`` commands to + control the publishing of fixed IPs in DNS when the + ``subnet_dns_publish_fixed_ip`` Neutron extension is enabled. + [Bug `1784879 `_]