コード例 #1
0
def test_get_section_start_index_no_open_brace_error():
    prsr = ip.IappParser(no_open_brace_templ)
    with pytest.raises(ip.NonextantSectionException) as \
            NonextantSectionExceptInfo:
        prsr._get_section_start_index(u'html-help')
    assert NonextantSectionExceptInfo.value.message == \
        'Section html-help not found in template'
コード例 #2
0
def test_get_template_name_bad_name_error():
    prsr = ip.IappParser(bad_name_templ)
    with pytest.raises(ip.NonextantTemplateNameException) as \
            NonextantTemplateNameExceptInfo:
        prsr._get_template_name()
    assert NonextantTemplateNameExceptInfo.value.message == \
        'Template name not found.'
コード例 #3
0
def test__init__error():
    prsr = None
    with pytest.raises(ip.EmptyTemplateException) as EmptyTemplateExceptInfo:
        prsr = ip.IappParser('')
    assert EmptyTemplateExceptInfo.value.message == \
        'Template empty or None value.'
    assert prsr is None
コード例 #4
0
def test_attr_whitespace_rm_error():
    prsr = ip.IappParser(whitespace_rm_templ)
    with pytest.raises(ip.MalformedTCLListException) as ex:
        prsr.parse_template()
    assert 'TCL list for "requires-modules" is malformed. If no elements are ' \
        'needed "none" should be used without curly braces.' in \
        ex.value.message
コード例 #5
0
def TemplateSectionSetup(request):
    def tearDown():
        prsr.template_sections.remove('notfound')
    request.addfinalizer(tearDown)
    prsr = ip.IappParser(good_templ)
    prsr.template_sections.append('notfound')
    return prsr
コード例 #6
0
def test_get_section_end_no_close_brace_error():
    prsr = ip.IappParser(no_close_brace_templ)
    with pytest.raises(ip.CurlyBraceMismatchException) as \
            CurlyBraceMismatchExceptInfo:
        help_start = prsr._get_section_start_index(u'html-help')
        prsr._get_section_end_index(u'html_help', help_start)
    assert CurlyBraceMismatchExceptInfo.value.message == \
        'Curly braces mismatch in section html_help.'
コード例 #7
0
def test_get_section_end_index():
    prsr = ip.IappParser(good_templ)
    impl_start = prsr._get_section_start_index(u'implementation')
    impl_end = prsr._get_section_end_index(u'implementation', impl_start)
    templ_impl = unicode('''{
        # TMSH implementation code
      }''')
    assert good_templ[impl_start:impl_end+1] == templ_impl
コード例 #8
0
def test_attr_empty_rm_error():
    prsr = ip.IappParser(empty_rm_templ)
    with pytest.raises(ip.MalformedTCLListException) as ex:
        prsr.parse_template()
    assert 'requires-modules' in ex.value.message
コード例 #9
0
def test_attr_no_description():
    prsr = ip.IappParser(no_desc_templ)
    templ_dict = prsr.parse_template()
    assert 'description' not in templ_dict
コード例 #10
0
def test_get_template_attr_attr_not_exists():
    prsr = ip.IappParser(good_attr_templ)
    attr = prsr._get_template_attr(u'bad_attr')
    assert attr is None
コード例 #11
0
def test_get_template_attr():
    prsr = ip.IappParser(good_attr_templ)
    attr = prsr._get_template_attr(u'partition')
    assert attr == u'just_a_partition name'
コード例 #12
0
def test_parse_template_no_section_found_not_required():
    prsr = ip.IappParser(no_help_templ)
    templ_dict = prsr.parse_template()
    assert templ_dict == no_help_templ_dict
コード例 #13
0
def test_parse_template_brace_in_quote():
    prsr = ip.IappParser(brace_in_quote_templ)
    assert prsr.parse_template() == brace_in_quote_templ_dict
コード例 #14
0
def test__init__():
    prsr = ip.IappParser(good_templ)
    assert prsr.template_str == good_templ
コード例 #15
0
def test_get_template_name_next_to_brace():
    prsr = ip.IappParser(name_brace_templ)
    assert prsr._get_template_name() == u'name_next_to_brace'
コード例 #16
0
def test_get_template_name():
    prsr = ip.IappParser(good_templ)
    assert prsr._get_template_name() == u'good_templ'
コード例 #17
0
def test_attr_none_rm():
    prsr = ip.IappParser(none_rm_templ)
    templ_dict = prsr.parse_template()
    assert templ_dict == none_rm_templ_dict
コード例 #18
0
def test_parse_template():
    prsr = ip.IappParser(good_templ)
    assert prsr.parse_template() == good_templ_dict