def test_remove_security_groups_missing_sec_group(self, mock_logger_debug): with mock.patch( 'functest.utils.openstack_clean.os_utils' '.get_security_groups', return_value=[]): openstack_clean.remove_security_groups(self.client, self.update_list) mock_logger_debug.assert_any_call("Removing Security groups...") mock_logger_debug.assert_any_call("No security groups found.")
def remove_security_groups(self, mock_logger_debug): with mock.patch( 'functest.utils.openstack_clean.os_utils' '.get_security_groups', return_value=self.test_dict_list): openstack_clean.remove_security_groups(self.client, self.update_list) mock_logger_debug.assert_any_call("Removing Security groups...") mock_logger_debug.assert_any_call(" > this is a default " "security group and will NOT " "be deleted.")
def test_remove_security_groups_delete_success(self, mock_logger_debug): with mock.patch('functest.utils.openstack_clean.os_utils' '.get_security_groups', return_value=self.test_dict_list), \ mock.patch('functest.utils.openstack_clean.os_utils' '.delete_security_group', return_value=True): openstack_clean.remove_security_groups(self.client, self.remove_list) mock_logger_debug.assert_any_call("Removing Security groups...") mock_logger_debug.assert_any_call(" > Done!") mock_logger_debug.assert_any_call( test_utils.RegexMatch(" Removing \s*\S+" "..."))
def test_remove_security_groups_delete_failed(self, mock_logger_debug, mock_logger_error): with mock.patch('functest.utils.openstack_clean.os_utils' '.get_security_groups', return_value=self.test_dict_list), \ mock.patch('functest.utils.openstack_clean.os_utils' '.delete_security_group', return_value=False): openstack_clean.remove_security_groups(self.client, self.remove_list) mock_logger_debug.assert_any_call("Removing Security groups...") mock_logger_error.assert_any_call( test_utils.RegexMatch("There has been a " "problem removing " "the security group" " \s*\S+...")) mock_logger_debug.assert_any_call( test_utils.RegexMatch(" Removing \s*\S+" "..."))