Ejemplo n.º 1
0
def create_tasks(update, context):
    task = context.user_data["taskType"]
    description = update.message.text
    context.user_data["description"] = description
    # Redirect to another state specially for Habits
    if task == "habit":
        reply_keyboard = [["positive", "negative"]]
        update.message.reply_text(
            "What kind of habit is it?",
            reply_markup=ReplyKeyboardMarkup(reply_keyboard,
                                             one_time_keyboard=True),
        )
        return TASK_CREATE_HABIT
    else:
        title = context.user_data["title"]
        result = api.create_task(title, task, description)
    # Process the results:
    if result and result["success"] == True:
        create_success(update, result)
    elif result["success"] == False:
        update.message.reply_markdown(
            "Please *login* using /start to continue.",
            reply_markup=ReplyKeyboardRemove(),
        )
    else:
        update.message.reply_markdown("*Error* creating {}".format(task))

    return ConversationHandler.END
Ejemplo n.º 2
0
Archivo: main.py Proyecto: edrijver/sps
 def post(self):
     try:
         domain = self.request.get('domain')
         description = self.request.get('description')
         parent_identifier = self.request.get('parent', "")
         if not description:
             raise ValueError("Empty description")
         # The checkbox will return 'on' if checked and None
         # otherwise.
         self_assign = bool(self.request.get('assign_to_self'))
     except (TypeError, ValueError):
         self.error(400)
         return
     user = api.get_and_validate_user(domain)
     if not user:
         self.error(401)
         return
     self.session = Session(writer='cookie',
                            wsgiref_headers=self.response.headers)
     assignee = user if self_assign else None
     if not parent_identifier:
         parent_identifier = None
     task = api.create_task(domain,
                            user,
                            description,
                            assignee=assignee,
                            parent_task=parent_identifier)
     add_message(self.session, "Task '%s' created" % task.title())
     if parent_identifier:
         self.redirect('/d/%s/task/%s' % (domain, parent_identifier))
     else:
         self.redirect('/d/%s/' % domain)
Ejemplo n.º 3
0
Archivo: main.py Proyecto: troberti/sps
 def post(self):
     try:
         domain = self.request.get('domain')
         description = self.request.get('description')
         parent_identifier = self.request.get('parent', "")
         if not description:
             raise ValueError("Empty description")
         # The checkbox will return 'on' if checked and None
         # otherwise.
         self_assign = bool(self.request.get('assign_to_self'))
     except (TypeError, ValueError):
         self.error(400)
         return
     user = api.get_and_validate_user(domain)
     if not user:
         self.error(401)
         return
     self.session = Session(writer='cookie',
                            wsgiref_headers=self.response.headers)
     assignee = user if self_assign else None
     if not parent_identifier:
         parent_identifier = None
     task = api.create_task(domain,
                            user,
                            description,
                            assignee=assignee,
                            parent_task_identifier=parent_identifier)
     add_message(self.session, "Task '%s' created" % task.title())
     if parent_identifier:
         self.redirect('/d/%s/task/%s' % (domain, parent_identifier))
     else:
         self.redirect('/d/%s/' % domain)
Ejemplo n.º 4
0
def create_tasks_habit(update, context):
    # title - Task name
    # description - Task description / detail
    # direction - Unique for Habits (Positive / Negative)
    title = context.user_data["title"]
    description = context.user_data["description"]
    direction = update.message.text
    if direction == "positive":
        result = api.create_task(title, "habit", description, "up")
    else:
        result = api.create_task(title, "habit", description, "down")
    # Process results:
    if result and result["success"] == True:
        create_success(update, result)
    elif result["success"] == False:
        update.message.reply_markdown(
            "Please *login* using /start to continue.",
            reply_markup=ReplyKeyboardRemove(),
        )
    else:
        update.message.reply_markdown("*Error* creating habit",
                                      reply_markup=ReplyKeyboardRemove())

    return ConversationHandler.END
Ejemplo n.º 5
0
def test_create_task_202_status_code():
    create_task(check_code=202)
Ejemplo n.º 6
0
def test_task_processing():
    task = create_task(check_code=202)
    print('статус должэен быть Running')
    assert get_task_status(task.json(), check_code=200).json() == 'running'
    sleep(121)
    assert get_task_status(task.json(), check_code=200).json() == 'finished'
Ejemplo n.º 7
0
def test_get_task_202_status_code():
    task = create_task(check_code=202)
    get_task_status(task.json(), check_code=200)