Skip to content

Commit

Permalink
Merge pull request #122 from abalakh/available_repos
Browse files Browse the repository at this point in the history
Added entities.Product.list_available_rhrepos() func
  • Loading branch information
Ichimonji10 committed Jun 19, 2015
2 parents 7a0b066 + 5bf93f7 commit 631e14d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
17 changes: 17 additions & 0 deletions nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,6 +2667,23 @@ def disable_rhrepo(self, base_arch,
)
return _handle_response(response, self._server_config, synchronous)

# pylint:disable=C0103
def repository_sets_available_repositories(self, reposet_id):
"""Lists available repositories for the repository set
:param reposet_id: The RepositorySet Id.
:returns: Returns list of available repositories for the repository set
"""
response = client.get(
self.path(
'repository_sets/{0}/available_repositories'
.format(reposet_id)
),
**self._server_config.get_client_kwargs()
)
return _handle_response(response, self._server_config)['results']


class PartitionTable(
Entity, EntityCreateMixin, EntityDeleteMixin, EntityReadMixin):
Expand Down
33 changes: 33 additions & 0 deletions tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def test_id_and_which(self):
(entities.Product, 'repository_sets'),
(entities.Product, 'repository_sets/2396/disable'),
(entities.Product, 'repository_sets/2396/enable'),
(entities.Product,
'repository_sets/2396/available_repositories'),
(entities.Repository, 'sync'),
(entities.Repository, 'upload_content'),
(entities.RHCIDeployment, 'deploy'),
Expand Down Expand Up @@ -1133,6 +1135,37 @@ def test_list_rhproducts(self):
self.assertEqual(handler.return_value['results'], response)


class ProductTestCase(TestCase):
"""Tests for :class:`nailgun.entities.Product`."""

def setUp(self):
"""Set ``self.product``."""
self.product = entities.Product(
config.ServerConfig('http://example.com'),
id=gen_integer(min_value=1),
)

# pylint:disable=C0103
def test_repository_sets_available_repositories(self):
"""Call
:meth:`nailgun.entities.Product.repository_sets_available_repositories`
"""
with mock.patch.object(client, 'get') as client_get:
with mock.patch.object(
entities,
'_handle_response',
return_value={'results': gen_integer()}, # not realistic
) as handler:
reposet_id = gen_integer(min_value=1)
response = self.product.repository_sets_available_repositories(
reposet_id=reposet_id,
)
self.assertEqual(client_get.call_count, 1)
self.assertEqual(handler.call_count, 1)
self.assertEqual(handler.return_value['results'], response)


class RHCIDeploymentTestCase(TestCase):
"""Tests for :class:`nailgun.entities.RHCIDeployment`."""

Expand Down

0 comments on commit 631e14d

Please sign in to comment.