# coding: utf8
"""Test bbs2ch.decode module."""
from bbs2ch import decode


def test_menu():
    """Parse bbsmenu html."""
    body = u"""
<B>カテゴリ1</B><BR>
<A HREF=http://test2ch.net/hoge/>ほげ</A><br>
<A HREF=http://test2ch.net/fuga/>ふが</A><br>
<BR><BR><B>カテゴリ2</B><BR>
<A HREF=http://test2ch.net/foo/>foo</A><br>"""
    ret = list(decode.menu(body))
    assert (u'http://test2ch.net/hoge/', u'カテゴリ1', u'ほげ') == ret[0]
    assert (u'http://test2ch.net/fuga/', u'カテゴリ1', u'ふが') == ret[1]
    assert (u'http://test2ch.net/foo/', u'カテゴリ2', u'foo') == ret[2]


def test_board_subject():
    """Parse board subject.txt."""
    body = u"""
100.dat<>スレッド1 (2)
200.dat<>スレッド2 (1000)"""
    ret = list(decode.board_subject(body))
    assert (u'100', u'スレッド1', 2) == ret[0]
    assert (u'200', u'スレッド2', 1000) == ret[1]

@@ -790,20 +790,463 @@
 2', 1000) == ret%5B1%5D%0A
+%0A%0Adef test_thread_dat():%0A    %22%22%22Parse thread dat.%22%22%22%0A    body = u%22%22%22%0A%E5%90%8D%E7%84%A1%E3%81%97%3C%3E%3C%3E1970/01/01(%E6%9C%A8) 00:00:00.00 ID:ZZZZZZZZ%3C%3Ehoge%3Cbr%3Efuga %3C%3E%E3%82%B9%E3%83%AC%E3%83%83%E3%83%891%0A%E5%90%8D%E7%84%A1%E3%81%97%3C%3Esage%3C%3E2015/02/23(%E6%9C%88) 00:00:00.00 ID:FFFFFFFF%3C%3E%E3%83%86%E3%82%B9%E3%83%88%3C%3E%22%22%22%0A    ret = list(decode.thread_dat(body))%0A    assert (u'%E5%90%8D%E7%84%A1%E3%81%97', u'', u'1970/01/01(%E6%9C%A8) 00:00:00.00 ID:ZZZZZZZZ',%0A            u'hoge%3Cbr%3Efuga ') == ret%5B0%5D%0A    assert (u'%E5%90%8D%E7%84%A1%E3%81%97', u'sage', u'2015/02/23(%E6%9C%88) 00:00:00.00 ID:FFFFFFFF',%0A            u'%E3%83%86%E3%82%B9%E3%83%88') == ret%5B1%5D%0A

add decode.thread_dat test