Пример #1
0
  def test_subsequent_update_triggers_version_deletion(self):
    library_key = Library(id='org/repo', spdx_identifier='MIT', tag_map='{"v1.0.0":"old","v2.0.0":"old"}').put()
    Version(id='v0.1.0', parent=library_key, sha="old", status=Status.ready).put()
    Version(id='v1.0.0', parent=library_key, sha="old", status=Status.ready).put()
    Version(id='v2.0.0', parent=library_key, sha="old", status=Status.ready).put()
    VersionCache.update(library_key)

    self.respond_to_github('https://api.github.com/repos/org/repo', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/contributors', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/tags', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/stats/participation', '{}')

    response = self.app.get(util.update_library_task('org/repo'), headers={'X-AppEngine-QueueName': 'default'})
    self.assertEqual(response.status_int, 200)

    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual([
        util.delete_task('org', 'repo', 'v0.1.0'),
    ], [task.url for task in tasks])
Пример #2
0
  def test_subsequent_update_triggers_version_deletion(self):
    library_key = Library(id='org/repo', spdx_identifier='MIT', tag_map='{"v1.0.0":"old","v2.0.0":"old"}').put()
    Version(id='v0.1.0', parent=library_key, sha="old", status=Status.ready).put()
    Version(id='v1.0.0', parent=library_key, sha="old", status=Status.ready).put()
    Version(id='v2.0.0', parent=library_key, sha="old", status=Status.ready).put()
    VersionCache.update(library_key)

    self.respond_to_github('https://api.github.com/repos/org/repo', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/contributors', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/tags', {'status': 304})
    self.respond_to_github('https://api.github.com/repos/org/repo/stats/participation', '{}')

    response = self.app.get(util.update_library_task('org/repo'), headers={'X-AppEngine-QueueName': 'default'})
    self.assertEqual(response.status_int, 200)

    tasks = self.tasks.get_filtered_tasks()
    self.assertEqual([
        util.delete_task('org', 'repo', 'v0.1.0'),
    ], [task.url for task in tasks])
Пример #3
0
 def trigger_version_deletion(self, tag):
   task_url = util.delete_task(self.owner, self.repo, tag)
   util.new_task(task_url, target='manage', transactional=True)
Пример #4
0
def task_edit(call):
    bot.delete_message(call.from_user.id, call.message.message_id)
    res = call.data.split('_')
    task_id = res[2]
    print(res[1])
    if res[1] == 'view':
        task = util.get_task_by_id(task_id)
        bot.send_message(call.from_user.id,
                         create_task_text(task),
                         reply_markup=mark_conf.task_menu(task),
                         parse_mode='HTML')
        return
    elif res[1] == 'tittle':
        msg = bot.send_message(call.from_user.id,
                               'Новый заголовок',
                               reply_markup=mark_conf.create_custom_button(
                                   button_text['cancel']))
        bot.register_next_step_handler(msg, change_task_name)
        global message_id
        message_id = task_id
        return
    elif res[1] == 'search':
        bot.send_message(call.from_user.id,
                         msg_text['input_task_name'],
                         reply_markup=mark_conf.create_custom_button(
                             button_text['cancel']))
        return
    elif res[1] == 'tags':
        # Удаляем словарь. если он уже существоватл
        if call.from_user.id in TASK_TAGS:
            del TASK_TAGS[call.from_user.id]

        TASK_TAGS[call.from_user.id] = {}
        TASK_TAGS[call.from_user.id]['task_id'] = task_id
        TASK_TAGS[call.from_user.id]['tag_list'] = []
        TASK_TAGS[call.from_user.id]['selected_tags'] = []

        # Создаем меню и словарь и создае меню тегов
        inline_key = telebot.types.InlineKeyboardMarkup()
        for tag in util.get_user_tags(call.from_user.id, task_id=task_id):
            TASK_TAGS[call.from_user.id]['tag_list'].append(tag)

            if tag['status']:
                TASK_TAGS[call.from_user.id]['selected_tags'].append({
                    'id':
                    tag['id'],
                    'name':
                    tag['name']
                })
                button_name = '✅ ' + tag['name']
            else:
                button_name = tag['name']

            inline_btn = telebot.types.InlineKeyboardButton(
                text=button_name,
                callback_data=inline_conf.tag + 'choise_' + str(tag['id']))
            inline_key.add(inline_btn)
        bot.send_message(call.from_user.id,
                         'Выберите теги:',
                         reply_markup=inline_key)

        custom_key = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True)
        custom_key.row(button_text['closed'], button_text['cancel'])
        bot.clear_step_handler(call.message)
        msg = bot.send_message(
            call.from_user.id,
            'После выбора нужных пунктов нажмите на кнопку <b>Готово ✅</b>.',
            parse_mode='HTML',
            reply_markup=custom_key)
        bot.register_next_step_handler(msg, tag_data)
        return
    elif res[1] == 'favorite':
        task = util.update_favorite_task(util.get_task_by_id(task_id))
        bot.send_message(call.from_user.id,
                         create_task_text(task),
                         reply_markup=mark_conf.task_menu(task),
                         parse_mode='HTML')
        return
    elif res[1] == 'closed':
        util.change_active_task(task_id)
        bot.send_message(call.from_user.id, 'Задача перемещена в 🗄 Архив')
    elif res[1] == 'activate':
        util.change_active_task(task_id, activate=1)
        bot.send_message(call.from_user.id, 'Задача перемещена в ✅ Активные')

        task = util.get_task_by_id(task_id)
        bot.send_message(call.from_user.id,
                         create_task_text(task),
                         reply_markup=mark_conf.task_menu(task),
                         parse_mode='HTML')
        return
    elif res[1] == 'delete':
        util.delete_task(task_id)
        bot.send_message(call.from_user.id, 'Напоминалка удалено ;)')

    elif res[1] == 'invite':
        # TODO доделать интеграцию с гугл диском или др. сервисами
        return
    elif res[1] == 'back':
        bot.send_message(call.from_user.id,
                         msg_text['back'],
                         parse_mode='HTML')
        return
    # По окончанию действий выводим список активных тасков для дальнейшей работы с ними
    task_list = util.get_task_list_by_user(call.from_user.id, not_closed=True)
    if task_list:
        bot.send_message(call.from_user.id,
                         msg_text['chose_task'],
                         reply_markup=mark_conf.task_list_menu(task_list))
    else:
        bot.send_message(call.from_user.id,
                         msg_text['task_not_found'],
                         reply_markup=mark_conf.menu())
Пример #5
0
 def trigger_version_deletion(self, tag):
     task_url = util.delete_task(self.owner, self.repo, tag)
     util.new_task(task_url, target='manage', transactional=True)