class TestRepositoryActionsAPI(unittest.TestCase): """Tests for the binding to the 'v2/repositories/<repo-id>/actions/sync/' API.""" def setUp(self): self.pulp_connection = mock.MagicMock(spec=PulpConnection) self.actions_api = RepositoryActionsAPI(self.pulp_connection) self.repo_id = 'mock_repo' self.override_config = {'key': 'value'} def test_sync(self): """Assert the sync API path is called.""" self.response = self.actions_api.sync(self.repo_id, self.override_config) self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/sync/', {'override_config': self.override_config} ) def test_publish(self): """Assert the publish API path is called.""" self.response = self.actions_api.publish( self.repo_id, 'mock_distributor', self.override_config ) self.override_config['id'] = 'mock_distributor' body = {'id': 'mock_distributor', 'override_config': self.override_config} self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/publish/', body ) def test_associate(self): """Assert the associate API path is called.""" self.response = self.actions_api.associate(self.repo_id, 'other_repo') self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/associate/', {'source_repo_id': 'other_repo'} ) def test_download(self): """Assert the download API path is called and the default parameters are correct.""" self.response = self.actions_api.download(self.repo_id) self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/download/', {'verify_all_units': False} ) def test_download_verify(self): """Assert the download API path is called and the default parameters are correct.""" self.response = self.actions_api.download(self.repo_id, verify_all_units=True) self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/download/', {'verify_all_units': True} )
class TestRepositoryActionsAPI(unittest.TestCase): """Tests for the binding to the 'v2/repositories/<repo-id>/actions/sync/' API.""" def setUp(self): self.pulp_connection = mock.MagicMock(spec=PulpConnection) self.actions_api = RepositoryActionsAPI(self.pulp_connection) self.repo_id = 'mock_repo' self.override_config = {'key': 'value'} def test_sync(self): """Assert the sync API path is called.""" self.response = self.actions_api.sync(self.repo_id, self.override_config) self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/sync/', {'override_config': self.override_config}) def test_publish(self): """Assert the publish API path is called.""" self.response = self.actions_api.publish(self.repo_id, 'mock_distributor', self.override_config) self.override_config['id'] = 'mock_distributor' body = { 'id': 'mock_distributor', 'override_config': self.override_config } self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/publish/', body) def test_associate(self): """Assert the associate API path is called.""" self.response = self.actions_api.associate(self.repo_id, 'other_repo') self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/associate/', {'source_repo_id': 'other_repo'}) def test_download(self): """Assert the download API path is called and the default parameters are correct.""" self.response = self.actions_api.download(self.repo_id) self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/download/', {'verify_all_units': False}) def test_download_verify(self): """Assert the download API path is called and the default parameters are correct.""" self.response = self.actions_api.download(self.repo_id, verify_all_units=True) self.pulp_connection.POST.assert_called_once_with( '/v2/repositories/mock_repo/actions/download/', {'verify_all_units': True})