示例#1
0
 def test_toot_ranking(self):
     rt.toot_ranking(rotated_just = pd.DataFrame({
         "username":['akyu','kosuzu','reimu', 'marisa'],
         "display_name":['阿求','小鈴','霊夢', '魔理沙'],
         "created_at":[time(17,30,0,0), time(17,30,1,0), time(17,30,1,0), time(17,30,2,0)]
     }))
     rt.mastodon.status_post.assert_called_once_with(status = '1位: 阿求 @akyu [02:30:00]\n2位: 小鈴 @kosuzu [02:30:01]\n2位: 霊夢 @reimu [02:30:01]\n4位: 魔理沙 @marisa [02:30:02]\n', visibility='unlisted')
示例#2
0
    def test_select_toots(self):
        toots = [
# positive
            { 'id': 10, 'created_at': datetime(2017, 11, 4, 17, 29, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '霊夢', } },
            { 'id': 11, 'created_at': datetime(2017, 11, 4, 17, 30, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '魔理沙', } },
# negative
            { 'id': 12, 'created_at': datetime(2017, 11, 4, 17, 31, 0, 0, UTC), 'content': 'コスズ', 'account': { 'username': '******', 'display_name': '小鈴', } },
        ]
        results = rt.select_toots(toots)
        self.assertEqual(['reimu','marisa'], list(results['username']))
        self.assertEqual(['霊夢','魔理沙'], list(results['display_name']))
示例#3
0
    def test_get_timeline(self):
        rt.mastodon.timeline.side_effect = [
 # timeline取得 1回目
            [
                { 'id': 12, 'created_at': datetime(2017, 11, 4, 17, 30, 0, 0, UTC), 'content': 'コスズ', 'account': { 'username': '******', 'display_name': '小鈴', } },
                { 'id': 11, 'created_at': datetime(2017, 11, 4, 17, 30, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '魔理沙', } },
                { 'id': 10, 'created_at': datetime(2017, 11, 4, 17, 29, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '霊夢', } }
            ],
# timeline取得 2回目
            [
                { 'id': 9, 'created_at': datetime(2017, 11, 4, 17, 29, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '早苗', } },
                { 'id': 8, 'created_at': datetime(2017, 11, 4, 17, 28, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '咲夜', } },
            ],
# timeline取得 3回目。実際には呼ばれない
            [
                { 'id': 7, 'created_at': datetime(2017, 11, 4, 17, 28, 0, 0, UTC), 'content': 'ズズズ', 'account': { 'username': '******', 'display_name': '阿求', } },
            ],
        ]
        results = rt.get_timeline('local')
# 取得したTLの検証。
        self.assertEqual(['咲夜', '霊夢', '早苗', '小鈴', '魔理沙'], [x['account']['display_name'] for x in results])
# mastodon APIの呼び出し回数検証
        self.assertEqual(2, len(rt.mastodon.timeline.mock_calls))
示例#4
0
 def test_toot_number_rotated_early_participation(self):
     rt.toot_number_rotated(6, 1, 0)
     rt.mastodon.status_post.assert_called_once_with(status = TODAY_STR + 'の墓石の回転は6人による1と2分の1回転です。\n'
                                                     + 'また、2時30分になる前に回した人は1人です。\n'
                                                     + '今日までの回転の合計数は12回転です。')
示例#5
0
 def test_toot_number_rotated_1_participation(self):
     rt.toot_number_rotated(1, 0, 0)
     rt.mastodon.status_post.assert_called_once_with(status = TODAY_STR + 'の墓石の回転は1人による4分の1回転です。\n'
                                                     + '今日までの回転の合計数は10と4分の3回転です。')
示例#6
0
 def test_toot_number_rotated_no_participation(self):
     rt.toot_number_rotated(0, 0, 0)
     rt.mastodon.status_post.assert_called_once_with(status = TODAY_STR + 'の墓石は回転しませんでした。\n'
                                                     + '今日までの回転の合計数は10と2分の1回転です。')
示例#7
0
 def test_count_rotation_6_participations(self):
     toot = rt.count_rotation(6)
     self.assertEqual('1と2分の1回転です。', toot)
示例#8
0
 def test_count_rotation_4_participations(self):
     toot = rt.count_rotation(4)
     self.assertEqual('1回転です。', toot)
示例#9
0
 def test_count_rotation_1_participation(self):
     toot = rt.count_rotation(1)
     self.assertEqual('4分の1回転です。', toot)
示例#10
0
 def test_count_rotation_no_participation(self):
     toot = rt.count_rotation(0)
     self.assertEqual('0回転です。', toot)
示例#11
0
 def test_toot_number_rotated_multi_turn(self):
     rt.toot_number_rotated(6, 0, 1)
     rt.mastodon.status_post.assert_called_once_with(status = TODAY_STR + 'の墓石の回転は6人による1と2分の1回転です。2度以上回した人は1人です。\n'
                                                     + '今日までの回転の合計数は12回転です。')