Exemple #1
0
def patch_coffin():
    """coffin before version 0.3.4
    does not have csrf_token template tag.
    This patch must be applied after the django patches
    """
    from askbot.patches import coffin_patches

    (major, minor, micro) = package_utils.get_coffin_version()
    if major == 0 and minor == 3 and micro < 4:
        coffin_patches.add_csrf_token_tag()
Exemple #2
0
def patch_coffin():
    """coffin before version 0.3.4
    does not have csrf_token template tag.
    This patch must be applied after the django patches
    """
    from askbot.patches import coffin_patches

    (major, minor, micro) = package_utils.get_coffin_version()
    if major == 0 and minor == 3 and micro < 4:
        coffin_patches.add_csrf_token_tag()
def assert_package_compatibility():
    """raises an exception if any known incompatibilities 
    are found
    """
    (django_major, django_minor, django_micro) = package_utils.get_django_version()
    if django_major < 1:
        raise DeploymentError('Django version < 1.0 is not supported by askbot')

    coffin_version = package_utils.get_coffin_version()
    if coffin_version == (0, 3, 0) and django_major == 1 and django_minor > 1:
        raise DeploymentError(
            'Coffin package version 0.3 is not compatible '
            'with the current version of Django, please upgrade '
            'coffin to at least 0.3.3'
        )
Exemple #4
0
def assert_package_compatibility():
    """raises an exception if any known incompatibilities 
    are found
    """
    (django_major, django_minor, django_micro) = \
        package_utils.get_django_version()
    if django_major < 1:
        raise DeploymentError(
            'Django version < 1.0 is not supported by askbot')

    coffin_version = package_utils.get_coffin_version()
    if coffin_version == (0, 3, 0) and django_major == 1 and django_minor > 1:
        raise DeploymentError(
            'Coffin package version 0.3 is not compatible '
            'with the current version of Django, please upgrade '
            'coffin to at least 0.3.3')
Exemple #5
0
def patch_jinja2():
    from jinja2 import Template
    ORIG_JINJA2_RENDERER = Template.render

    def instrumented_render(template_object, *args, **kwargs):
        context = dict(*args, **kwargs)
        signals.template_rendered.send(sender=template_object,
                                       template=template_object,
                                       context=context)
        return ORIG_JINJA2_RENDERER(template_object, *args, **kwargs)

    Template.render = instrumented_render


(CMAJOR, CMINOR, CMICRO) = package_utils.get_coffin_version()
if CMAJOR == 0 and CMINOR == 3 and CMICRO < 4:
    patch_jinja2()


class PageLoadTestCase(AskbotTestCase):

    #############################################
    #
    # INFO: We load test data once for all tests in this class (setUpClass + cleanup in tearDownClass)
    #
    #       We also disable (by overriding _fixture_setup/teardown) per-test fixture setup,
    #       which by default flushes the database for non-transactional db engines like MySQL+MyISAM.
    #       For transactional engines it only messes with transactions, but to keep things uniform
    #       for both types of databases we disable it all.
    #
def patch_jinja2():
    from jinja2 import Template
    ORIG_JINJA2_RENDERER = Template.render

    def instrumented_render(template_object, *args, **kwargs):
        context = dict(*args, **kwargs)
        signals.template_rendered.send(
                                sender=template_object,
                                template=template_object,
                                context=context
                            )
        return ORIG_JINJA2_RENDERER(template_object, *args, **kwargs)
    Template.render = instrumented_render

(CMAJOR, CMINOR, CMICRO) = package_utils.get_coffin_version()
if CMAJOR == 0 and CMINOR == 3 and CMICRO < 4:
    patch_jinja2()


class PageLoadTestCase(AskbotTestCase):

    #############################################
    #
    # INFO: We load test data once for all tests in this class (setUpClass + cleanup in tearDownClass)
    #
    #       We also disable (by overriding _fixture_setup/teardown) per-test fixture setup,
    #       which by default flushes the database for non-transactional db engines like MySQL+MyISAM.
    #       For transactional engines it only messes with transactions, but to keep things uniform
    #       for both types of databases we disable it all.
    #