Exemple #1
0
    def test_put_repo_group_distributor_no_config_specified(self, mock_factory, mock_resp):
        """
        Modifiy a distributor without specifying the distributor_config.
        """
        mock_request = mock.MagicMock()
        mock_request.body = json.dumps({'no_dist_config': 'mock_conf'})

        repo_group_distributor_resource = RepoGroupDistributorResourceView()

        try:
            repo_group_distributor_resource.put(mock_request, 'group_id', 'dist_id')
        except pulp_exceptions.MissingValue, response:
            pass
Exemple #2
0
    def test_put_repo_group_distributor(self, mock_factory, mock_resp, mock_rev):
        """
        Modifiy a distributor with required argument.
        """
        mock_request = mock.MagicMock()
        mock_rev.return_value = '/mock/path/'
        mock_request.body = json.dumps({'distributor_config': 'mock_conf'})
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.update_distributor_config.return_value = {'updated': 'distributor'}

        repo_group_distributor_resource = RepoGroupDistributorResourceView()
        response = repo_group_distributor_resource.put(mock_request, 'group_id', 'dist_id')

        expected_content = {'updated': 'distributor', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        mock_dist_manager.update_distributor_config.assert_called_once_with(
            'group_id', 'dist_id', 'mock_conf')
        self.assertTrue(response is mock_resp.return_value)