Merge "Support list containers by type"
This commit is contained in:
commit
7086558f43
@ -149,6 +149,7 @@ class ContainersController(controllers.ACLMixin):
|
||||
offset_arg=kw.get('offset', 0),
|
||||
limit_arg=kw.get('limit', None),
|
||||
name_arg=kw.get('name', None),
|
||||
type_arg=kw.get('type', None),
|
||||
suppress_exception=True
|
||||
)
|
||||
|
||||
|
@ -1310,7 +1310,7 @@ class ContainerRepo(BaseRepo):
|
||||
"""Repository for the Container entity."""
|
||||
|
||||
def get_by_create_date(self, external_project_id, offset_arg=None,
|
||||
limit_arg=None, name_arg=None,
|
||||
limit_arg=None, name_arg=None, type_arg=None,
|
||||
suppress_exception=False, session=None):
|
||||
"""Returns a list of containers
|
||||
|
||||
@ -1330,6 +1330,9 @@ class ContainerRepo(BaseRepo):
|
||||
if name_arg:
|
||||
query = query.filter(models.Container.name.like(name_arg))
|
||||
|
||||
if type_arg:
|
||||
query = query.filter(models.Container.type == type_arg)
|
||||
|
||||
query = query.join(models.Project, models.Container.project)
|
||||
query = query.filter(models.Project.external_id == external_project_id)
|
||||
|
||||
|
@ -160,12 +160,12 @@ class WhenGettingContainersListUsingContainersResource(
|
||||
'limit': self.limit
|
||||
}
|
||||
|
||||
def _create_containers(self):
|
||||
def _create_containers(self, type='generic'):
|
||||
for i in range(self.num_containers):
|
||||
resp, container_uuid = create_container(
|
||||
self.app,
|
||||
name='test container name {num}'.format(num=i),
|
||||
container_type='generic'
|
||||
container_type=type
|
||||
)
|
||||
self._assert_successful_container_create(resp, container_uuid)
|
||||
|
||||
@ -199,6 +199,24 @@ class WhenGettingContainersListUsingContainersResource(
|
||||
self.assertEqual((self.limit + 2),
|
||||
resp.body.decode('utf-8').count(url_hrefs))
|
||||
|
||||
def test_list_containerss_by_type(self):
|
||||
# Creating containers to be retrieved later
|
||||
self._create_containers(type='generic')
|
||||
self._create_containers(type='certificate')
|
||||
self._create_containers(type='rsa')
|
||||
|
||||
for type in ('generic', 'certificate', 'rsa'):
|
||||
params = {
|
||||
'limit': self.num_containers,
|
||||
'type': type
|
||||
}
|
||||
resp = self.app.get(
|
||||
'/containers/',
|
||||
params
|
||||
)
|
||||
self.assertEqual(200, resp.status_int)
|
||||
self.assertEqual(self.num_containers, resp.namespace.get('total'))
|
||||
|
||||
def test_response_should_include_total(self):
|
||||
self._create_containers()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user