def test_should_fail_i(mk_cli_anon: Misskey): with pytest.raises(MisskeyAPIException) as e: mk_cli_anon.i() assert type(e.value.code) == str assert type(e.value.message) == str assert type(e.value.id) == uuid.UUID or type(e.value.id) == str
def test_drive_folders( mk_cli_admin: Misskey, ): res_create = mk_cli_admin.drive_folders_create( name='test-folder', ) assert type(res_create) == dict res_show = mk_cli_admin.drive_folders_show( res_create['id'], ) assert type(res_show) == dict res_update = mk_cli_admin.drive_folders_update( folder_id=res_create['id'], name='renamed-folder', parent_id=None, ) assert type(res_update) == dict res_delete = mk_cli_admin.drive_folders_delete( res_create['id'], ) assert type(res_delete) == bool assert res_delete
def test_note_poll_expires_at( mk_cli_admin: Misskey, mk_cli_user: Misskey, ): res = mk_cli_admin.notes_create( text='poll test (expires_at)', poll_choices=[ 'test 1', 'test 2', ], poll_expires_at=( datetime.datetime.now() + datetime.timedelta(minutes=1) ), ) assert type(res) == dict vote_res = mk_cli_user.notes_polls_vote( res['createdNote']['id'], 0, ) assert type(vote_res) == bool assert vote_res is_deleted = mk_cli_admin.notes_delete(res['createdNote']['id']) assert type(is_deleted) == bool assert is_deleted
def test_should_fail_in_drives_files_create( mk_cli_anon: Misskey ): with pytest.raises(MisskeyAPIException): with open('tests/test_image.png', mode='rb') as f: mk_cli_anon.drive_files_create( f, )
def mk_admin_new_note(mk_cli_admin: Misskey): new_note = mk_cli_admin.notes_create(text='Unit test message') assert type(new_note) == dict yield new_note['createdNote']['id'] is_deleted = mk_cli_admin.notes_delete(new_note['createdNote']['id']) assert type(is_deleted) == bool assert is_deleted
def test_should_can_be_pin_and_unpin_note( mk_cli_admin: Misskey, mk_admin_new_note: str, ): res_pin = mk_cli_admin.i_pin(mk_admin_new_note) assert type(res_pin) == dict res_unpin = mk_cli_admin.i_unpin(mk_admin_new_note) assert type(res_unpin) == dict
def test_drive_stream( mk_cli_admin: Misskey, ): res_stream = mk_cli_admin.drive_stream() assert type(res_stream) == list res_files = mk_cli_admin.drive_files() assert type(res_files) == list res_folders = mk_cli_admin.drive_folders() assert type(res_folders) == list
def test_following( mk_cli_admin: Misskey, mk_user_id: str, ): res_follow = mk_cli_admin.following_create( mk_user_id, ) assert type(res_follow) == dict res_unfollow = mk_cli_admin.following_delete( mk_user_id, ) assert type(res_unfollow) == dict
def test_user_relation( mk_cli_admin: Misskey, mk_user_id: str, ): res_single = mk_cli_admin.users_relation( mk_user_id, ) assert type(res_single) == dict res_multiple = mk_cli_admin.users_relation( [mk_user_id], ) assert type(res_multiple) == list
def test_notes_watching( mk_cli_user: Misskey, mk_admin_new_note: str, ): res_watch = mk_cli_user.notes_watching_create( mk_admin_new_note, ) assert type(res_watch) == bool assert res_watch res_unwatch = mk_cli_user.notes_watching_delete( mk_admin_new_note, ) assert type(res_unwatch) == bool assert res_unwatch
def test_renote_note( mk_cli_admin: Misskey, mk_admin_new_note: str, ): res = mk_cli_admin.notes_create( renote_id=mk_admin_new_note, ) assert type(res) == dict res_unrenote = mk_cli_admin.notes_unrenote( mk_admin_new_note, ) assert type(res_unrenote) == bool assert res_unrenote
def test_favorite_note( mk_cli_admin: Misskey, mk_admin_new_note: str, ): res_favorite = mk_cli_admin.notes_favorites_create( mk_admin_new_note, ) assert type(res_favorite) == bool assert res_favorite res_unfav = mk_cli_admin.notes_favorites_delete( mk_admin_new_note, ) assert type(res_unfav) == bool assert res_unfav
def test_should_can_be_reaction_to_notes( mk_cli_user: Misskey, mk_admin_new_note: str, ): res_reaction = mk_cli_user.notes_reactions_create( mk_admin_new_note, '✅', ) assert type(res_reaction) == bool assert res_reaction res_del_reaction = mk_cli_user.notes_reactions_delete( mk_admin_new_note, ) assert type(res_del_reaction) == bool assert res_del_reaction
def test_users_followers( mk_cli_admin: Misskey, ): res = mk_cli_admin.users_followers( username='******' ) assert type(res) == list
def test_should_be_error_in_i_notifications( mk_cli_admin: Misskey, ): with pytest.raises(ValueError): mk_cli_admin.i_notifications( include_types=[ 'unknown_type' ] ) with pytest.raises(ValueError): mk_cli_admin.i_notifications( exclude_types=[ 'unknown_type' ] )
def test_blocking( mk_cli_admin: Misskey, mk_user_id: str, ): res_block = mk_cli_admin.blocking_create( mk_user_id, ) assert type(res_block) == dict res_block_list = mk_cli_admin.blocking_list() assert type(res_block_list) == list res_unblock = mk_cli_admin.blocking_delete( mk_user_id, ) assert type(res_unblock) == dict
def test_users_show( mk_cli_admin: Misskey, ): res = mk_cli_admin.users_show( username='******', ) assert type(res) == dict
def test_notes_children( mk_cli_admin: Misskey, mk_admin_new_note: str, ): res = mk_cli_admin.notes_children( mk_admin_new_note, ) assert type(res) == list
def test_notes_state( mk_cli_admin: Misskey, mk_admin_new_note: str, ): res = mk_cli_admin.notes_state( mk_admin_new_note, ) assert type(res) == dict
def test_users_stats( mk_cli_admin: Misskey, mk_admin_id: str, ): res = mk_cli_admin.users_stats( mk_admin_id, ) assert type(res) == dict
def test_mute( mk_cli_admin: Misskey, mk_user_id: str, ): res_mute = mk_cli_admin.mute_create( mk_user_id, ) assert type(res_mute) == bool assert res_mute res_mute_list = mk_cli_admin.mute_list() assert type(res_mute_list) == list res_unmute = mk_cli_admin.mute_delete( mk_user_id, ) assert type(res_unmute) == bool assert res_unmute
def test_should_ok_show_reactions( mk_cli_admin: Misskey, mk_admin_new_note: str, ): res = mk_cli_admin.notes_reactions( mk_admin_new_note, reaction_type='✅', ) assert type(res) == list
def test_i_notifications( mk_cli_admin: Misskey, ): res = mk_cli_admin.i_notifications( include_types={ NotificationsType.REACTION }, ) assert type(res) == list
def test_users_report_abuse( mk_cli_admin: Misskey, mk_user_id: str, ): res = mk_cli_admin.users_report_abuse( user_id=mk_user_id, comment='this is test report abuse', ) assert type(res) == bool assert res
def test_i_update( mk_cli_admin: Misskey, ): res = mk_cli_admin.i_update( name='Unit test user admin', birthday=datetime.date.today(), lang='ja-JP', muting_notification_types=[ 'app', ], ) assert type(res) == dict
def test_notes_global_timeline( mk_cli_admin: Misskey, ): timeline_global = mk_cli_admin.notes_global_timeline( since_date=( datetime.datetime.now() - datetime.timedelta(days=1) ), until_date=( datetime.datetime.now() + datetime.timedelta(hours=3) ) ) assert type(timeline_global) == list
def test_user_notes( mk_cli_admin: Misskey, mk_admin_id: str, ): res = mk_cli_admin.users_notes( mk_admin_id, since_date=( datetime.datetime.now() - datetime.timedelta(days=1) ), until_date=( datetime.datetime.now() ), ) assert type(res) == list
def test_drive_files( mk_cli_admin: Misskey ): with open('tests/test_image.png', mode='rb') as f: res_create = mk_cli_admin.drive_files_create( f, ) assert type(res_create) == dict res_file_check = mk_cli_admin.drive_files_check_existence( res_create['md5'], ) assert type(res_file_check) == bool assert res_file_check res_find_hash = mk_cli_admin.drive_files_find_by_hash( res_create['md5'], ) assert type(res_find_hash) == list res_attached_notes = mk_cli_admin.drive_files_attached_notes( res_create['id'], ) assert type(res_attached_notes) == list res_files_show = mk_cli_admin.drive_files_show( res_create['id'], ) assert type(res_files_show) == dict res_files_update = mk_cli_admin.drive_files_update( res_create['id'], folder_id=None, comment='test file', ) assert type(res_files_update) == dict res_delete = mk_cli_admin.drive_files_delete( res_create['id'], ) assert type(res_delete) == bool assert res_delete
def test_users_lists( mk_cli_admin: Misskey, mk_user_id: str, ): res_create = mk_cli_admin.users_lists_create( 'test-list', ) assert type(res_create) == dict res_show = mk_cli_admin.users_lists_show( res_create['id'], ) assert type(res_show) == dict res_list = mk_cli_admin.users_lists_list() assert type(res_list) == list res_push = mk_cli_admin.users_lists_push( list_id=res_create['id'], user_id=mk_user_id, ) assert type(res_push) == bool assert res_push res_pull = mk_cli_admin.users_lists_pull( list_id=res_create['id'], user_id=mk_user_id, ) assert type(res_pull) == bool assert res_pull res_update = mk_cli_admin.users_lists_update( list_id=res_create['id'], name='test-list-renamed', ) assert type(res_update) == dict res_delete = mk_cli_admin.users_lists_delete( res_create['id'], ) assert type(res_delete) == bool assert res_delete
print("Misskey X61 RSS Bot initialized") config = json_read("config.json") rules = json_read("rules.json") for key in rules: spider(key, rules[key]['rss_source']) name = rules[key]['identity'] Misskey.baseurl = config[name]['url'] c = conn.cursor() r = c.execute('''SELECT * FROM "main"."result" WHERE "rule_name" = ? AND "post_time" = '0' ORDER BY "rid" DESC''', (key,)).fetchone() if not(r is None): res = c.execute('UPDATE "main"."result" SET "post_time" = ? WHERE rowid = ?', (time.time(), r[0])) if not (res is None): reg = re.compile('<[^>]*>') desc = reg.sub('', r[4]).replace(' ', '').replace('\n\n\n', '\n') content = "**"+r[3]+"**\n\n"+desc+"\n<"+r[2]+">\n"+rules[key]['extra_content'] if Misskey.debug: config[name]['visibility'] = "specified" Misskey.post(self=Misskey, content=content, i=config[name]['token'], visibility=config[name]['visibility']) conn.commit() conn.close() time_end = time.time() print("X61 bot: done in", time_end - time_start, "s")