def test_remove_users_missing_users(self, mock_logger_debug): with mock.patch('functest.utils.openstack_clean.os_utils' '.get_users', return_value=None): openstack_clean.remove_users(self.client, self.update_list) mock_logger_debug.assert_any_call("Removing Users...") mock_logger_debug.assert_any_call("There are no users in" " the deployment. ")
def test_remove_users(self, mock_logger_debug): with mock.patch('functest.utils.openstack_clean.os_utils' '.get_users', return_value=self.test_list): openstack_clean.remove_users(self.client, self.update_list) mock_logger_debug.assert_any_call("Removing Users...") mock_logger_debug.assert_any_call(" > this is a default " "user and will " "NOT be deleted.")
def test_remove_users_delete_success(self, mock_logger_debug): with mock.patch('functest.utils.openstack_clean.os_utils' '.get_users', return_value=self.test_list), \ mock.patch('functest.utils.openstack_clean.os_utils' '.delete_user', return_value=True): openstack_clean.remove_users(self.client, self.remove_list) mock_logger_debug.assert_any_call("Removing Users...") mock_logger_debug.assert_any_call(" > Done!") mock_logger_debug.assert_any_call( test_utils.RegexMatch(" Removing " "\s*\S+..."))
def test_remove_users_delete_failed(self, mock_logger_debug, mock_logger_error): with mock.patch('functest.utils.openstack_clean.os_utils' '.get_users', return_value=self.test_list), \ mock.patch('functest.utils.openstack_clean.os_utils' '.delete_user', return_value=False): openstack_clean.remove_users(self.client, self.remove_list) mock_logger_debug.assert_any_call("Removing Users...") mock_logger_error.assert_any_call( test_utils.RegexMatch("There has been a " "problem removing " "the user \s*\S+" "...")) mock_logger_debug.assert_any_call( test_utils.RegexMatch(" Removing " "\s*\S+..."))