Beispiel #1
0
def test_vocabulary(input_string, expected_result):
    config = {
        'md_extensions': ['rdm.md_extensions.VocabularyExtension'],
    }

    actual_result = render_from_string(input_string, config=config)
    assert actual_result == expected_result
Beispiel #2
0
 def test_audited_template_with_no_special_formats(self):
     config = {
         'md_extensions': ['rdm.md_extensions.AuditNoteInclusionExtension'],
     }
     input_string = "{% audit_notes %}Sample specification [[1234:9.8.7.6]]."
     expected_result = "Sample specification [1234:9.8.7.6].\n"
     actual_result = render_from_string(input_string, config=config)
     assert actual_result == expected_result
Beispiel #3
0
 def test_simple_template_with_audit_exclusion(self):
     config = {
         'md_extensions': ['rdm.md_extensions.AuditNoteExclusionExtension'],
     }
     input_string = "Sample specification [[1234:9.8.7.6]]."
     expected_result = "Sample specification.\n"
     actual_result = render_from_string(input_string, config=config)
     assert actual_result == expected_result
Beispiel #4
0
def test_filtering():
    config = {
        'md_extensions': ['rdm.md_extensions.VocabularyExtension'],
    }
    context = {'stuff': ['apple', 'cherry', 'egg']}
    input_string = 'apple, banana, cherry, plum\n{% for thing in stuff | present_in(first_pass_output.source) %} ' \
                   '--->{{thing}}{% endfor %}'
    expected_result = 'apple, banana, cherry, plum\n --->apple --->cherry\n'
    actual_result = render_from_string(input_string, context, config=config)
    assert actual_result == expected_result
Beispiel #5
0
 def test_custom_audited_template(self):
     config = {
         'md_extensions': ['rdm.md_extensions.AuditNoteInclusionExtension'],
     }
     context = {
         'system': {
             "auditor_notes": {
                 '4321': ' NOT USED',
                 '1234': '{spacing}***{tag}**:{content}*'
             },
         }
     }
     input_string = "{% audit_notes system.auditor_notes %}" \
                    "Sample specification [[4321:9.8.7.6]] and [[1234:9.8.7.6]] and  [[999:9.8.7.6]]."
     expected_result = "Sample specification NOT USED and ***1234**:9.8.7.6* and  [999:9.8.7.6].\n"
     actual_result = render_from_string(input_string, context, config=config)
     assert actual_result == expected_result
Beispiel #6
0
 def test_without_extension(self):
     input_string = "Sample specification [[1234:9.8.7.6]]."
     expected_result = "Sample specification [[1234:9.8.7.6]].\n"
     actual_result = render_from_string(input_string)
     assert actual_result == expected_result
Beispiel #7
0
def test_undefined():
    with raises(TemplateSyntaxError):
        input_string = "{% huhwhat 'hotel', 'california' %}"
        render_from_string(input_string)
Beispiel #8
0
def test_render_no_filtering():
    input_string = "apple\nbanana\ncherry\n"
    expected_result = input_string
    actual_result = render_from_string(input_string)
    assert actual_result == expected_result
Beispiel #9
0
def test_section_numbering_disabled(input_string, context, expected_output):
    actual_output = render_from_string(input_string, context=context)
    assert actual_output == expected_output
Beispiel #10
0
def test_section_numbering_enabled(input_string, context, expected_output):
    config = {
        'md_extensions': ['rdm.md_extensions.SectionNumberExtension'],
    }
    actual_output = render_from_string(input_string, context, config=config)
    assert actual_output == expected_output