예제 #1
0
def test_should_be_able_to_load_snmpagentdown_alert_msg_template():
    details = TemplateDetails(name='snmpAgentState/snmpAgentDown-email.txt',
                              msgtype='email',
                              language='en')
    ensure_alert_templates_are_available()
    template = loader.get_template(details.name)
    assert template
예제 #2
0
def test_template_syntax():
    ensure_alert_templates_are_available()
    templates = list(get_template_list())
    assert templates, "Can't find any Django templates"
    for template in templates:
        testname = "does %s validate" % template
        yield testname, loader.get_template, template
예제 #3
0
def test_template_syntax():
    ensure_alert_templates_are_available()
    templates = list(get_template_list())
    assert templates, "Can't find any Django templates"
    for template in templates:
        testname = "does %s validate" % template
        yield testname, loader.get_template, template
예제 #4
0
def test_should_be_able_to_render_snmpagentdown_alert_msg_template():
    details = TemplateDetails(name='snmpAgentState/snmpAgentDown-email.txt',
                              msgtype='email',
                              language='en')
    ensure_alert_templates_are_available()
    event = Mock(varmap={})
    alert = AlertGenerator(event)
    _, output = _render_template(details, alert)
    assert output
예제 #5
0
def get_template_list(directories=None):
    templates = getattr(settings, 'TEMPLATES', [{}])
    template_dirs = list(getattr(templates[0], 'DIRS', []))
    if not template_dirs:
        template_dirs = list(getattr(settings, 'TEMPLATE_DIRS',
                                     []))  # Outdated, remove when on 1.11
    if not directories:
        ensure_alert_templates_are_available()
        directories = template_dirs + list(get_nav_app_template_dirs())

    for tmpldir in directories:
        for dirname, _subdirs, files in os.walk(tmpldir):
            for name in files:
                fullpath = join(dirname, name)
                yield relpath(fullpath, tmpldir)
예제 #6
0
def test_templates_can_be_found():
    ensure_alert_templates_are_available()
    templates = list(get_template_list())
    assert templates, "Can't find any Django templates"