def date_range(): start_date = functions.edit("start date", "Lookup tasks by date range.", "date", True, datetime.date.today()) end_date = functions.edit("end date", "Lookup tasks by date range.", "date", True, datetime.date.today()) display_tasks(db.Task.select().where( db.Task.date.between(start_date, end_date)))
def new_task(self): """Create a new task.""" self.header_line = "Add new task." task_name = functions.edit("name", self.header_line) user_name = functions.edit("user name", self.header_line) minutes = functions.edit("minutes", self.header_line, "number") notes = functions.edit("notes", self.header_line, "text", False) date = datetime.date.today().strftime('%Y-%m-%d') # Save return db.save( dict([('task_name', task_name), ('user_name', user_name), ('minutes', minutes), ('notes', notes), ('date', date)]))
def edit_message(message): bad_words = check_bad_words(message.text.lower()) if bad_words == '': edit(message) bot.send_message(message.chat.id, "Успешно отредактировано!", reply_markup=markups.markup) else: bot.send_message( message.chat.id, f"Ваше сообщение содержит недопустимые слово(-а) ({bad_words}) и не было " f"изменено.") go_back(message)
def test_user_input_required(self): fake_input = mock.Mock(side_effect=['', 'Test Text']) with patch('sys.stdout', new=StringIO()) as fake_out: with patch('builtins.input', fake_input): test_case = functions.edit("Input Title", "Header Text") self.assertEqual(fake_input.call_count, 2) self.assertIn('cannot be empty', fake_out.getvalue())
def test_user_input_number(self): fake_input = mock.Mock(side_effect=['fred', '3']) with patch('sys.stdout', new=StringIO()) as fake_out: with patch('builtins.input', fake_input): test_case = functions.edit("Input Title", "Header Text", "number") self.assertEqual(fake_input.call_count, 2) self.assertIn('must be a number', fake_out.getvalue())
def test_user_input_date(self): fake_input = mock.Mock( side_effect=['fred', '3', '1234-56-78', '2014-01-01']) with patch('sys.stdout', new=StringIO()) as fake_out: with patch('builtins.input', fake_input): test_case = functions.edit("Input Title", "Header Text", "date") self.assertEqual(fake_input.call_count, 4) self.assertIn('Invalid date', fake_out.getvalue())
def edit_task(self): """Edit an existing task.""" self.header_line = ("Edit existing task: {}.".format( self.task.task_name)) self.task.date = functions.edit("date", self.header_line, "date", True, str(self.task.date)) self.task.task_name = functions.edit("task name", self.header_line, "text", True, str(self.task.task_name)) self.task.user_name = functions.edit("user name", self.header_line, "text", True, str(self.task.user_name)) self.task.minutes = functions.edit("minutes", self.header_line, "number", True, str(self.task.minutes)) self.task.notes = functions.edit("notes", self.header_line, "text", False, str(self.task.notes)) # Confirm screen self.view_task() if (input("Confirm the above task is correct to save Y/n: ").strip(). lower() != "n"): self.task.save()
elif opcionMenu == "2": functions.showAll() elif opcionMenu == "3": search_service = input( "\nOk, introduce the name of the service : ") functions.search(search_service) elif opcionMenu == "4": id_edit = int( input( "\nIntroduce the id of the user/password you want to edit : " )) user_edit = input("Introduce the new username : "******"Introduce the new password : "******"5": id_remove = int( input( "\nOk, introduce the id of the password you want to remove : " )) functions.removePassword(id_remove) elif opcionMenu == "9": print("\nHope to see you soon!") break else: print("") input( "That option is not correct. Please enter a correct option: ")
print("\033[1;33mOlá! Bem-vindo ao Header!\033[0;0m") print("\033[1;32mStatus do Header: iniciado\033[0;0m" if status == True else "\033[1;31mStatus do Header: não iniciado\033[0;0m") print("\033[1;32mPara obter ajuda no uso da ferramenta, digite:\033[0;0m") print("python3 header.py help") else: arg.pop(0) if status and arg[0].lower() == "w": print(functions.write(arg)) elif status and arg[0].lower() == "ws": print(functions.write_save(arg, directory)) elif status and arg[0].lower() == "s": print(functions.save(arg, directory)) elif status and arg[0].lower() == "c": print(functions.create(arg, directory)) elif not status and arg[0].lower() == "init": print(functions.init(directory)) elif status and arg[0].lower() == "init": print("Seu Header já foi iniciado!") elif status and arg[0].lower() == "list": functions.list_ws(directory) elif status and arg[0].lower() == "e": print(functions.edit(arg, directory)) elif status and arg[0].lower() == "d": print(functions.delete(arg, directory)) elif arg[0].lower() == "help": help("header") config.close()
def test_user_input_not_required(self): with patch('sys.stdout', new=StringIO()) as fake_out: test_case = functions.edit("Input Title", "Header Text", "number", False, '123456') self.assertEqual(test_case, '123456')