@@ -62,6 +62,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
6262 'id' ,
6363 'port_id' ,
6464 'project_id' ,
65+ 'qos_policy_id' ,
6566 'router_id' ,
6667 'status' ,
6768 )
@@ -76,6 +77,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
7677 floating_ip .id ,
7778 floating_ip .port_id ,
7879 floating_ip .project_id ,
80+ floating_ip .qos_policy_id ,
7981 floating_ip .router_id ,
8082 floating_ip .status ,
8183 )
@@ -197,6 +199,28 @@ def test_floating_ip_create_project_domain(self):
197199 self .assertEqual (self .columns , columns )
198200 self .assertEqual (self .data , data )
199201
202+ def test_create_floating_ip_with_qos (self ):
203+ qos_policy = network_fakes .FakeNetworkQosPolicy .create_one_qos_policy ()
204+ self .network .find_qos_policy = mock .Mock (return_value = qos_policy )
205+ arglist = [
206+ '--qos-policy' , qos_policy .id ,
207+ self .floating_ip .floating_network_id ,
208+ ]
209+ verifylist = [
210+ ('network' , self .floating_ip .floating_network_id ),
211+ ('qos_policy' , qos_policy .id ),
212+ ]
213+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
214+
215+ columns , data = self .cmd .take_action (parsed_args )
216+
217+ self .network .create_ip .assert_called_once_with (** {
218+ 'floating_network_id' : self .floating_ip .floating_network_id ,
219+ 'qos_policy_id' : qos_policy .id ,
220+ })
221+ self .assertEqual (self .columns , columns )
222+ self .assertEqual (self .data , data )
223+
200224
201225class TestDeleteFloatingIPNetwork (TestFloatingIPNetwork ):
202226
@@ -538,6 +562,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
538562 'id' ,
539563 'port_id' ,
540564 'project_id' ,
565+ 'qos_policy_id' ,
541566 'router_id' ,
542567 'status' ,
543568 )
@@ -552,6 +577,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
552577 floating_ip .id ,
553578 floating_ip .port_id ,
554579 floating_ip .project_id ,
580+ floating_ip .qos_policy_id ,
555581 floating_ip .router_id ,
556582 floating_ip .status ,
557583 )
@@ -677,6 +703,76 @@ def test_fixed_ip_option(self, find_floating_ip_mock):
677703 self .network .update_ip .assert_called_once_with (
678704 self .floating_ip , ** attrs )
679705
706+ @mock .patch (
707+ "openstackclient.tests.unit.network.v2.test_floating_ip_network." +
708+ "fip._find_floating_ip"
709+ )
710+ def test_port_and_qos_policy_option (self , find_floating_ip_mock ):
711+ qos_policy = network_fakes .FakeNetworkQosPolicy .create_one_qos_policy ()
712+ self .network .find_qos_policy = mock .Mock (return_value = qos_policy )
713+ find_floating_ip_mock .side_effect = [
714+ self .floating_ip ,
715+ ]
716+ arglist = [
717+ "--qos-policy" , qos_policy .id ,
718+ '--port' , self .floating_ip .port_id ,
719+ self .floating_ip .id ,
720+ ]
721+ verifylist = [
722+ ('qos_policy' , qos_policy .id ),
723+ ('port' , self .floating_ip .port_id ),
724+ ('floating_ip' , self .floating_ip .id ),
725+ ]
726+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
727+
728+ self .cmd .take_action (parsed_args )
729+
730+ attrs = {
731+ 'qos_policy_id' : qos_policy .id ,
732+ 'port_id' : self .floating_ip .port_id ,
733+ }
734+ find_floating_ip_mock .assert_called_once_with (
735+ mock .ANY ,
736+ self .floating_ip .id ,
737+ ignore_missing = False ,
738+ )
739+ self .network .update_ip .assert_called_once_with (
740+ self .floating_ip , ** attrs )
741+
742+ @mock .patch (
743+ "openstackclient.tests.unit.network.v2.test_floating_ip_network." +
744+ "fip._find_floating_ip"
745+ )
746+ def test_port_and_no_qos_policy_option (self , find_floating_ip_mock ):
747+ find_floating_ip_mock .side_effect = [
748+ self .floating_ip ,
749+ ]
750+ arglist = [
751+ "--no-qos-policy" ,
752+ '--port' , self .floating_ip .port_id ,
753+ self .floating_ip .id ,
754+ ]
755+ verifylist = [
756+ ('no_qos_policy' , True ),
757+ ('port' , self .floating_ip .port_id ),
758+ ('floating_ip' , self .floating_ip .id ),
759+ ]
760+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
761+
762+ self .cmd .take_action (parsed_args )
763+
764+ attrs = {
765+ 'qos_policy_id' : None ,
766+ 'port_id' : self .floating_ip .port_id ,
767+ }
768+ find_floating_ip_mock .assert_called_once_with (
769+ mock .ANY ,
770+ self .floating_ip .id ,
771+ ignore_missing = False ,
772+ )
773+ self .network .update_ip .assert_called_once_with (
774+ self .floating_ip , ** attrs )
775+
680776
681777class TestUnsetFloatingIP (TestFloatingIPNetwork ):
682778
@@ -732,3 +828,36 @@ def test_floating_ip_unset_port(self, find_floating_ip_mock):
732828 self .floating_ip , ** attrs )
733829
734830 self .assertIsNone (result )
831+
832+ @mock .patch (
833+ "openstackclient.tests.unit.network.v2.test_floating_ip_network." +
834+ "fip._find_floating_ip"
835+ )
836+ def test_floating_ip_unset_qos_policy (self , find_floating_ip_mock ):
837+ find_floating_ip_mock .side_effect = [
838+ self .floating_ip ,
839+ ]
840+ arglist = [
841+ self .floating_ip .id ,
842+ "--qos-policy" ,
843+ ]
844+ verifylist = [
845+ ('floating_ip' , self .floating_ip .id ),
846+ ('qos_policy' , True ),
847+ ]
848+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
849+
850+ result = self .cmd .take_action (parsed_args )
851+
852+ attrs = {
853+ 'qos_policy_id' : None ,
854+ }
855+ find_floating_ip_mock .assert_called_once_with (
856+ mock .ANY ,
857+ self .floating_ip .id ,
858+ ignore_missing = False ,
859+ )
860+ self .network .update_ip .assert_called_once_with (
861+ self .floating_ip , ** attrs )
862+
863+ self .assertIsNone (result )
0 commit comments