def test_buildConnectionTable(self): journal = [ '2018-01-01 this is a journal entry with +WTF as label and @Testing as context', '2018-01-01 this is a journal entry with +WTFF as label and @NotTesting as context' ] journal_list = [] for entry in journal: new_obj = Todo.Todo(entry) journal_list.append(new_obj) info = [ '2018-01-01 this is a info entry with +WTF as label and @Testing as context', '2018-01-01 this is a info entry with +WTFF as label and @NotTesting as context' ] info_list = [] for entry in info: new_obj = Todo.Todo(entry) info_list.append(new_obj) # fetch all todos with context Testing result_context = helpers.listByContext(todo_list, "Testing") # connect those todos with content from info and journal # must have 3 elements connected_contexts = helpers.buildConnectionTable( result_context, "@Testing", journal_list, info_list) self.assertEqual(len(connected_contexts), 3) # fetch all todos with label WTF result_label = helpers.listByLabel(todo_list, "WTF") # connect / enrich those todos with content from info and journal connected_labels = helpers.buildConnectionTable( result_label, "+WTF", journal_list, info_list) self.assertEqual(len(connected_labels), 3)
def test_resolvedWithinDays(self): resolvedDate1 = datetime.date.today() - datetime.timedelta(3) resolvedDate2 = datetime.date.today() - datetime.timedelta(4) todo_list.append( Todo.Todo( "x " + str(resolvedDate1) + " (C) 2018-08-01 {0} this has urgency zero $$s due:2020-01-01") ) todo_list.append( Todo.Todo( "x " + str(resolvedDate2) + " (C) 2018-08-01 {0} this has urgency zero $$s due:2020-01-01") ) resolved_todos = resolvedWithinDays(1, todo_list) self.assertEqual(len(resolved_todos), 0) resolved_todos = resolvedWithinDays(2, todo_list) self.assertEqual(len(resolved_todos), 0) resolved_todos = resolvedWithinDays(3, todo_list) self.assertEqual(len(resolved_todos), 1) resolved_todos = resolvedWithinDays(4, todo_list) self.assertEqual(len(resolved_todos), 2)
def test_listCommands(self): import tdt # resetting and refilling todolist to improve testability todo_list.append( Todo.Todo( "(A) {0} this is the second @Testing [email protected] context")) # testing contexts # --------------------------------------------------------------- context_dict = tdt.listAllContexts(todo_list) self.assertIsInstance(context_dict, dict) self.assertDictEqual(context_dict, {'@Testing': 2, '@Context': 1}) # testing query u=0 p=a s=o # --------------------------------------------------------------- myQuery = Classes.Query("u=1 p=a s=o") filtered_list = tdt.byManualQuery(myQuery, todo_list) self.assertTrue(len(filtered_list), 1) # eisenhower # --------------------------------------------------------------- todo_list.append( Todo.Todo( "(F) {3} eisenhower this is the second @Testing [email protected] context" )) table_obj = tdt.eisenhower(todo_list, True) self.assertEqual( table_obj._rows[1][3], " - ".join( [str(todo_list[0].ID), todo_list[0].description[0:60].strip()])) # list by prio (lp) # --------------------------------------------------------------- prio = "Z" todos_filtered = helpers.listByPrio(prio, todo_list) self.assertEqual(todos_filtered[0].priority, "(Z)") self.assertEqual(len(todos_filtered), 1)
def setUp(self): global todo_list rawTodo1 = "(A) 2021-01-01 this is a dummy todo following the proposed structure {1} +WTF . and now i'm adding a whole lot of more text to be able to teest lenght assertions later on (182 chars)" rawTodo2 = "(B) 2019-01-02 01-01-2020 and this one is a f*****g mess {2}1 +testing and this @Context" rawTodo3 = "(Z) 2022-01-03 this is a + sign that should not be added to label list. {3} neither should [email protected], @Testing" todo_list.append(Todo.Todo(rawTodo1)) todo_list.append(Todo.Todo(rawTodo2)) todo_list.append(Todo.Todo(rawTodo3))
def list_todos(): todos = Todo.list() div = '<div><a href="/todo/{id}">{title}</a></div>' form = '''<form method="POST" action="add"> <input name="todo_id" placeholder="Add todo..."/> </form> ''' items = [div.format(id=t.id, title=t.title) for t in todos] items.append(form) return '\n'.join(items)
def test_datesaredatesinTodo(self): todo_list.append( Todo.Todo( "x 2018-01-01 (C) 2018-08-01 {0} this has urgency zero $$s due:2020-01-01" )) self.assertIsInstance(getattr(todo_list[3], 'createDate'), datetime.date) self.assertIsInstance(getattr(todo_list[3], 'finishDate'), datetime.date) self.assertIsInstance(getattr(todo_list[3], 'dueDate'), datetime.date)
def test_sortingTodosByProperies(self): # recreating todos to make the sorting more relevant todo_list = [] todo_list.append( Todo.Todo("(C) 2018-08-01 {0} this has urgency zero $$s")) todo_list.append( Todo.Todo("(A) 2018-08-01 {0} this has urgency zero $$xs")) todo_list.append( Todo.Todo("(A) 2018-09-01 {1} this has urgency one $$m")) todo_list.append( Todo.Todo("(A) 2018-08-01 {2} this has urgency two $$xl")) todo_list.append( Todo.Todo("(B) 2018-07-01 {2} this has urgency two $$xxl")) todo_list.append( Todo.Todo("(A) 2018-07-01 {2} this has urgency two $$l")) """ sorting by (order) urgency, prio, createDate must yield (A) 2018-08-01 {0} this has urgency zero $$xs (C) 2018-08-01 {0} this has urgency zero $$s (A) 2018-09-01 {1} this has urgency one $$m (A) 2018-07-01 {2} this has urgency two $$l (A) 2018-08-01 {2} this has urgency two $$xl (B) 2018-07-01 {2} this has urgency two $$xxl to check, i'm abusing the size property (xs-xxl) """ # this is the 'natural' way of prioritising the sort order. must be reversed in the function sortTodos sorted_list = helpers.sortTodos(todo_list, 'urgency', 'priority', 'createDate') sorted_sizes = [] for todo in sorted_list: sorted_sizes.append(todo.size) self.assertListEqual(sorted_sizes, ["XS", "S", "M", "L", "XL", "XXL"])
def test_addedWithinDays(self): addedDate1 = datetime.date.today() - datetime.timedelta(3) addedDate2 = datetime.date.today() - datetime.timedelta(4) todo_list.append( Todo.Todo("(C) " + str(addedDate1) + " {0} this has urgency zero $$s due:2020-01-01")) todo_list.append( Todo.Todo("(C) " + str(addedDate2) + " {0} this has urgency zero $$s due:2020-01-01")) added_todos = addedWithinDays(1, todo_list) self.assertEqual(len(added_todos), 0) added_todos = addedWithinDays(2, todo_list) self.assertEqual(len(added_todos), 0) added_todos = addedWithinDays(3, todo_list) self.assertEqual(len(added_todos), 1) added_todos = addedWithinDays(4, todo_list) self.assertEqual(len(added_todos), 2)
def addTodo(todo_list): global config log.debug("in function addTodo()") rawline = addTodo_CollectContent() log.info("now building new ToDo") new_todo = "" confirm_todo = input("do you want to save\n\n " + rawline + "\ny/n?\n") if confirm_todo == 'y': try: log.info("adding '" + rawline + "' to list") new_todo = Todo.Todo(rawline) # not appending yet, but rebuilding existing todos from a fresh copy from the file todo.txt # in order to prevent overwrting changes made manually to the file #todo_list.append(new_todo) except Exception as e: log.critical("was not able to build todo") print(e) pass try: print("saving to file %s....\n" % config.todotxt) log.info("rebuilding todo list from: %s" % config.todotxt) todo_list = tdt.buildIt(config.todotxt, "Todos") log.info("appending new todo") todo_list.append(new_todo) log.info("sorting new todo list") todo_list = sortTodos(todo_list, False, "status", "urgency", "priority") log.info("saving new todo list") tdt.save_state(todo_list) return todo_list except Exception as e: log.error("something went wrong while saving file") print("ERROR: " + str(e)) log.critical("ToDo: add verification to individual entries") else: print("aborting...")
from flask import * from Todo import * todo = Todo() app = Flask(__name__) @app.route('/hello') def hello(): return 'hello world' @app.route('/') def list(): return render_template('index.html', todoList=todo.getAllToto()) @app.route('/delete') def delete(): task = request.args.get('todo', '') todo.removeTodo(task) return render_template('index.html', todoList=todo.getAllToto()) @app.route('/insert', methods=['POST']) def insert(): task = request.form['todo'] todo.addTodo(task) return render_template('index.html', todoList=todo.getAllToto())
def create(self, s): todo = Todo() todo.desc = s self.items.append(todo)
def add_todo(): todo_id = request.form['todo_id'] if todo_id: Todo.add(todo_id) return redirect('/todo/')
def show_todo(todo_id): todo = Todo.get_id(todo_id) fmt = '<h1>Todo {todo_id}</h1><p>{title}</p>' return fmt.format(todo_id=todo.id, title=todo.title)
import random from flask import url_for import pytest from {{cookiecutter.project_slug}} import db from {{cookiecutter.project_slug}}.todo.models import Todo todos = ( Todo(content='write some tests', is_done=False), Todo(content='integrate swagger ui', is_done=False), Todo(content='convert to cookiecutter', is_done=False), Todo(content='implement a basic api', is_done=True), Todo(content='integrate webpack assets', is_done=True), ) def setup_module(module): for todo in todos: db.session.add(todo) db.session.commit() def teardown_module(module): for todo in todos: db.session.delete(todo) db.session.commit()
def __init__(self): self.c_todo = Todo.Todo() self.c_alias = Todo.Todo(1) self.c_cook = cook.Cook()
print("Belirtmek istemediğiniz değerleri boş geçin.") gorev = input("Todoya yazmak istediğiniz: ") if gorev == "": print("Bu alan boş bırakılamaz!") continue kategori = input("Kategori: ") gun = input("Gün: ") yer = input("Yer: ") saat = input("Saat") liste2 = [gorev, kategori, gun, yer, saat] for i in range(0, len(liste2)): if liste2[i] == "": liste2[i] = "Belirtilmedi!" todo = Todo(liste2[0], liste2[1], liste2[2], liste2[3], liste2[4]) liste.todo_ekle(todo) elif choice == "3": try: id = int(input("Tamamladığınız todo id'si: ")) except ValueError: print("Sadece id değeri!") continue liste.tamamla(id) time.sleep(2) elif choice == "4": gun = input("Aranacak gün: ") liste.gune_gore(gun) time.sleep(5) elif choice == "5": kategori = input("Aranacak kategori: ")