Example #1
0
 def test_format_spaces_commas(self):
     bot = JLPTBot()
     word = {
         u'hiragana': u'\u30c1\u30e3\u30f3\u30b9',
         u'english': u'chance,opportunity',
     }
     self.assertEqual(bot.format(word), u'\u30c1\u30e3\u30f3\u30b9\nchance, opportunity')
Example #2
0
def tweet(response, dry_run=True):
    bot = JLPTBot()
    msg = bot.format(bot.get_date_based_word())
    if not dry_run:
        bot.tweet(msg)
    response.headers['Content-Type'] = 'text/plain'
    response.write(msg)
Example #3
0
 def test_format_spaces_commas(self):
     bot = JLPTBot()
     word = {
         u'hiragana': u'\u30c1\u30e3\u30f3\u30b9',
         u'english': u'chance,opportunity',
     }
     self.assertEqual(bot.format(word),
                      u'\u30c1\u30e3\u30f3\u30b9\nchance, opportunity')
Example #4
0
 def test_format_kanji(self):
     bot = JLPTBot()
     word = {
         u'kanji': u'\u773a\u3081',
         u'hiragana': u'\u306a\u304c\u3081',
         u'english': u'scene,view,prospect,outlook',
     }
     self.assertEqual(bot.format(word), u'\u773a\u3081 - \u306a\u304c\u3081\nscene, view, prospect, outlook')
Example #5
0
    def test_returns_word_based_on_date(self):
        bot = JLPTBot()

        now = datetime.utcnow()
        baseline_time = datetime(2013, 12, 1, 0, 0, 0)
        days_since = (now - baseline_time).days
        expected = bot.words[days_since]

        actual = bot.get_date_based_word()
        self.assertEqual(actual, expected)
Example #6
0
    def test_returns_word_based_on_date(self):
        bot = JLPTBot()

        now = datetime.utcnow()
        baseline_time = datetime(2013, 12, 1, 0, 0, 0)
        days_since = (now - baseline_time).days
        expected = bot.words[days_since]

        actual = bot.get_date_based_word()
        self.assertEqual(actual, expected)
Example #7
0
 def test_format_kanji(self):
     bot = JLPTBot()
     word = {
         u'kanji': u'\u773a\u3081',
         u'hiragana': u'\u306a\u304c\u3081',
         u'english': u'scene,view,prospect,outlook',
     }
     self.assertEqual(
         bot.format(word),
         u'\u773a\u3081 - \u306a\u304c\u3081\nscene, view, prospect, outlook'
     )
Example #8
0
def tweet(response, dry_run=True):
    bot = JLPTBot()
    msg = bot.format(bot.get_date_based_word())
    if not dry_run:
        bot.tweet(msg)
    response.headers['Content-Type'] = 'text/plain'
    response.write(msg)
Example #9
0
 def test_word_list(self):
     bot = JLPTBot()
     self.assertEqual(len(bot.words), 1803)
Example #10
0
    def test_index_is_mod_word_list_length(self):
        bot = JLPTBot()

        expected = bot.words[200]
        actual = bot.get_date_based_word(index_override=len(bot.words) + 200)
        self.assertEqual(actual, expected)
Example #11
0
    def test_index_is_mod_word_list_length(self):
        bot = JLPTBot()

        expected = bot.words[200]
        actual = bot.get_date_based_word(index_override=len(bot.words) + 200)
        self.assertEqual(actual, expected)