Files
horizon/openstack_dashboard/dashboards/settings/credentials/tests.py
Tatiana Ovchinnikova 41cc293b65 Add filter to User Credentials table
Change-Id: I4f1bff57fc87736f702601323bfb8258282f7b41
2025-04-25 11:11:00 -05:00

40 lines
1.5 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.urls import reverse
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
INDEX_URL = reverse('horizon:settings:credentials:index')
INDEX_VIEW_TEMPLATE = 'horizon/common/_data_table_view.html'
class CredentialsViewTests(test.TestCase):
def _get_credentials(self, user_id):
credentials = [cred for cred in self.credentials.list()
if cred.user_id == user_id]
return credentials
@test.create_mocks({api.keystone: ('credentials_list',
'user_get', 'tenant_get')})
def test_index(self):
user = self.users.list()[0]
self.mock_user_get.return_value = user
credentials = self._get_credentials(user.id)
self.mock_credentials_list.return_value = credentials
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, INDEX_VIEW_TEMPLATE)
self.assertCountEqual(res.context['table'].data, credentials)