from k_parse_tool.lib.htmlprocess import get_table_metadata

# -*- coding: utf-8 -*-

import unittest
from unittest.mock import patch


class PdfProcessTestCase(unittest.TestCase):

    def test_extract_table_metadata(self):
        self.env = patch.dict('os.environ', {'SCRAPY_PROJECT': 'development'})
        source = """<table style="WIDTH: 1531px; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="1531" border="0">  <colgroup>  <col style="WIDTH: 95px; mso-width-source: userset; mso-width-alt: 3040" width="95">  <col style="WIDTH: 207px; mso-width-source: userset; mso-width-alt: 6624" width="207">  <col style="WIDTH: 220px; mso-width-source: userset; mso-width-alt: 7040" width="220">  <col style="WIDTH: 295px; mso-width-source: userset; mso-width-alt: 9440" width="295">  <col style="WIDTH: 47px; mso-width-source: userset; mso-width-alt: 1504" width="47">  <col style="WIDTH: 52px; mso-width-source: userset; mso-width-alt: 1664" width="52">  <col style="WIDTH: 56px; mso-width-source: userset; mso-width-alt: 1792" width="56">  <col style="WIDTH: 59px; mso-width-source: userset; mso-width-alt: 1856" width="58">  <col style="WIDTH: 63px; mso-width-source: userset; mso-width-alt: 1984" width="62">  <col style="WIDTH: 63px; mso-width-source: userset; mso-width-alt: 2016" width="63">  <col style="WIDTH: 117px; mso-width-source: userset; mso-width-alt: 3744" width="117">  <col style="WIDTH: 259px; mso-width-source: userset; mso-width-alt: 8288" width="259">  </colgroup><tbody>    <tr style="HEIGHT: 19px" height="19">      <td class="xl65" style="BORDER-TOP: #000 1px solid; HEIGHT: 38px; BORDER-RIGHT: #000 1px solid; WIDTH: 95px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" height="38" rowspan="2" width="95"><font face="宋体"><strong>决定书号</strong></font></td>      <td class="xl73" style="BORDER-TOP: #000 1px solid; BORDER-RIGHT: #000 1px solid; WIDTH: 207px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" rowspan="2" width="207"><font face="宋体"><strong>被处罚人名称</strong></font></td>      <td class="xl73" style="BORDER-TOP: #000 1px solid; BORDER-RIGHT: #000 1px solid; WIDTH: 220px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" rowspan="2" width="220"><font face="宋体"><strong>案由</strong></font></td>      <td class="xl73" style="BORDER-TOP: #000 1px solid; BORDER-RIGHT: #000 1px solid; WIDTH: 295px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" rowspan="2" width="295"><font face="宋体"><strong>处罚依据</strong></font></td>      <td class="xl65" style="BORDER-TOP: #000 1px solid; BORDER-RIGHT: #000 1px solid; WIDTH: 339px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="338" colspan="6"><font face="宋体"><strong>处罚决定内容</strong></font></td>      <td class="xl74" style="BORDER-TOP: #000 1px solid; BORDER-RIGHT: #000 1px solid; WIDTH: 117px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" rowspan="2" width="117"><strong><font face="宋体">签发日期</font><font class="font7" face="Times New Roman"><span style="mso-spacerun: yes"> </span></font></strong></td>      <td class="xl65" style="BORDER-TOP: #000 1px solid; BORDER-RIGHT: #000 1px solid; WIDTH: 259px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" rowspan="2" width="259"><strong><font face="宋体">执法单位名称</font></strong></td>    </tr>    <tr style="HEIGHT: 19px" height="19">      <td class="xl65" style="BORDER-TOP: #000; HEIGHT: 19px; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" height="19"><strong><font face="宋体">警告</font></strong></td>      <td class="xl65" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><strong><font face="宋体">没收</font></strong></td>      <td class="xl65" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><strong><font face="宋体">罚款</font></strong></td>      <td class="xl65" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><strong><font face="宋体">吊证</font></strong></td>      <td class="xl65" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><strong><font face="宋体">停产</font></strong></td>      <td class="xl65" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><strong><font face="宋体">其他</font></strong></td>    </tr>    <tr style="HEIGHT: 76px" height="76">      <td class="xl71" style="BORDER-TOP: #000; HEIGHT: 76px; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" height="76"><font face="宋体">2120162065</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 207px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="207"><font face="宋体">沈建芳（上海闵行虹桥美美美发厅的经营者）</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 220px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="220"><font face="宋体">未按照规定对公共场所的空气、微小气候、水质、采光、照明、噪声、顾客用品用具等进行卫生检测</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 295px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="295"><font face="宋体">《公共场所卫生管理条例实施细则》第三十六条第（一）项</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1100</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl70" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">2016-5-4</font></td>      <td class="xl69" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">上海市闵行区卫生和计划生育委员会</font></td>    </tr>    <tr style="HEIGHT: 76px" height="76">      <td class="xl71" style="BORDER-TOP: #000; HEIGHT: 76px; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" height="76"><font face="宋体">2120162064</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 207px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="207"><font face="宋体">上海相昶贸易有限公司</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 220px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="220"><font face="宋体">未按照规定对公共场所的空气、微小气候、水质、采光、照明、噪声、顾客用品用具等进行卫生检测</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 295px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="295"><font face="宋体">《公共场所卫生管理条例实施细则》第三十六条第（一）项</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1100</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl70" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">2016-5-4</font></td>      <td class="xl69" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">上海市闵行区卫生和计划生育委员会</font></td>    </tr>    <tr style="HEIGHT: 76px" height="76">      <td class="xl71" style="BORDER-TOP: #000; HEIGHT: 76px; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" height="76"><font face="宋体">2120162066</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 207px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="207"><font face="宋体">郭祥娣（上海市闵行区浦江镇清星理发店的经营者）</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 220px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="220"><font face="宋体">未按照规定对公共场所的空气、微小气候、水质、采光、照明、噪声、顾客用品用具等进行卫生检测</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 295px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="295"><font face="宋体">《公共场所卫生管理条例实施细则》第三十六条第（一）项</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1100</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl70" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">2016-5-4</font></td>      <td class="xl69" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">上海市闵行区卫生和计划生育委员会</font></td>    </tr>    <tr style="HEIGHT: 76px" height="76">      <td class="xl71" style="BORDER-TOP: #000; HEIGHT: 76px; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" height="76"><font face="宋体">2120162063</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 207px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="207"><font face="宋体">魏学宽（上海市闵行区欣品空间美发厅的经营者）</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 220px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="220"><font face="宋体">未按照规定对公共场所的空气、微小气候、水质、采光、照明、噪声、顾客用品用具等进行卫生检测</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 295px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="295"><font face="宋体">《公共场所卫生管理条例实施细则》第三十六条第（一）项</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1200</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl70" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">2016-5-4</font></td>      <td class="xl69" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">上海市闵行区卫生和计划生育委员会</font></td>    </tr>    <tr style="HEIGHT: 76px" height="76">      <td class="xl71" style="BORDER-TOP: #000; HEIGHT: 76px; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000 1px solid; BACKGROUND-COLOR: transparent" height="76"><font face="宋体">2120162067</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 207px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="207"><font face="宋体">上海凯姆美容美发有限公司</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 220px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="220"><font face="宋体">未按照规定对公共场所的空气、微小气候、水质、采光、照明、噪声、顾客用品用具等进行卫生检测</font></td>      <td class="xl72" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; WIDTH: 295px; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent" width="295"><font face="宋体">《公共场所卫生管理条例实施细则》第三十六条第（一）项</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl71" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">1100</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl67" style="BORDER-TOP: #000; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">　</font></td>      <td class="xl70" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">2016-5-4</font></td>      <td class="xl69" style="BORDER-TOP: #ece9d8; BORDER-RIGHT: #000 1px solid; BORDER-BOTTOM: #000 1px solid; BORDER-LEFT: #000; BACKGROUND-COLOR: transparent"><font face="宋体">上海市闵行区卫生和计划生育委员会</font></td>    </tr>  </tbody>  </table>"""
        res = get_table_metadata(source)
        print(res)


if __name__ == '__main__':
    unittest.main()