示例#1
0
    def test_post_repo_group_distributors(self, mock_factory, mock_resp,
                                          mock_redir, mock_reverse):
        """
        Create a new repo group distributor.
        """
        mock_request = mock.MagicMock()
        mock_request.body = json.dumps({
            'distributor_type_id': 'mock_type',
            'distributor_config': 'mock_conf',
            'distributor_id': 'mock_id',
        })
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.add_distributor.return_value = {'id': 'dist1'}
        mock_reverse.return_value = '/mock/path/'

        repo_group_distributors = RepoGroupDistributorsView()
        response = repo_group_distributors.post(mock_request, 'mock_group_id')

        expected_content = {'id': 'dist1', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        mock_redir.assert_called_once_with(mock_resp.return_value,
                                           mock_reverse.return_value)
        self.assertTrue(response is mock_redir.return_value)
        mock_dist_manager.add_distributor.assert_called_once_with(
            'mock_group_id', 'mock_type', 'mock_conf', 'mock_id')
示例#2
0
    def test_post_repo_group_distributors(self, mock_factory, mock_resp, mock_redir, mock_reverse):
        """
        Create a new repo group distributor.
        """
        mock_request = mock.MagicMock()
        mock_request.body = json.dumps({
            'distributor_type_id': 'mock_type',
            'distributor_config': 'mock_conf',
            'distributor_id': 'mock_id',
        })
        mock_dist_manager = mock_factory.repo_group_distributor_manager.return_value
        mock_dist_manager.add_distributor.return_value = {'id': 'dist1'}
        mock_reverse.return_value = '/mock/path/'

        repo_group_distributors = RepoGroupDistributorsView()
        response = repo_group_distributors.post(mock_request, 'mock_group_id')

        expected_content = {'id': 'dist1', '_href': '/mock/path/'}
        mock_resp.assert_called_once_with(expected_content)
        mock_redir.assert_called_once_with(mock_resp.return_value, mock_reverse.return_value)
        self.assertTrue(response is mock_redir.return_value)
        mock_dist_manager.add_distributor.assert_called_once_with(
            'mock_group_id', 'mock_type', 'mock_conf', 'mock_id'
        )