Пример #1
0
 def test_TodoList_completes_a_message(self):
     """A completed message gets removed."""
     todolist = TodoList(self.mock_persister)
     todolist.add("New message")
     ret_string = "Completed #1 New message"
     self.assertEqual(todolist.do("1"), ret_string)
     self.assertEqual(0, len(self.mock_persister.tasks))
Пример #2
0
 def test_TodoList_adds_single_message(self):
     """A new message gets added to the list of tasks."""
     todolist = TodoList(self.mock_persister)
     ret_string = "#1 New message"
     self.assertEqual(todolist.add("New message"), ret_string)
     actual_task = self.mock_persister.tasks[0]
     self.assertEqual(actual_task.text, "New message")
     self.assertEqual(actual_task.id, 1)
Пример #3
0
 def test_TodoList_adds_unique_id_after_several_adds_and_a_do(self):
     """Can add several, one do and still have unique number."""
     todolist = TodoList(self.mock_persister)
     todolist.add("One")
     todolist.add("Two")
     todolist.add("Three")
     todolist.do("2")
     todolist.add("This message should have ID: 4")
     self.assertEqual(todolist.next_id, 5)
Пример #4
0
 def test_TodoList_add_then_complete(self):
     todolist = TodoList(self.mock_persister)
     after_add = "#1 New message"
     self.assertEqual(todolist.add("New message"), after_add)
     actual_task = self.mock_persister.tasks[0]
     self.assertEqual(actual_task.text, "New message")
     self.assertEqual(actual_task.id, 1)
     after_do = "Completed #1 New message"
     self.assertEqual(1, len(self.mock_persister.tasks))
     self.assertEqual(todolist.do("1"), after_do)
     self.assertEqual(0, len(self.mock_persister.tasks))
Пример #5
0
 def test_TodoList_has_correct_length(self):
     """Make sure __len__ is implemented."""
     todolist = TodoList(self.mock_persister)
     todolist.add("One")
     todolist.add("Two")
     todolist.add("Three")
     self.assertEqual(len(todolist), 3)
def test_add():
    tl = TodoList("test.db")
    tl.add("Blah")
    assert "Blah" in tl
def test_add_persist_2():
    tl = TodoList("test.db")
    assert "di" in tl
def test_clear():
    tl = TodoList("test.db")
    tl.clear()
    with open("test.db") as f:
        assert f.read() == ""
def test_remove():
    tl = TodoList("test.db")
    tl.remove(0)
    assert "Blah" not in tl
def test_remove_persist():
    tl = TodoList("test.db")
    assert "Blah" not in tl
Пример #11
0
 def test_TodoList_can_add_empty_item(self):
     """If we want, we can have empty items."""
     todolist = TodoList(self.mock_persister)
     after_add_empty = "#1 "
     self.assertEqual(todolist.add(""), after_add_empty)
     self.assertEqual(1, len(self.mock_persister.tasks))
def test_add_again():
    tl = TodoList("test.db")
    tl.add("di")
    assert "di" in tl
Пример #13
0
class TodoListTester(unittest.TestCase):
	def setUp(self):
		self.todo = TodoList()
	
	def tearDown(self):
		del self.todo

	def test_add(self):
		item = 'Hello World'
		self.todo.add(item)
		self.assertEqual(self.todo.get(0), item)

	def test_find(self):
		item1 = 'ABCD'
		item2 = 'WXYZ'
		self.assertEqual(self.todo.find(item1), -1)
		for i in xrange(10):
			self.todo.add(item1)
		self.todo.add(item2)
		for i in xrange(10):
			self.todo.add(item1)
		self.assertEqual(self.todo.find(item2), 10)
		self.assertEqual(self.todo.find(item2[:2]), 10)
		self.assertEqual(self.todo.find(item2[1:3]), 10)
		self.assertEqual(self.todo.find(item2[2:]), 10)
		self.assertEqual(self.todo.find(item2.lower()), 10)

	def test_get_by_id(self):
		item = 'abcdefg'
		self.todo.add(item)
		self.assertEqual(self.todo.get(0), item)

	def test_complete_by_string(self):
		item = 'Hello World'
		self.todo.add(item)
		self.todo.complete(item)
		self.assertEqual(self.todo.find(item), -1)

	def test_complete_by_id(self):
		item = 'Hello World'
		self.todo.add(item)
		self.todo.complete(0)
		self.assertEqual(self.todo.find(item), -1)

	def test_list(self):
		self.assertEqual(self.todo.list_all(), '')
		item = 'Hello World'
		self.todo.add(item)
		self.assertEqual(self.todo.list_all(), item)
		self.todo.add(item)
		self.assertEqual(self.todo.list_all(), '{0:s}\n{0:s}'.format(item))
	
	def test_move_by_string(self):
		for s in ['a', 'b', 'c']:
			self.todo.add(s)
		self.todo.move(0, 'c')
		self.assertEqual(self.todo.find('c'), 0)

	def test_move_by_id(self):
		for s in ['a', 'b', 'c']:
			self.todo.add(s)
		self.todo.move(0, 2)
		self.assertEqual(self.todo.find('c'), 0)
Пример #14
0
 def __init__(self, persister):
     self.persister = persister
     self.todolist = TodoList(self.persister)
     self.commands = {'add': self.todolist.add,
                      'do': self.todolist.do,
                      'print': self.todolist.print_all_tasks}
Пример #15
0
 def test_TodoList_cannot_print_empty_list(self):
     """Notify nicely that the todo-list is empty."""
     todolist = TodoList(self.mock_persister)
     after_print = "No entries yet."
     self.assertEqual(todolist.print_all_tasks([]), after_print)
