def parse_single_attribute_from_en_table():
    attr_block_html = (u'<body class="dummy">'
                       u'  <table>'
                       u'    <tr>'
                       u'      <td><pre>attr1</pre></td>'
                       u'      <td>value1</td>'
                       u'    </tr>'
                       u'    <tr>'
                       u'      <td><pre>attr2</pre></td>'
                       u'      <td>value2</td>'
                       u'    </tr>'
                       u'    <tr>'
                       u'      <td><pre>attr3</pre></td>'
                       u'      <td>value3</td>'
                       u'    </tr>'
                       u'  </table>'
                       u'</body>')
    attrs = list(
        hanreifetch.EnJikenParser().hanrei_attrs_from(attr_block_html))
    assert attrs == [
        (
            u'attr1',
            u'value1',
        ),
        (
            u'attr2',
            u'value2',
        ),
        (
            u'attr3',
            u'value3',
        ),
    ]
Beispiel #2
0
 def __init__(self, en_list=False):
     if en_list:
         self._listhandler = hanreifetch.EnListHandler()
         self._jikenparser = hanreifetch.EnJikenParser()
     else:
         self._listhandler = hanreifetch.ListHandler()
         self._jikenparser = hanreifetch.JikenParser()
     self._in_english = en_list
def create_en_hanrei_xml():
    hanrei_xml = hanreifetch.EnJikenParser().create_xml_from([
        (sample_en_jiken(), '2012-Kyo-No.43')
    ])
    expected_xml = sample_en_jiken_xml()
    assert hanrei_xml == expected_xml
def create_en_hanrei_struct():
    hanrei = hanreifetch.EnJikenParser().create_struct_from(sample_en_jiken())
    expected_attrmap = sample_en_jiken_struct_attrmap()
    for key in expected_attrmap:
        assert getattr(hanrei, key) == expected_attrmap[key]
def detect_all_en_hanrei_attrs():
    detected = list(hanreifetch.EnJikenParser().hanrei_attrs_from(
        sample_en_jiken()))
    expected_attrs = sample_en_jiken_attr_pairs()
    assert set(detected) == set(expected_attrs)