Ejemplo n.º 1
0
    def test_version_manager_disable_version_raises_exception_if_object_does_not_exist(
            self, mock_get_all):
        # Arrange
        mock_absent = _create_mock_object()
        mock_version_manager = _create_mock_version_manager()

        mock_get_all.return_value = [mock_version_manager]

        # Act + Assert
        with self.assertRaises(exceptions.ApiError):
            version_manager_api.disable_version(mock_absent)
Ejemplo n.º 2
0
    def test_version_manager_disable_current_version_throws_exception(
            self, mock_get_all):
        # Arrange
        mock_version_manager = _create_mock_version_manager()
        mock_current = _create_mock_object()
        mock_version_manager.versions.append(str(mock_current.id))
        mock_version_manager.current = str(mock_current.id)

        mock_get_all.return_value = [mock_version_manager]

        # Act + Assert
        with self.assertRaises(exceptions.ApiError):
            version_manager_api.disable_version(mock_current)
Ejemplo n.º 3
0
def disable_version_of_version_manager(version):
    """ Disable a version of a version manager.

    Args:
        version:

    Returns:

    """
    try:
        version_manager_api.disable_version(version)
    except Exception as e:
        return HttpResponseBadRequest(str(e), content_type='application/javascript')
Ejemplo n.º 4
0
    def test_version_manager_disable_version_raises_exception_if_new_current_does_not_exist(
            self, mock_get_all):
        # Arrange
        mock_user = create_mock_user("1", is_superuser=True)
        mock_request = create_mock_request(mock_user)
        mock_version_manager = _create_mock_version_manager()
        mock_absent = _create_mock_object()
        mock_current = _create_mock_object()
        mock_version_manager.versions.append(str(mock_current.id))
        mock_version_manager.current = str(mock_current.id)

        mock_get_all.return_value = [mock_version_manager]

        # Act + Assert
        with self.assertRaises(exceptions.ApiError):
            version_manager_api.disable_version(mock_current,
                                                request=mock_request,
                                                new_current=mock_absent)
Ejemplo n.º 5
0
    def status_update(self, template_object):
        """ Update status to disabled

        Args:
            template_object:

        Returns:

        """
        return version_manager_api.disable_version(template_object)
Ejemplo n.º 6
0
    def status_update(self, template_object):
        """Update status to disabled

        Args:

            template_object: template_version

        Returns:

            TemplateVersion
        """
        return version_manager_api.disable_version(template_object,
                                                   request=self.request)