Пример #16
0
	def setUp(self):
		self.todo = TodoList()
Пример #17
0
 def test_TodoList_notifies_that_empty_list_cannot_be_completed(self):
     """Notify that nicely that we cannot complete from an empty list."""
     todolist = TodoList(self.mock_persister)
     after_do_empty = "No entries to do yet."
     self.assertEqual(todolist.do("1"), after_do_empty)
Пример #18
0
 def test_TodoList_notifies_if_id_is_not_a_number(self):
     todolist = TodoList(self.mock_persister)
     todolist.add("New message")
     after_invalid = "Error: ID must be number."
     self.assertEqual(todolist.do("fem"), after_invalid)
Пример #19
0
 def test_TodoList_notifies_if_id_does_not_exist(self):
     todolist = TodoList(self.mock_persister)
     todolist.add("New message")
     after_invalid = "Error: ID 404 not found."
     self.assertEqual(todolist.do("404"), after_invalid)
Пример #20
0
# Use this file as your main entrypoint for your program
from todo import TodoList, getCommandArguments, get_cli

if __name__ == "__main__":

    # Initialise TodoList Object
    todo = TodoList()

    # Create TODO item(s)
    if get_cli().command[0] == "create":
        x = getCommandArguments(get_cli().command)
        todo.createTodo(x)

    # List item(s)
    if get_cli().command[0] == "list-all":
        # Handle --substring CLI argument
        if get_cli().substring:
            todo.readListSubstring(get_cli().substring[0])
        # Handle --no-complete CLI argument
        elif get_cli().no_complete:
            todo.readListNotComplete(get_cli().no_complete[0])
        # Handle --complete CLI argument
        elif get_cli().complete:
            todo.readListComplete(get_cli().complete[0])
        else:
            # Handle 'list-all'
            if len(get_cli().command) == 1:
                print("All TODO items below:")
                todo.readListAll()
            # Catch for inputs after list-all
            else:
def test_persist():
    tl = TodoList("test.db")
    assert "Blah" in tl
Пример #22
0
class TodoListTester(unittest.TestCase):
	def setUp(self):
		self.todo = TodoList()
	
	def tearDown(self):
		del self.todo

	def test_add(self):
		args = ArgumentHolder(todo='Hello World')
		self.todo.add(args)
		self.assertEqual(self.todo.get(0), 'Hello World')

	def test_find_uses_digits(self):
		args = ArgumentHolder(todo='Hello World')
		self.todo.add(args)
		self.todo.add(args)
		self.assertEqual(self.todo.find('1'), 1)
	
	def test_find_by_digits_clamps(self):
		self.assertEqual(self.todo.find('2'), -1)

	def test_find_uses_string(self):
		args = ArgumentHolder(todo='Abc')
		self.todo.add(args)
		self.assertEqual(self.todo.find('Abc'), 0)

	def test_fuzzy_find(self):
		args = ArgumentHolder(todo='A Very Long String')
		self.todo.add(args)
		self.assertEqual(self.todo.find('very'), 0)

	def test_list(self):
		args = ArgumentHolder()
		self.assertEqual(self.todo.list_all(args), '')
		args = ArgumentHolder(todo='Hello World')
		self.todo.add(args)
		self.assertEqual(self.todo.list_all(args), 'Hello World')
		self.todo.add(args)
		self.assertEqual(self.todo.list_all(args), '{0:s}\n{0:s}'.format('Hello World'))
	
	def test_move_by_string(self):
		for s in ['a', 'b', 'c']:
			args = ArgumentHolder(todo=s)
			self.todo.add(args)

		args = ArgumentHolder(todo='c', new_location=0)
		self.todo.move(args)
		self.assertEqual(self.todo.find('c'), 0)

	def test_move_by_id(self):
		for s in ['a', 'b', 'c']:
			args = ArgumentHolder(todo=s)
			self.todo.add(args)

		args = ArgumentHolder(todo='2', new_location=0)
		self.todo.move(args)
		self.assertEqual(self.todo.find('c'), 0)
Пример #23
0
 def test_first_TodoList_is_empty(self):
     """A blank TodoList should be empty."""
     new = TodoList(self.mock_persister)
     self.assertEqual(new.next_id, 1)
     self.assertEqual(new.tasks, list())
     self.assertEqual(self.mock_persister.load_count, 1)
Пример #24
0
    "ExtraTreesClassifier": ExtraTreesClassifier,  # 1120
    "GaussianNB": GaussianNB,  # 1
    "GradientBoostingClassifier": GradientBoostingClassifier,  # 7840
    "KNeighborsClassifier": KNeighborsClassifier,  # 54
    "LinearSVC": LinearSVC,  # 320
    "LogisticRegression": LogisticRegression,  # 240
    "MultinomialNB": MultinomialNB,  # 20
    "PassiveAggressiveClassifier": PassiveAggressiveClassifier,  # 44
    "RandomForestClassifier": RandomForestClassifier,  # 1120
    "SGDClassifier": SGDClassifier,  # 5000
    "SVC": SVC,  # 1232
    "XGBClassifier": XGBClassifier  # 30492
}

# todos = {}
todos = TodoList()
resultdir = "."
count = 0
total = 0


def flatten(l):
    return [item for sublist in l for item in sublist]


def make_parser():
    descr = "Scheduler that hands out trials and collects results."
    parser = argparse.ArgumentParser(description=descr)

    parser.add_argument('resultdir', action="store")
    parser.add_argument('-p', '--port', action="store", default=3000, type=int)
Пример #25
0
 def __init__(self, owner_id, tlist=TodoList(), uid=None):
     self.owner_id = owner_id
     self.tlist = tlist
     self.uid = uid