# Path: WeCron/wxhook/todo_parser/local_parser.py
# CN_NUM = {
#         u'〇': 0,
#         u'一': 1,
#         u'二': 2,
#         u'三': 3,
#         u'四': 4,
#         u'五': 5,
#         u'六': 6,
#         u'七': 7,
#         u'八': 8,
#         u'九': 9,
#          
#         u'零': 0,
#         u'壹': 1,
#         u'贰': 2,
#         u'叁': 3,
#         u'肆': 4,
#         u'伍': 5,
#         u'陆': 6,
#         u'柒': 7,
#         u'捌': 8,
#         u'玖': 9,
#          
#         u'貮': 2,
#         u'两': 2,
#     }
# CN_UNIT = {
#         u'十': 10,
#         u'拾': 10,
#         u'百': 100,
#         u'佰': 100,
#         u'千': 1000,
#         u'仟': 1000,
#         u'万': 10000,
#         u'萬': 10000,
#         u'亿': 100000000,
#         u'億': 100000000,
#         u'兆': 1000000000000,
#     }
# DEFAULT_HOUR = 8
# DEFAULT_MINUTE = 0
# def parse_cn_number(cn_sentence):
#     def __init__(self):
#     def parse_by_rules(self, text):
#     def consume_repeat(self):
#     def consume_year(self):
#     def consume_month(self):
#     def consume_day(self):
#     def consume_hour(self):
#     def consume_minute(self):
#     def consume_second(self):
#     def exclude_time_range(self, next_expectation):
#     def consume_year_period(self):
#     def consume_month_period(self):
#     def consume_day_period(self):
#     def consume_weekday_period(self):
#     def consume_hour_period(self):
#     def consume_minute_period(self):
#     def consume_second_period(self):
#     def consume_to_end(self):
#     def consume_word(self, *words):
#     def consume_phrase(self, *words):
#     def consume_digit(self, consume=True):
#     def current_word(self):
#     def current_tag(self):
#     def peek_next_word(self, step=1):
#     def get_index(self):
#     def set_index(self, idx):
#     def has_next(self):
#     def advance(self, step=1):
# class LocalParser(object):


import unittest
from dateutil.relativedelta import relativedelta
from django.utils import timezone
from django.test import TestCase
from ..todo_parser.local_parser import LocalParser, parse_cn_number, DEFAULT_HOUR, ParseError
from remind.models import remind
            self.assertEqual((self.now + relativedelta(days=1)).day, reminder.time.day)
            self.assertEquals(reminder.time.hour, 9)
            self.assertEquals(reminder.time.minute, 30)

    def test_parse_date_out_of_range(self):
        text = '六月三十一号'
        self.assertRaises(ParseError, self.parse, text)

    def test_parse_time_range(self):
        self.parser.now = self.parser.now.replace(year=2017)
        for text in ('2017年11月12日 11:00-12:00 安美宝一包', '星期一到星期五提醒我早上六点半起床', '三号~五号吃饭'):
            self.setUp()
            with self.assertRaises(ParseError) as cm:
                self.parse(text)
            the_exception = cm.exception
            self.assertIn('连续时间段', the_exception.message)

    def test_should_not_add_additional_12_hours(self):
        text = '12:45报加班'
        self.parser.now = self.parser.now.replace(hour=12, minute=15)
        reminder = self.parse(text)
        self.assertEquals(reminder.time.hour, 12)
        self.assertEquals(reminder.time.minute, 45)

    def test_parse_day_period_without_hour(self):
        text = '九十九天后秒杀流量'
        reminder = self.parse(text)
        self.assertEqual(reminder.desc, text)
        self.assertEqual(reminder.title(), '秒杀流量')
        self.assertAlmostEqual((reminder.time - self.now).days, 99, delta=1)

# Path: WeCron/wxhook/todo_parser/local_parser.py
# CN_NUM = {
#         u'〇': 0,
#         u'一': 1,
#         u'二': 2,
#         u'三': 3,
#         u'四': 4,
#         u'五': 5,
#         u'六': 6,
#         u'七': 7,
#         u'八': 8,
#         u'九': 9,
#          
#         u'零': 0,
#         u'壹': 1,
#         u'贰': 2,
#         u'叁': 3,
#         u'肆': 4,
#         u'伍': 5,
#         u'陆': 6,
#         u'柒': 7,
#         u'捌': 8,
#         u'玖': 9,
#          
#         u'貮': 2,
#         u'两': 2,
#     }
# CN_UNIT = {
#         u'十': 10,
#         u'拾': 10,
#         u'百': 100,
#         u'佰': 100,
#         u'千': 1000,
#         u'仟': 1000,
#         u'万': 10000,
#         u'萬': 10000,
#         u'亿': 100000000,
#         u'億': 100000000,
#         u'兆': 1000000000000,
#     }
# DEFAULT_HOUR = 8
# DEFAULT_MINUTE = 0
# def parse_cn_number(cn_sentence):
#     def __init__(self):
#     def parse_by_rules(self, text):
#     def consume_repeat(self):
#     def consume_year(self):
#     def consume_month(self):
#     def consume_day(self):
#     def consume_hour(self):
#     def consume_minute(self):
#     def consume_second(self):
#     def exclude_time_range(self, next_expectation):
#     def consume_year_period(self):
#     def consume_month_period(self):
#     def consume_day_period(self):
#     def consume_weekday_period(self):
#     def consume_hour_period(self):
#     def consume_minute_period(self):
#     def consume_second_period(self):
#     def consume_to_end(self):
#     def consume_word(self, *words):
#     def consume_phrase(self, *words):
#     def consume_digit(self, consume=True):
#     def current_word(self):
#     def current_tag(self):
#     def peek_next_word(self, step=1):
#     def get_index(self):
#     def set_index(self, idx):
#     def has_next(self):
#     def advance(self, step=1):
# class LocalParser(object):


# Path: WeCron/wxhook/tests/test_todo_parser.py
import unittest
from dateutil.relativedelta import relativedelta
from django.utils import timezone
from django.test import TestCase
from ..todo_parser.local_parser import LocalParser, parse_cn_number, DEFAULT_HOUR, ParseError
from remind.models import remind

            self.assertEqual((self.now + relativedelta(days=1)).day, reminder.time.day)
            self.assertEquals(reminder.time.hour, 9)
            self.assertEquals(reminder.time.minute, 30)

    def test_parse_date_out_of_range(self):
        text = '六月三十一号'
        self.assertRaises(ParseError, self.parse, text)

    def test_parse_time_range(self):
        self.parser.now = self.parser.now.replace(year=2017)
        for text in ('2017年11月12日 11:00-12:00 安美宝一包', '星期一到星期五提醒我早上六点半起床', '三号~五号吃饭'):
            self.setUp()
            with self.assertRaises(ParseError) as cm:
                self.parse(text)
            the_exception = cm.exception
            self.assertIn('连续时间段', the_exception.message)

    def test_should_not_add_additional_12_hours(self):
        text = '12:45报加班'
        self.parser.now = self.parser.now.replace(hour=12, minute=15)
        reminder = self.parse(text)
        self.assertEquals(reminder.time.hour, 12)
        self.assertEquals(reminder.time.minute, 45)

    def test_parse_day_period_without_hour(self):
        text = '九十九天后秒杀流量'
        reminder = self.parse(text)
        self.assertEqual(reminder.desc, text)
        self.assertEqual(reminder.title(), '秒杀流量')
        self.assertAlmostEqual((reminder.time - self.now).days, 99, delta=1)

        self.assertEquals(reminder.time.hour, DEFAULT_HOUR)