def test_add_item2(self): quarter = TodoQuarter() date = datetime(2017, 7, 4) quarter.add_item('implement Quarter Class', date) self.assertEqual(quarter.todo_items[0].deadline, date) self.assertEqual(quarter.todo_items[0].title, 'implement Quarter Class')
def __init__(self): self.todo_quarters = { 'IU': TodoQuarter(), 'IN': TodoQuarter(), 'NU': TodoQuarter(), 'NN': TodoQuarter() }
def __init__(self): """ Method creates an instance of the class Returns: None """ self.todo_quarters = { 'IU': TodoQuarter(), 'IN': TodoQuarter(), 'NU': TodoQuarter(), 'NN': TodoQuarter()}
def __init__(self): ''' Constructs a *TodoMatrix* object with all possible quarters. * `todo_quarters` - data: dictionary - description: contains *TodoQuarter* objects key: string - status of todo_quarter, value: *TodoQuarter* object possible status of TODO quarter: - 'IU' means that todo_quarter contains important todo_items & urgent - 'IN' means that todo_quarter contains important todo_items & not urgent - 'NU' means that todo_quarter contains not important todo_items & urgent - 'NN' means that todo_quarter contains not important & not urgent todo_items ''' self.todo_quarters = {'IU': TodoQuarter(), 'IN': TodoQuarter(), 'NU': TodoQuarter(), 'NN': TodoQuarter()}
def test_sort_items(self): quarter = TodoQuarter() date1 = datetime(2017, 6, 14) date2 = datetime(2017, 5, 24) date3 = datetime(2017, 6, 4) date4 = datetime(2017, 7, 3) date5 = datetime(2017, 6, 23) quarter.add_item('go to Codecool', date1) quarter.add_item('make a coffee', date2) quarter.add_item('start coding', date3) quarter.add_item('more coffee', date4) quarter.add_item('more coding', date5) self.assertEqual(quarter.todo_items[0].deadline, date2) self.assertEqual(quarter.todo_items[1].deadline, date3) self.assertEqual(quarter.todo_items[2].deadline, date1) self.assertEqual(quarter.todo_items[3].deadline, date5) self.assertEqual(quarter.todo_items[4].deadline, date4)
def test_remove_item(self): quarter = TodoQuarter() date = datetime(2017, 7, 4) date2 = datetime(2017, 6, 14) date3 = datetime(2017, 9, 24) quarter.add_item('go to Codecool', date) quarter.add_item('make a coffee', date2) quarter.add_item('code', date3) quarter.remove_item(1) self.assertEqual(len(quarter.todo_items), 2, 'Incorrect lenght of todo_items list') self.assertEqual(quarter.todo_items[1].title, 'code', 'Incorrect item')
def test_archive_items(self): quarter = TodoQuarter() date = datetime(2017, 6, 16) date2 = datetime(2017, 6, 14) date3 = datetime(2017, 7, 24) quarter.add_item('go to Codecool', date) quarter.add_item('make a coffee', date2) quarter.add_item('code', date3) quarter.todo_items[0].mark() quarter.archive_items() self.assertEqual(len(quarter.todo_items), 2, 'Incorrect lenght of todo_items list') self.assertEqual(quarter.todo_items[0].title, 'go to Codecool', 'Incorrect item')
def test_str(self): quarter = TodoQuarter() date = datetime(2017, 6, 16) date2 = datetime(2017, 6, 14) date3 = datetime(2017, 7, 24) quarter.add_item('go to Codecool', date) quarter.add_item('make a coffee', date2) quarter.add_item('code', date3) quarter.todo_items[1].mark() quarter_string = quarter.__str__() self.assertIsInstance(quarter_string, str, msg='it\'s not a string!') self.assertEqual(quarter_string[0:6], '1. [ ]') self.assertEqual(quarter_string[26:32], '2. [x]')
def __init__(self): self.todo_quarters = {} for name in TodoMatrix.Quarters_names: self.todo_quarters[name] = TodoQuarter()
def test_add_item_error(self): quarter = TodoQuarter() with self.assertRaises(ValueError, msg='Incorrect deadline'): quarter.add_item('implement Quarter Class', 'error date')
def test_constructor(self): quarter = TodoQuarter() self.assertEqual(quarter.todo_items, [])
def test_get_item_error(self): quarter = TodoQuarter() with self.assertRaises(IndexError, msg='Index out of range list todo_items'): quarter.get_item(5)
def test_get_item(self): date = datetime(2017, 7, 4) quarter = TodoQuarter() quarter.add_item('implement Quarter Class', date) item = quarter.get_item(0) self.assertIsInstance(item, TodoItem)
def main(): quarter = TodoQuarter() matrix = TodoMatrix() menu(matrix, quarter)