def test_recognize_from_bot(self): botuser = bot() service = parse.ParseService(botuser) message = make_mention("+100") message.author = botuser result = service.recognize(message) self.assertTrue(isinstance(result, parse_result.IgnorableRequest))
def test_recognize_empty(self): service = parse.ParseService(bot()) self.assertEqual(service.recognize(make_mention("")), parse_result.EmptyRequest()) self.assertEqual(service.recognize(make_mention(" ")), parse_result.EmptyRequest()) self.assertEqual(service.recognize(make_mention(" ")), parse_result.EmptyRequest())
def test_recognize_bind(self): service = parse.ParseService(bot()) self.assertEqual(parse_result.BindRequest("alice"), service.recognize(make_mention("im alice"))) self.assertEqual(parse_result.BindRequest("ありす"), service.recognize(make_mention("im ありす"))) self.assertEqual(parse_result.BindRequest("ー"), service.recognize(make_mention("imー"))) self.assertEqual(parse_result.BindRequest("ー"), service.recognize(make_mention("im ー"))) self.assertEqual(parse_result.BindRequest("🍎"), service.recognize(make_mention("im🍎")))
def test_recognize_update(self): service = parse.ParseService(bot()) base = ["月曜午前", "月AM", "午前月曜", "AM月", "AM月 "] small = map(lambda x: x.lower(), base) ja = map(lambda x: jaconv.h2z(x, kana=False, digit=True, ascii=True), base) term = list(itertools.chain(base, small, ja)) ok_cases = (["+100 {}".format(c) for c in term] + ["+100 {}".format(c) for c in term] + ["+{} 100".format(c) for c in term]) for c in ok_cases: message = make_mention(c) expected = parse_result.UpdateRequest("月AM", 100) self.assertEqual(service.recognize(message), expected)
def test_recognize_unknown(self): service = parse.ParseService(bot()) self.assertEqual(parse_result.UnknownRequest(), service.recognize(make_mention("excellent")))
def test_recognize_echo(self): service = parse.ParseService(bot()) self.assertEqual(parse_result.EchoRequest("echo"), service.recognize(make_mention("echo")))
def test_recognize_who(self): service = parse.ParseService(bot()) self.assertEqual(parse_result.WhoAmIRequest(), service.recognize(make_mention("who")))
def test_recognize_hist(self): service = parse.ParseService(bot()) self.assertEqual(service.recognize(make_mention("hist")), parse_result.HistoryRequest()) self.assertEqual(service.recognize(make_mention("history")), parse_result.HistoryRequest())