def test_remove_networks_delete_failed(self, mock_logger_debug,
                                        mock_logger_error,
                                        mock_remove_ports,
                                        mock_remove_routers):
     with mock.patch('functest.utils.openstack_clean.os_utils'
                     '.get_network_list',
                     return_value=self.test_dict_list), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.delete_neutron_net', return_value=False), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_port_list', return_value=self.ports), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_router_list', return_value=self.routers):
         openstack_clean.remove_networks(self.client, self.remove_list,
                                         self.remove_list)
         mock_logger_debug.assert_any_call("Removing Neutron objects")
         mock_logger_error.assert_any_call(
             test_utils.RegexMatch("There has been a"
                                   " problem removing"
                                   " the network \s*\S+"
                                   "..."))
         mock_logger_debug.assert_any_call(
             test_utils.RegexMatch("Removing network "
                                   "\s*\S+ ..."))
         mock_remove_ports.assert_called_once_with(self.client, self.ports,
                                                   ['id1', 'id2'])
         mock_remove_routers.assert_called_once_with(
             self.client, self.routers, self.remove_list)
    def test_remove_networks_delete_success(self, mock_logger_debug,
                                            mock_remove_ports,
                                            mock_remove_routers):

        with mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_network_list',
                        return_value=self.test_dict_list), \
                mock.patch('functest.utils.openstack_clean.os_utils'
                           '.delete_neutron_net', return_value=True), \
                mock.patch('functest.utils.openstack_clean.os_utils'
                           '.get_port_list', return_value=self.ports), \
                mock.patch('functest.utils.openstack_clean.os_utils'
                           '.get_router_list', return_value=self.routers):
            openstack_clean.remove_networks(self.client, self.remove_list,
                                            self.remove_list)
            mock_logger_debug.assert_any_call("Removing Neutron objects")
            mock_logger_debug.assert_any_call("   > this network will be "
                                              "deleted.")
            mock_logger_debug.assert_any_call("  > Done!")
            mock_logger_debug.assert_any_call(
                test_utils.RegexMatch("Removing network "
                                      "\s*\S+ ..."))
            mock_remove_ports.assert_called_once_with(self.client, self.ports,
                                                      ['id1', 'id2'])
            mock_remove_routers.assert_called_once_with(
                self.client, self.routers, self.remove_list)
 def test_remove_networks_missing_networks(self, mock_logger_debug,
                                           mock_remove_ports,
                                           mock_remove_routers):
     with mock.patch('functest.utils.openstack_clean.os_utils'
                     '.get_network_list', return_value=None), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_port_list', return_value=self.ports), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_router_list', return_value=self.routers):
         openstack_clean.remove_networks(self.client, self.update_list,
                                         self.update_list)
         mock_logger_debug.assert_any_call("Removing Neutron objects")
         mock_logger_debug.assert_any_call("There are no networks in the"
                                           " deployment. ")
         mock_remove_ports.assert_called_once_with(self.client, self.ports,
                                                   [])
         mock_remove_routers.assert_called_once_with(
             self.client, self.routers, self.update_list)
 def test_remove_networks(self, mock_logger_debug, mock_remove_ports,
                          mock_remove_routers):
     with mock.patch('functest.utils.openstack_clean.os_utils'
                     '.get_network_list',
                     return_value=self.test_dict_list), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_port_list', return_value=self.ports), \
             mock.patch('functest.utils.openstack_clean.os_utils'
                        '.get_router_list', return_value=self.routers):
         openstack_clean.remove_networks(self.client, self.update_list,
                                         self.update_list)
         mock_logger_debug.assert_any_call("Removing Neutron objects")
         mock_logger_debug.assert_any_call("   > this is a default "
                                           "network and will "
                                           "NOT be deleted.")
         mock_remove_ports.assert_called_once_with(self.client, self.ports,
                                                   [])
         mock_remove_routers.assert_called_once_with(
             self.client, self.routers, self.update_list)